1
0
Fork 0

Adding upstream version 0.11.9.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-11 18:39:36 +01:00
parent 1b2b356ce0
commit 3ac0de4543
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
11 changed files with 528 additions and 157 deletions

View file

@ -4,17 +4,14 @@ from unittest.mock import patch, mock_open
from gita import utils, info
from conftest import (
PATH_FNAME, PATH_FNAME_EMPTY, PATH_FNAME_CLASH, GROUP_FNAME,
PATH_FNAME, PATH_FNAME_EMPTY, PATH_FNAME_CLASH, GROUP_FNAME, TEST_DIR,
)
@pytest.mark.parametrize('test_input, diff_return, expected', [
({
'abc': '/root/repo/'
}, True, 'abc \x1b[31mrepo *+_ \x1b[0m msg'),
({
'repo': '/root/repo2/'
}, False, 'repo \x1b[32mrepo _ \x1b[0m msg'),
([{'abc': '/root/repo/'}, False], True, 'abc \x1b[31mrepo *+_ \x1b[0m msg'),
([{'abc': '/root/repo/'}, True], True, 'abc repo *+_ msg'),
([{'repo': '/root/repo2/'}, False], False, 'repo \x1b[32mrepo _ \x1b[0m msg'),
])
def test_describe(test_input, diff_return, expected, monkeypatch):
monkeypatch.setattr(info, 'get_head', lambda x: 'repo')
@ -23,8 +20,8 @@ def test_describe(test_input, diff_return, expected, monkeypatch):
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))))
assert expected == next(utils.describe(test_input))
print('got: ', repr(next(utils.describe(*test_input))))
assert expected == next(utils.describe(*test_input))
@pytest.mark.parametrize('path_fname, expected', [
@ -41,17 +38,28 @@ def test_describe(test_input, diff_return, expected, monkeypatch):
}),
])
@patch('gita.utils.is_git', return_value=True)
@patch('gita.utils.get_config_fname')
@patch('gita.common.get_config_fname')
def test_get_repos(mock_path_fname, _, path_fname, expected):
mock_path_fname.return_value = path_fname
utils.get_repos.cache_clear()
assert utils.get_repos() == expected
@patch('gita.common.get_config_dir')
def test_get_context(mock_config_dir):
mock_config_dir.return_value = TEST_DIR
utils.get_context.cache_clear()
assert utils.get_context() == TEST_DIR / 'xx.context'
mock_config_dir.return_value = '/'
utils.get_context.cache_clear()
assert utils.get_context() == None
@pytest.mark.parametrize('group_fname, expected', [
(GROUP_FNAME, {'xx': ['a', 'b'], 'yy': ['a', 'c', 'd']}),
])
@patch('gita.utils.get_config_fname')
@patch('gita.common.get_config_fname')
def test_get_groups(mock_group_fname, group_fname, expected):
mock_group_fname.return_value = group_fname
utils.get_groups.cache_clear()