Skip to content

Commit

Permalink
Fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Mogost committed Aug 19, 2024
1 parent 197e833 commit 9569fb8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ source = constance
branch = 1
omit =
*/pytest.py
*/tests/*

[report]
omit = *tests*,*migrations*,.tox/*,setup.py,*settings.py
2 changes: 1 addition & 1 deletion constance/migrations/0003_drop_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def import_module_attr(path):
return getattr(import_module(package), module)


def migrate_pickled_data(apps, schema_editor) -> None:
def migrate_pickled_data(apps, schema_editor) -> None: # pragma: no cover
Constance = apps.get_model('constance', 'Constance')

for constance in Constance.objects.exclude(value=None):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ def test_serializes_and_deserializes_default_types(self):
):
self.assertEqual(t, loads(dumps(t)))

def test_invalid_deserialization(self):
with self.assertRaises(ValueError):
loads('THIS_IS_NOT_RIGHT')
with self.assertRaises(ValueError):
loads('{"__type__": "not_registred", "__value__": "test"}')

def test_handles_unknown_type(self):
class UnknownType:
pass
Expand All @@ -73,6 +79,8 @@ def __init__(self, value):
self.assertEqual(deserialized_data.value, 'test')

def test_register_known_type(self):
with self.assertRaises(ValueError):
register_type(int, '', lambda o: o.value, lambda o: int(o))
with self.assertRaises(ValueError):
register_type(int, 'default', lambda o: o.value, lambda o: int(o))
register_type(int, 'new_custom_type', lambda o: o.value, lambda o: int(o))
Expand Down

0 comments on commit 9569fb8

Please sign in to comment.