def test_save_artifact(self): """Artifact needs to be created.""" cch = Handler() new_artifact = cch._save_artifact(self.download_result_mock("c1"), self.ra1) c1 = Content.objects.get(pk=self.c1.pk) self.assertIsNotNone(new_artifact) self.assertEqual(c1._artifacts.get().pk, new_artifact.pk)
def test_save_content_artifact(self): """Artifact needs to be created.""" cch = Handler() new_artifact = cch._save_content_artifact(self.download_result_mock('c1'), ContentArtifact.objects.get(pk=self.c1.pk)) c1 = Content.objects.get(pk=self.c1.pk) self.assertIsNotNone(new_artifact) self.assertEqual(c1._artifacts.get().pk, new_artifact.pk)
def test_save_artifact_artifact_already_exists(self): """Artifact turns out to already exist.""" cch = Handler() new_artifact = cch._save_artifact(self.download_result_mock("c1"), self.ra1) existing_artifact = cch._save_artifact(self.download_result_mock("c2"), self.ra2) c2 = Content.objects.get(pk=self.c2.pk) self.assertEqual(existing_artifact.pk, new_artifact.pk) self.assertEqual(c2._artifacts.get().pk, existing_artifact.pk)
def test_save_content_artifact(self): """Artifact needs to be created.""" cch = Handler() new_artifact = cch._save_content_artifact( self.download_result_mock('f1'), ContentArtifact.objects.get(pk=self.f1.pk)) f1 = FileContent.objects.get(pk=self.f1.pk) self.assertIsNotNone(new_artifact) self.assertEqual(f1._artifacts.get().pk, new_artifact.pk)
def test_save_content_artifact_artifact_already_exists(self): """Artifact turns out to already exist.""" cch = Handler() new_artifact = cch._save_content_artifact(self.download_result_mock('c1'), ContentArtifact.objects.get(pk=self.c1.pk)) existing_artifact = cch._save_content_artifact(self.download_result_mock('c2'), ContentArtifact.objects.get(pk=self.c2.pk)) c2 = Content.objects.get(pk=self.c2.pk) self.assertEqual(existing_artifact.pk, new_artifact.pk) self.assertEqual(c2._artifacts.get().pk, existing_artifact.pk)
def test_save_content_artifact_artifact_already_exists(self): """Artifact turns out to already exist.""" cch = Handler() new_artifact = cch._save_content_artifact( self.download_result_mock('f1'), ContentArtifact.objects.get(pk=self.f1.pk)) existing_artifact = cch._save_content_artifact( self.download_result_mock('f2'), ContentArtifact.objects.get(pk=self.f2.pk)) f2 = FileContent.objects.get(pk=self.f2.pk) self.assertEqual(existing_artifact.pk, new_artifact.pk) self.assertEqual(f2._artifacts.get().pk, existing_artifact.pk)