Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #719: fix crash in metrics when no changes to approve #720

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading