summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-25 12:57:06 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-25 12:57:15 +0000
commit85cebf7af1712dfc8214564045d68317656cf03b (patch)
treeabd3aa80bb35025159939826e1ee75c430fa7522 /tests
parentReleasing debian version 0.11.9-1. (diff)
downloadgita-85cebf7af1712dfc8214564045d68317656cf03b.tar.xz
gita-85cebf7af1712dfc8214564045d68317656cf03b.zip
Merging upstream version 0.12.9.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_main.py39
1 files changed, 38 insertions, 1 deletions
diff --git a/tests/test_main.py b/tests/test_main.py
index 1c30eec..ad501f7 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -43,7 +43,7 @@ class TestLsLl:
assert info.Color.end in out
# no color on branch name
- __main__.main(['ll', '-n'])
+ __main__.main(['ll', '-C'])
out, err = capfd.readouterr()
assert err == ''
assert 'gita' in out
@@ -95,6 +95,16 @@ class TestLsLl:
assert out == expected
+@patch('subprocess.run')
+@patch('gita.utils.get_repos', return_value={'repo1': '/a/', 'repo2': '/b/'})
+def test_freeze(_, mock_run, capfd):
+ __main__.main(['freeze'])
+ assert mock_run.call_count == 2
+ out, err = capfd.readouterr()
+ assert err == ''
+ assert out == ',repo1,/a/\n,repo2,/b/\n'
+
+
@patch('os.path.isfile', return_value=True)
@patch('gita.common.get_config_fname', return_value='some path')
@patch('gita.utils.get_repos', return_value={'repo1': '/a/', 'repo2': '/b/'})
@@ -149,6 +159,20 @@ def test_superman(mock_run, _, input):
mock_run.assert_called_once_with(expected_cmds, cwd='path7')
+@pytest.mark.parametrize('input', [
+ 'diff --name-only --staged',
+ "commit -am 'lala kaka'",
+])
+@patch('gita.utils.get_repos', return_value={'repo7': 'path7'})
+@patch('subprocess.run')
+def test_shell(mock_run, _, input):
+ mock_run.reset_mock()
+ args = ['shell', 'repo7'] + shlex.split(input)
+ __main__.main(args)
+ expected_cmds = shlex.split(input)
+ mock_run.assert_called_once_with(expected_cmds, cwd='path7', check=True, stderr=-2, stdout=-1)
+
+
class TestContext:
@patch('gita.utils.get_context', return_value=None)
@@ -273,6 +297,19 @@ class TestGroupCmd:
mock_write.assert_called_once_with(
{'xx': ['a', 'b', 'c'], 'yy': ['a', 'c', 'd']}, 'w')
+ @patch('gita.utils.get_repos', return_value={'a': '', 'b': '', 'c': '', 'd': ''})
+ @patch('gita.common.get_config_fname', return_value=GROUP_FNAME)
+ @patch('gita.utils.write_to_groups_file')
+ def testRmRepo(self, mock_write, *_):
+ args = argparse.Namespace()
+ args.from_group = ['a', 'c']
+ args.group_cmd = 'rmrepo'
+ args.gname = 'xx'
+ utils.get_groups.cache_clear()
+ __main__.f_group(args)
+ mock_write.assert_called_once_with(
+ {'xx': ['b'], 'yy': ['a', 'c', 'd']}, 'w')
+
@patch('gita.utils.is_git', return_value=True)
@patch('gita.common.get_config_fname', return_value=PATH_FNAME)