summaryrefslogtreecommitdiff
path: root/ishtar_common/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/tests.py')
-rw-r--r--ishtar_common/tests.py32
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):