Skip to content

Commit

Permalink
Add unit test for checking annotate returned instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolás Fantone committed Sep 4, 2024
1 parent 58c7b33 commit 67988f4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,13 @@ def test_annotate(self):

self.assertEqual(qs[2].color_or_car, 'kia')

def test_annotate_returns_current_class_instance(self):
class CustomMockSet(MockSet):
pass

qs = CustomMockSet(Car(model='golf', id=1))
self.assertIsInstance(qs.annotate(model=models.F('model')), CustomMockSet)

def test_query_values_raises_attribute_error_when_field_is_not_in_meta_concrete_fields(self):
qs = MockSet(MockModel(foo=1), MockModel(foo=2))
self.assertRaises(FieldError, qs.values, 'bar')
Expand Down

0 comments on commit 67988f4

Please sign in to comment.