Skip to content
Closed
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
8 changes: 4 additions & 4 deletions gittensor/utils/mirror/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ def from_dict(cls, data: dict) -> 'MirrorReviewSummary':
'defaulting to 0 (review penalty/clean-bonus may be miscalculated)'
)
return cls(
maintainer_changes_requested_count=data.get('maintainer_changes_requested_count', 0),
changes_requested_count=data.get('changes_requested_count', 0),
approved_count=data.get('approved_count', 0),
commented_count=data.get('commented_count', 0),
maintainer_changes_requested_count=int(data.get('maintainer_changes_requested_count', 0)),
changes_requested_count=int(data.get('changes_requested_count', 0)),
approved_count=int(data.get('approved_count', 0)),
commented_count=int(data.get('commented_count', 0)),
)


Expand Down
18 changes: 18 additions & 0 deletions tests/utils/test_mirror_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,24 @@ def test_no_warn_when_field_present_even_if_zero(self, mock_logging):
MirrorReviewSummary.from_dict({'maintainer_changes_requested_count': 0})
mock_logging.warning.assert_not_called()

def test_counts_coerced_to_int(self):
"""Counts are returned as ints even if the mirror serializes them as
strings, matching the int() coercion every other numeric model field uses.
"""
rs = MirrorReviewSummary.from_dict(
{
'maintainer_changes_requested_count': '2',
'changes_requested_count': '3',
'approved_count': '1',
'commented_count': '4',
}
)
assert rs.maintainer_changes_requested_count == 2
assert isinstance(rs.maintainer_changes_requested_count, int)
assert rs.changes_requested_count == 3
assert rs.approved_count == 1
assert rs.commented_count == 4


# ============================================================================
# MirrorLinkedIssue
Expand Down
Loading