summaryrefslogtreecommitdiffstats
path: root/tests/test_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r--tests/test_utils.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 39430b0..3ff0cb1 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -11,7 +11,7 @@ from conftest import (
@pytest.mark.parametrize('repo_path, paths, expected', [
- ('/a/b/c/repo', ['/a/b'], ('b', 'c')),
+ ('/a/b/c/repo', ['/a/b'], (('b', 'c'), '/a')),
])
def test_generate_dir_hash(repo_path, paths, expected):
got = utils._generate_dir_hash(repo_path, paths)
@@ -20,11 +20,13 @@ def test_generate_dir_hash(repo_path, paths, expected):
@pytest.mark.parametrize('repos, paths, expected', [
({'r1': {'path': '/a/b//repo1'}, 'r2': {'path': '/a/b/repo2'}},
- ['/a/b'], {'b': ['r1', 'r2']}),
+ ['/a/b'], {'b': {'repos': ['r1', 'r2'], 'path': '/a/b'}}),
({'r1': {'path': '/a/b//repo1'}, 'r2': {'path': '/a/b/c/repo2'}},
- ['/a/b'], {'b': ['r1', 'r2'], 'b-c': ['r2']}),
+ ['/a/b'], {'b': {'repos': ['r1', 'r2'], 'path': '/a/b'},
+ 'b-c': {'repos': ['r2'], 'path': "/a/b/c"}}),
({'r1': {'path': '/a/b/c/repo1'}, 'r2': {'path': '/a/b/c/repo2'}},
- ['/a/b'], {'b-c': ['r1', 'r2'], 'b': ['r1', 'r2']}),
+ ['/a/b'], {'b-c': {'repos': ['r1', 'r2'], 'path': '/a/b/c'},
+ 'b': {'path': '/a/b', 'repos': ['r1', 'r2']}}),
])
def test_auto_group(repos, paths, expected):
got = utils.auto_group(repos, paths)
@@ -46,8 +48,8 @@ def test_describe(test_input, diff_return, expected, monkeypatch):
monkeypatch.setattr(info, 'get_commit_time', lambda *_: "xx")
monkeypatch.setattr(info, 'has_untracked', lambda *_: True)
monkeypatch.setattr('os.chdir', lambda x: None)
- print('expected: ', repr(expected))
- print('got: ', repr(next(utils.describe(*test_input))))
+
+ info.get_color_encoding.cache_clear() # avoid side effect
assert expected == next(utils.describe(*test_input))
@@ -83,7 +85,8 @@ def test_get_context(mock_config_dir):
@pytest.mark.parametrize('group_fname, expected', [
- (GROUP_FNAME, {'xx': ['a', 'b'], 'yy': ['a', 'c', 'd']}),
+ (GROUP_FNAME, {'xx': {'repos': ['a', 'b'], 'path': ''},
+ 'yy': {'repos': ['a', 'c', 'd'], 'path': ''}}),
])
@patch('gita.common.get_config_fname')
def test_get_groups(mock_group_fname, group_fname, expected):