def test_snapshot_deletion_of_non_reference_snapshot(self): """ Test that when snapshot is deleted and is not a reference for other snapshot, nothing happens Here, S1 is a reference S2 has a reference on S1 S3 has a reference on S1 After deletion of S2, S3 should still have reference on S1 """ s1 = Snapshot(stepResult=self.tsr1, image=None, refSnapshot=None, pixelsDiff=None) s1.save() s2 = Snapshot(stepResult=self.tsr2, image=None, refSnapshot=s1, pixelsDiff=None) s2.save() s3 = Snapshot(stepResult=self.tsr2, image=None, refSnapshot=s1, pixelsDiff=None) s3.save() s2.delete() self.assertEqual(Snapshot.objects.get(pk=s3.id).refSnapshot, s1)
def test_snapshot_deletion_and_recomputing_on_previous_reference(self): """ Test that when snapshot is deleted and is a reference for other snapshot, this reference is removed and replaced by a previous reference when it exists Here, S1 is a reference S2 is a reference S3 has a reference on S2 After deletion of S2, S3 should have reference on S1 """ s1 = Snapshot(stepResult=self.tsr1, image=None, refSnapshot=None, pixelsDiff=None) s1.save() s2 = Snapshot(stepResult=self.tsr2, image=None, refSnapshot=None, pixelsDiff=None) s2.save() s3 = Snapshot(stepResult=self.tsr2, image=None, refSnapshot=s2, pixelsDiff=None) s3.save() s2.delete() self.assertEqual(Snapshot.objects.get(pk=s3.id).refSnapshot, s1)
def test_snapshot_deletion_of_last_snapshot(self): """ Test that nothing happens when the deleted snapshot is the last one Here, S1 is a reference S2 has a reference on S1 S3 has a reference on S1 After deletion of S1, S2 becomes a reference S3 should have reference on S2 """ s1 = Snapshot(stepResult=self.tsr1, image=None, refSnapshot=None, pixelsDiff=None) s1.save() s2 = Snapshot(stepResult=self.tsr2, image=None, refSnapshot=s1, pixelsDiff=None) s2.save() s2.delete() self.assertEqual(Snapshot.objects.get(pk=s1.id).refSnapshot, None)
def test_snapshot_deletion_of_first_reference(self): """ Test that when first reference is deleted, other pictures have their references changed Here, S1 is a reference S2 has a reference on S1 S3 has a reference on S1 After deletion of S1, S2 becomes a reference S3 should have reference on S2 """ s1 = Snapshot(stepResult=self.tsr1, image=None, refSnapshot=None, pixelsDiff=None) s1.save() s2 = Snapshot(stepResult=self.tsr2, image=None, refSnapshot=s1, pixelsDiff=None) s2.save() s3 = Snapshot(stepResult=self.tsr2, image=None, refSnapshot=s1, pixelsDiff=None) s3.save() s1.delete() self.assertEqual(Snapshot.objects.get(pk=s2.id).refSnapshot, None) self.assertEqual(Snapshot.objects.get(pk=s3.id).refSnapshot, s2)