def test_generate_rerun_data(self): """ Tests that completed Rerun data contains the completed flag. """ drop_a = AbstractDROP("a", "a") drop_a.reproducibility_level = ReproducibilityFlags.RERUN drop_a.setCompleted() self.assertEqual(drop_a.generate_rerun_data(), {"status": DROPStates.COMPLETED})
def test_recommit(self): """ Should raise an exception preventing a straight-recommit. """ a = AbstractDROP('a', 'a') a.reproducibility_level = ReproducibilityFlags.RERUN a.setCompleted() with self.assertRaises(Exception): a.commit()
def test_generate_rerun_data(self): """ Tests that completed Rerun data contains the completed flag. """ a = AbstractDROP('a', 'a') a.reproducibility_level = ReproducibilityFlags.RERUN a.setCompleted() self.assertEqual(a.generate_rerun_data(), {'status': DROPStates.COMPLETED})
def test_set_reproducibility_level(self): """ Tests functionality for changing a DROP's reproducibility flag If already committed. The drop should reset and re-commit all reproducibility data If not committed, the change can proceed simply. """ a = AbstractDROP('a', 'a') b = AbstractDROP('b', 'b') a.reproducibility_level = ReproducibilityFlags.NOTHING b.reproducibility_level = ReproducibilityFlags.NOTHING a.setCompleted() self.assertIsNone(a.merkleroot) a.reproducibility_level = ReproducibilityFlags.RERUN self.assertIsNotNone(a.merkleroot) self.assertIsNone(b.merkleroot) b.reproducibility_level = ReproducibilityFlags.RERUN b.setCompleted() self.assertIsNotNone(b.merkleroot) with self.assertRaises(TypeError): a.reproducibility_level = 'REPEAT'
def test_set_reproducibility_level(self): """ Tests functionality for changing a DROP's reproducibility flag If already committed. The drop should reset and re-commit all reproducibility data If not committed, the change can proceed simply. """ drop_a = AbstractDROP("a", "a") drop_b = AbstractDROP("b", "b") drop_a.reproducibility_level = ReproducibilityFlags.NOTHING drop_b.reproducibility_level = ReproducibilityFlags.NOTHING drop_a.setCompleted() self.assertIsNone(drop_a.merkleroot) drop_a.reproducibility_level = ReproducibilityFlags.RERUN drop_a.commit() self.assertIsNotNone(drop_a.merkleroot) self.assertIsNone(drop_b.merkleroot) drop_b.reproducibility_level = ReproducibilityFlags.RERUN drop_b.setCompleted() self.assertIsNotNone(drop_b.merkleroot) with self.assertRaises(TypeError): drop_a.reproducibility_level = "REPEAT"
def test_commit_on_complete(self): """ Tests that merkle_data is generated upon set_complete status and is correct (NOTHING, RERUN) """ drop_a = AbstractDROP("a", "a") drop_b = AbstractDROP("b", "b") drop_a.reproducibility_level = ReproducibilityFlags.RERUN drop_b.reproducibility_level = ReproducibilityFlags.NOTHING self.assertIsNone(drop_a.merkleroot) self.assertIsNone(drop_b.merkleroot) # Test RERUN drop_a.setCompleted() test = MerkleTree({"status": DROPStates.COMPLETED}.items(), common_hash) # 689fcf0d74c42200bef177db545adc43c135dfb0d7dc85b166db3af1dcded235 self.assertTrue(test.merkle_root == drop_a.merkleroot) # Test NOTHING drop_b.setCompleted() # None self.assertIsNone(drop_b.merkleroot) self.assertTrue(drop_b._committed)