Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_rename(mock_rename, _, __):
utils.get_repos.cache_clear()
args = ['rename', 'repo1', 'abc']
__main__.main(args)
mock_rename.assert_called_once_with(
{'repo1': '/a/bcd/repo1', 'repo2': '/e/fgh/repo2',
'xxx': '/a/b/c/repo3'},
'repo1', 'abc')
def testLl(self, mock_path_fname, capfd, tmp_path):
""" functional test """
# avoid modifying the local configuration
mock_path_fname.return_value = tmp_path / 'path_config.txt'
__main__.main(['add', '.'])
out, err = capfd.readouterr()
assert err == ''
assert 'Found 1 new repo(s).\n' == out
# in production this is not needed
utils.get_repos.cache_clear()
__main__.main(['ls'])
out, err = capfd.readouterr()
assert err == ''
assert 'gita\n' == out
__main__.main(['ll'])
out, err = capfd.readouterr()
assert err == ''
assert 'gita' in out
__main__.main(['ls', 'gita'])
out, err = capfd.readouterr()
assert err == ''
assert out.strip() == utils.get_repos()['gita']
def test_get_repos(mock_path_fname, _, path_fname, expected):
mock_path_fname.return_value = path_fname
utils.get_repos.cache_clear()
repos = utils.get_repos()
assert repos == expected
def testWithPathFiles(self, mock_path_fname, _0, _1, _2, _3, path_fname,
expected, capfd):
mock_path_fname.return_value = path_fname
utils.get_repos.cache_clear()
__main__.main(['ll'])
out, err = capfd.readouterr()
print(out)
assert err == ''
assert out == expected