|
@@ -3,6 +3,8 @@ from contextlib import closing
|
|
|
|
|
|
from pycs import db
|
|
|
from pycs.database.Database import Database
|
|
|
+from pycs.database.File import File
|
|
|
+from pycs.database.Label import Label
|
|
|
from pycs.database.Model import Model
|
|
|
from pycs.database.LabelProvider import LabelProvider
|
|
|
|
|
@@ -132,5 +134,45 @@ class TestDatabase(unittest.TestCase):
|
|
|
self.assertEqual(list(self.database.projects())[0].description, 'Description 0')
|
|
|
|
|
|
|
|
|
+ def test_no_files_after_project_deletion(self):
|
|
|
+
|
|
|
+ project = self.database.project(1)
|
|
|
+ for i in range(5):
|
|
|
+ file, is_new = project.add_file(
|
|
|
+ uuid=f"some_string{i}",
|
|
|
+ name=f"some_name{i}",
|
|
|
+ filename=f"some_filename{i}",
|
|
|
+ file_type="image",
|
|
|
+ extension=".jpg",
|
|
|
+ size=42,
|
|
|
+ )
|
|
|
+
|
|
|
+ self.assertTrue(is_new)
|
|
|
+ self.assertIsNotNone(file)
|
|
|
+
|
|
|
+ self.assertEqual(5, File.query.filter_by(project_id=project.id).count())
|
|
|
+
|
|
|
+ project.remove()
|
|
|
+ self.assertIsNone(self.database.project(1))
|
|
|
+ self.assertEqual(0, File.query.filter_by(project_id=project.id).count())
|
|
|
+
|
|
|
+ def test_no_labels_after_project_deletion(self):
|
|
|
+
|
|
|
+ project = self.database.project(1)
|
|
|
+ for i in range(5):
|
|
|
+ label, is_new = project.create_label(
|
|
|
+ name=f"label{i}",
|
|
|
+ reference=f"ref{i}"
|
|
|
+ )
|
|
|
+
|
|
|
+ self.assertTrue(is_new)
|
|
|
+ self.assertIsNotNone(label)
|
|
|
+
|
|
|
+ self.assertEqual(5, Label.query.filter_by(project_id=project.id).count())
|
|
|
+
|
|
|
+ project.remove()
|
|
|
+ self.assertIsNone(self.database.project(1))
|
|
|
+ self.assertEqual(0, Label.query.filter_by(project_id=project.id).count())
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
unittest.main()
|