More tests for RepositoryChange

This commit is contained in:
Dmitry Petrov
2017-03-26 22:46:05 -07:00
parent 4fdd7cd460
commit a6ec1ea9bf
+11 -4
View File
@@ -16,13 +16,14 @@ class TestRepositoryChange(TestCase):
self.tearDown()
os.mkdir(self.test_dir)
os.chdir(self.test_dir)
os.mkdir('data')
devnull = open(os.devnull, 'w')
subprocess.Popen(['git', 'init'], stdout=devnull, stderr=None).wait()
self.file_to_modify = 'file1.txt'
self.file_created_before_run = 'file2.txt'
self.file_created_by_run = 'out.txt'
self.file_created_by_run = os.path.join('data', 'out.txt')
self.file_to_remove = 'file3.txt'
self.create_file(self.file_to_modify)
@@ -49,7 +50,7 @@ class TestRepositoryChange(TestCase):
fd.write('random text')
fd.close()
def test_df(self):
def test_all(self):
change = RepositoryChange(['ls', '-la'],
self.file_created_by_run,
self.file_to_modify,
@@ -63,6 +64,12 @@ class TestRepositoryChange(TestCase):
self.assertEqual(change.removed_files, [os.path.realpath(self.file_to_remove)])
self.assertEqual(change.modified_files, [os.path.realpath(self.file_to_modify)])
expected_to_change = expected_new + [self.file_to_modify]
self.assertEqual(set(change.changed_files), set(map(os.path.realpath, expected_to_change)))
expected_to_change_set = set(map(os.path.realpath, expected_new + [self.file_to_modify]))
self.assertEqual(set(change.changed_files), expected_to_change_set)
expected_to_change_set.remove(os.path.realpath(self.file_created_by_run))
self.assertEqual(expected_to_change_set, set(change.externally_created_files))
self.assertEqual(1, len(change.data_items_for_changed_files))
self.assertEqual(self.file_created_by_run, change.data_items_for_changed_files[0].data.dvc)
pass