Skip to content

Commit

Permalink
tweak tests for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bckohan committed Sep 7, 2024
1 parent 972a67d commit 96fae54
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion tests/djenum/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,10 @@ class EnumFlagTester(EnumFlagTesterBase):

extra_big_neg = EnumField(
ExtraBigNegativeFlagEnum,
default=ExtraBigNegativeFlagEnum(0),
default=None,
db_index=True,
blank=True,
null=True,
)

def __repr__(self):
Expand Down
5 changes: 1 addition & 4 deletions tests/enum_prop/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,7 @@ class BaseEnumFlagPropTester(models.Model):
)

extra_big_neg = EnumField(
ExtraBigNegativeFlagEnum,
default=ExtraBigNegativeFlagEnum(0),
db_index=True,
blank=True,
ExtraBigNegativeFlagEnum, default=None, db_index=True, blank=True, null=True
)

def __repr__(self):
Expand Down
9 changes: 9 additions & 0 deletions tests/test_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,3 +448,12 @@ def test_unsupported_flags(self):

with self.assertRaises(FieldError):
self.MODEL_CLASS.objects.filter(**{"field__has_all": EnumClass.ONE})

def test_extra_big_flags(self):
obj = self.MODEL_CLASS.objects.create()
obj.refresh_from_db()
self.assertTrue(obj.extra_big_neg is None)
self.assertEqual(obj.extra_big_pos, 0)

self.assertEqual(obj, self.MODEL_CLASS.objects.get(extra_big_pos=0))
self.assertEqual(obj, self.MODEL_CLASS.objects.get(extra_big_neg__isnull=True))

0 comments on commit 96fae54

Please sign in to comment.