Skip to content

Commit

Permalink
added test_mock_model_annotation_by_nested_field test
Browse files Browse the repository at this point in the history
  • Loading branch information
DvirH-Qspark committed Jun 26, 2024
1 parent 8e082fe commit 5f6a092
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1356,3 +1356,11 @@ def test_empty_queryset_filter(self):
mockset = MockSet(car1, car2)
self.assertEqual(mockset.count(), 2)
self.assertEqual(mockset.filter(Q()).count(), 2)

def test_mock_model_annotation_by_nested_field():
mockset = MockSet(
MockModel(id=1, nested_mock=MockModel(id=1, field1="field_value"))
)
field1 = mockset.annotate(field1=models.F("nested_mock__field1")).values_list("field1")[0][0]

assert field1 == "field_value"

0 comments on commit 5f6a092

Please sign in to comment.