diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-08-29 18:39:43 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-01 10:32:52 +0200 |
commit | 954951026722f59a7b9d988d8f01d34c2fb24096 (patch) | |
tree | 945ed8fb2ddd8c44632a561b7f36386dce19aa00 /ishtar_common/tests.py | |
parent | 9666ede3c0f72fb1d8ccd38d3c957980b2f28efa (diff) | |
download | Ishtar-954951026722f59a7b9d988d8f01d34c2fb24096.tar.bz2 Ishtar-954951026722f59a7b9d988d8f01d34c2fb24096.zip |
Restoration: restore types
Diffstat (limited to 'ishtar_common/tests.py')
-rw-r--r-- | ishtar_common/tests.py | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 03c2ad03a..e292ae097 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -632,16 +632,30 @@ class SerializationTest(TestCase): restore_serialized(zip_filename) def test_type_restore(self): + models.AuthorType.objects.create(label="Test", txt_idx="test") + zip_filename = type_serialization(archive=True) - initial_count = {} - with zipfile.ZipFile(zip_filename, "r") as zip_file: - for json_filename in zip_file.namelist(): - path = json_filename.split(os.sep) - if len(path) != 2 or path[0] != "types": - continue - model = get_model_from_filename(path[-1]) - initial_count[json_filename] = model.objects.count() - model.objects.all().delete() + models.AuthorType.objects.create( + label="Am I still here", txt_idx="am-i-still-here") + models.AuthorType.objects.filter(txt_idx="test").delete() + restore_serialized(zip_filename) + self.assertEqual( + models.AuthorType.objects.filter(txt_idx="test").count(), 1) + self.assertEqual( + models.AuthorType.objects.filter(txt_idx="am-i-still-here").count(), + 1) + + models.AuthorType.objects.filter(txt_idx="am-i-still-here").delete() + zip_filename = type_serialization(archive=True) + models.AuthorType.objects.create( + label="Am I still here", txt_idx="am-i-still-here") + models.AuthorType.objects.filter(txt_idx="test").delete() + restore_serialized(zip_filename, delete_existing=True) + self.assertEqual( + models.AuthorType.objects.filter(txt_idx="test").count(), 1) + self.assertEqual( + models.AuthorType.objects.filter(txt_idx="am-i-still-here").count(), + 0) class AccessControlTest(TestCase): |