Tests for GC command

This commit is contained in:
Dmitry Petrov
2017-06-17 17:08:17 -07:00
parent f2bac9aac1
commit 9062da3f79
6 changed files with 197 additions and 23 deletions
+8 -12
View File
@@ -1,7 +1,6 @@
import os
from dvc.command.remove import CmdDataRemove, DataRemoveError
from dvc.path.data_item import DataItemError
from dvc.command.remove import CmdDataRemove
from tests.basic_env import DirHierarchyEnvironment
@@ -16,7 +15,7 @@ class TestCmdDataRemove(DirHierarchyEnvironment):
dir1_dvc_name = os.path.join('data', self.dir1)
self.assertTrue(os.path.exists(dir1_dvc_name))
cmd.remove_dir_file_by_file(dir1_dvc_name)
cmd.remove_dir(dir1_dvc_name)
self.assertFalse(os.path.exists(dir1_dvc_name))
def test_remove_deep_dir(self):
@@ -38,8 +37,7 @@ class TestCmdDataRemove(DirHierarchyEnvironment):
dir1_dvc_name = os.path.join('data', self.dir1)
self.assertTrue(os.path.exists(dir1_dvc_name))
with self.assertRaises(DataRemoveError):
cmd.remove_dir(dir1_dvc_name)
cmd.remove_dir(dir1_dvc_name)
pass
def test_data_dir_removal(self):
@@ -50,8 +48,7 @@ class TestCmdDataRemove(DirHierarchyEnvironment):
data_dir = 'data'
self.assertTrue(os.path.exists(data_dir))
with self.assertRaises(DataRemoveError):
cmd.remove_dir(data_dir)
cmd.remove_dir(data_dir)
pass
@@ -95,9 +92,8 @@ class TestRemoveDataItem(DirHierarchyEnvironment):
self.assertTrue(os.path.exists(self.state6))
self.assertTrue(os.path.isfile(self.state6))
with self.assertRaises(DataItemError):
cmd.remove_file(self.file6)
self.assertTrue(os.path.exists(self.file6))
cmd.remove_file(self.file6)
self.assertFalse(os.path.exists(self.file6))
class TestRemoveEndToEnd(DirHierarchyEnvironment):
@@ -148,7 +144,7 @@ class TestRemoveEndToEnd(DirHierarchyEnvironment):
self.assertTrue(os.path.exists(dir2_full))
self.assertTrue(os.path.exists(self.file1))
self.assertTrue(cmd.remove_all_targets())
self.assertTrue(cmd.remove_all())
self.assertFalse(os.path.exists(dir11_full))
self.assertFalse(os.path.exists(self.file5))
@@ -202,7 +198,7 @@ class TestRemoveEndToEndWithAnError(DirHierarchyEnvironment):
self.assertTrue(os.path.exists(self.file1))
self.assertTrue(os.path.exists(self.file6))
self.assertTrue(cmd.remove_all_targets())
self.assertTrue(cmd.remove_all())
self.assertFalse(os.path.exists(dir11_full))
self.assertFalse(os.path.exists(self.file5))