Skip to content

Commit

Permalink
remove all these extra mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
saponifi3d committed Jul 31, 2024
1 parent 834445d commit 4bac969
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions tests/sentry/rules/processing/test_delayed_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1344,30 +1344,22 @@ def setUp(self):

@patch("sentry.rules.processing.delayed_processing.apply_delayed")
def test_no_redis_data(self, mock_apply_delayed):
mock_delayed = Mock()
mock_apply_delayed.delayed = mock_delayed
process_rulegroups_in_batches(self.project.id)

mock_delayed.assert_called_once_with(self.project.id)
mock_apply_delayed.delayed.assert_called_once_with(self.project.id)

@patch("sentry.rules.processing.delayed_processing.apply_delayed")
def test_basic(self, mock_apply_delayed):
mock_delayed = Mock()
mock_apply_delayed.delayed = mock_delayed

self.push_to_hash(self.project.id, self.rule.id, self.group.id)
self.push_to_hash(self.project.id, self.rule.id, self.group_two.id)
self.push_to_hash(self.project.id, self.rule.id, self.group_three.id)

process_rulegroups_in_batches(self.project.id)
mock_delayed.assert_called_once_with(self.project.id)
mock_apply_delayed.delayed.assert_called_once_with(self.project.id)

@override_options({"delayed_processing.batch_size": 2})
@patch("sentry.rules.processing.delayed_processing.apply_delayed")
def test_batch(self, mock_apply_delayed):
mock_delayed = Mock()
mock_apply_delayed.delayed = mock_delayed

mock_delayed = mock_apply_delayed.delayed
self.push_to_hash(self.project.id, self.rule.id, self.group.id)
self.push_to_hash(self.project.id, self.rule.id, self.group_two.id)
self.push_to_hash(self.project.id, self.rule.id, self.group_three.id)
Expand Down Expand Up @@ -1440,8 +1432,6 @@ def test_cleanup_redis(self):
@override_options({"delayed_processing.batch_size": 2})
@patch("sentry.rules.processing.delayed_processing.apply_delayed")
def test_batched_cleanup(self, mock_apply_delayed):
mock_delayed = Mock()
mock_apply_delayed.delayed = mock_delayed
group_two = self.create_group(self.project)
group_three = self.create_group(self.project)

Expand All @@ -1455,8 +1445,8 @@ def test_batched_cleanup(self, mock_apply_delayed):
rules_to_groups[self.rule.id].add(group_three.id)

process_rulegroups_in_batches(self.project.id)
batch_one_key = mock_delayed.call_args_list[0][0][1]
batch_two_key = mock_delayed.call_args_list[1][0][1]
batch_one_key = mock_apply_delayed.delayed.call_args_list[0][0][1]
batch_two_key = mock_apply_delayed.delayed.call_args_list[1][0][1]

# Verify process_rulegroups_in_batches removed the data from the buffer
rule_group_data = buffer.backend.get_hash(Project, {"project_id": self.project.id})
Expand Down

0 comments on commit 4bac969

Please sign in to comment.