diff --git a/conntrackt/tests/test_models.py b/conntrackt/tests/test_models.py --- a/conntrackt/tests/test_models.py +++ b/conntrackt/tests/test_models.py @@ -117,6 +117,18 @@ class EntityTest(TestCase): self.assertEqual(entity.get_absolute_url(), "/conntrackt/entity/1/") + def test_project_move_constraints(self): + """ + Tests if entity is prevented from being moved to different project in + case of existing communications. + """ + + entity = Entity.objects.get(pk=1) + new_project = Project.objects.get(pk=2) + + entity.project = new_project + self.assertRaisesRegexp(ValidationError, "The entity cannot be moved to different project as long as it has valid communications with entities in current project." ,entity.clean) + class InterfaceTest(TestCase): fixtures = ['test-data.json']