Skip to content

Commit

Permalink
Fix #719: fix crash in metrics when no changes to approve
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Dec 5, 2024
1 parent 192f6cd commit f8ab807
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,14 @@ def get_source_records(self, **kwargs):
def get_destination_records(self, **kwargs):
return self._get_records(self.destination, **kwargs)

def push_records_to_destination(self, request):
def push_records_to_destination(self, request) -> int:
dest_records, _dest_timestamp = self.get_destination_records()
source_records, _source_timestamp = self.get_source_records()
new_records = records_diff(source_records, dest_records)
changes_count = len(new_records)

if len(new_records) == 0:
return None
return 0

# Update the destination collection.
for record in new_records:
Expand Down
15 changes: 15 additions & 0 deletions kinto-remote-settings/tests/signer/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,21 @@ def test_review_approved_is_triggered(self):
assert isinstance(self.events[-1], signer_events.ReviewApproved)
assert self.events[-1].changes_count == 2

def test_changes_count_is_zero_when_no_changes(self):
self.app.delete(
self.source_collection + "/records",
headers=self.headers,
)

self.app.patch_json(
self.source_collection,
{"data": {"status": "to-sign"}},
headers=self.headers,
)

assert isinstance(self.events[-1], signer_events.ReviewApproved)
assert self.events[-1].changes_count == 0

def test_review_approved_is_not_triggered_on_resign(self):
self.app.patch_json(
self.source_collection,
Expand Down

0 comments on commit f8ab807

Please sign in to comment.