mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 15:28:34 +01:00
Gc: Move old unittest gc tests to pytest
This commit is contained in:
committed by
David de la Iglesia Castro
parent
d47e3c40b8
commit
9c59689aa7
@@ -6,7 +6,6 @@ from dvc.commands.add import CmdAdd
|
||||
from dvc.commands.checkout import CmdCheckout
|
||||
from dvc.commands.config import CmdConfig
|
||||
from dvc.commands.data_sync import CmdDataPull, CmdDataPush
|
||||
from dvc.commands.gc import CmdGC
|
||||
from dvc.commands.init import CmdInit
|
||||
from dvc.commands.remove import CmdRemove
|
||||
from dvc.commands.repro import CmdRepro
|
||||
@@ -144,27 +143,6 @@ class TestAdd(TestDvc):
|
||||
cmd.repo.close()
|
||||
|
||||
|
||||
class TestGC(TestDvc):
|
||||
def test(self):
|
||||
args = parse_args(["gc"])
|
||||
cmd = args.func(args)
|
||||
self.assertIsInstance(cmd, CmdGC)
|
||||
|
||||
cmd.repo.close()
|
||||
|
||||
|
||||
class TestGCMultipleDvcRepos(TestDvc):
|
||||
def test(self):
|
||||
args = parse_args(["gc", "-p", "/tmp/asdf", "/tmp/xyz"])
|
||||
|
||||
cmd = args.func(args)
|
||||
self.assertIsInstance(cmd, CmdGC)
|
||||
|
||||
self.assertEqual(args.repos, ["/tmp/asdf", "/tmp/xyz"])
|
||||
|
||||
cmd.repo.close()
|
||||
|
||||
|
||||
class TestConfig(TestDvc):
|
||||
def test(self):
|
||||
name = "section.option"
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import pytest
|
||||
|
||||
from dvc.cli import parse_args
|
||||
from dvc.commands.gc import CmdGC
|
||||
from dvc.exceptions import InvalidArgumentError
|
||||
|
||||
|
||||
def test_(dvc, scm, mocker):
|
||||
cli_args = parse_args(
|
||||
[
|
||||
"gc",
|
||||
"--workspace",
|
||||
"--all-tags",
|
||||
"--all-branches",
|
||||
"--all-commits",
|
||||
"--all-experiments",
|
||||
"--cloud",
|
||||
"--remote",
|
||||
"origin",
|
||||
"--force",
|
||||
"--jobs",
|
||||
"3",
|
||||
"--projects",
|
||||
"project1",
|
||||
"project2",
|
||||
]
|
||||
)
|
||||
assert cli_args.func == CmdGC
|
||||
|
||||
cmd = cli_args.func(cli_args)
|
||||
m = mocker.patch("dvc.repo.Repo.gc", return_value={})
|
||||
|
||||
assert cmd.run() == 0
|
||||
|
||||
m.assert_called_once_with(
|
||||
workspace=True,
|
||||
all_tags=True,
|
||||
all_branches=True,
|
||||
all_commits=True,
|
||||
all_experiments=True,
|
||||
cloud=True,
|
||||
remote="origin",
|
||||
force=True,
|
||||
jobs=3,
|
||||
repos=["project1", "project2"],
|
||||
)
|
||||
|
||||
cli_args = parse_args(["gc"])
|
||||
cmd = cli_args.func(cli_args)
|
||||
with pytest.raises(InvalidArgumentError):
|
||||
cmd.run()
|
||||
Reference in New Issue
Block a user