def test_data_flow(self): analysis = Analysis(self.stage1, cache_path=TEST_CACHE) analysis.then(self.stage2) data = {} analysis.run(data) self.assertEqual(data, {}) self.assertEqual(self.data_before_stage1, {}) self.assertEqual(self.data_after_stage1, {"stage1": 5}) self.assertEqual(self.data_before_stage2, {"stage1": 5}) self.assertEqual(self.data_after_stage2, {"stage1": 5, "stage2": 25})
def test_caching(self): analysis = Analysis(self.stage1, cache_path=TEST_CACHE) analysis.then(self.stage2) analysis.run() self.assertEqual(self.executed_stage1, 1) self.assertEqual(self.executed_stage2, 1) analysis.run() self.assertEqual(self.executed_stage1, 1) self.assertEqual(self.executed_stage2, 1)
def test_descendent_fingerprint_deleted(self): analysis = Analysis(self.stage1, cache_path=TEST_CACHE) analysis.then(self.stage2) analysis.run() self.assertEqual(self.executed_stage1, 1) self.assertEqual(self.executed_stage2, 1) path = os.path.join(TEST_CACHE, 'stage2.fingerprint') os.remove(path) analysis.run() self.assertEqual(self.executed_stage1, 1) self.assertEqual(self.executed_stage2, 2)
def test_ancestor_fingerprint_mismatch(self): analysis = Analysis(self.stage1, cache_path=TEST_CACHE) analysis.then(self.stage2) analysis.run() self.assertEqual(self.executed_stage1, 1) self.assertEqual(self.executed_stage2, 1) path = os.path.join(TEST_CACHE, 'stage1.fingerprint') with open(path, 'w') as f: f.write('foo') analysis.run() self.assertEqual(self.executed_stage1, 2) self.assertEqual(self.executed_stage2, 2)
def test_descendent_fingerprint_deleted(self): analysis = Analysis(self.stage1, cache_path=TEST_CACHE) analysis.then(self.stage2) analysis.run() self.assertEqual(self.executed_stage1, 1) self.assertEqual(self.executed_stage2, 1) path = os.path.join(TEST_CACHE, "stage2.fingerprint") os.remove(path) analysis.run() self.assertEqual(self.executed_stage1, 1) self.assertEqual(self.executed_stage2, 2)
def test_data_flow(self): analysis = Analysis(self.stage1, cache_path=TEST_CACHE) analysis.then(self.stage2) data = {} analysis.run(data) self.assertEqual(data, {}) self.assertEqual(self.data_before_stage1, {}) self.assertEqual(self.data_after_stage1, { 'stage1': 5 }) self.assertEqual(self.data_before_stage2, { 'stage1' : 5 }) self.assertEqual(self.data_after_stage2, { 'stage1': 5, 'stage2': 25 })
def test_ancestor_fingerprint_mismatch(self): analysis = Analysis(self.stage1, cache_path=TEST_CACHE) analysis.then(self.stage2) analysis.run() self.assertEqual(self.executed_stage1, 1) self.assertEqual(self.executed_stage2, 1) path = os.path.join(TEST_CACHE, "stage1.fingerprint") with open(path, "w") as f: f.write("foo") analysis.run() self.assertEqual(self.executed_stage1, 2) self.assertEqual(self.executed_stage2, 2)