Esempio n. 1
0
def test_add_repos(_0, _1, _2, path_input, expected, monkeypatch):
    monkeypatch.setenv('XDG_CONFIG_HOME', '/config')
    with patch('builtins.open', mock_open()) as mock_file:
        utils.add_repos(path_input)
    mock_file.assert_called_with('/config/gita/repo_path', 'w')
    handle = mock_file()
    handle.write.assert_called_once_with(expected)
Esempio n. 2
0
def test_add_repos(_0, _1, path_input, expected, monkeypatch):
    monkeypatch.setenv('XDG_CONFIG_HOME', '/config')
    with patch('builtins.open', mock_open()) as mock_file:
        utils.add_repos({'repo': '/nos/repo'}, path_input)
    mock_file.assert_called_with('/config/gita/repo_path', 'a+')
    handle = mock_file()
    if type(expected) == str:
        handle.write.assert_called_once_with(expected)
    else:
        handle.write.assert_called_once()
        args, kwargs = handle.write.call_args
        assert args[0] in expected
        assert not kwargs
Esempio n. 3
0
def test_add_repos(_0, _1, path_input, expected, monkeypatch):
    monkeypatch.setenv("XDG_CONFIG_HOME", "/config")
    with patch("builtins.open", mock_open()) as mock_file:
        utils.add_repos({"repo": {"path": "/nos/repo"}}, path_input)
    mock_file.assert_called_with("/config/gita/repos.csv", "a+", newline="")
    handle = mock_file()
    if type(expected) == str:
        handle.write.assert_called_once_with(expected)
    else:
        # the write order is random
        assert handle.write.call_count == 2
        args, kwargs = handle.write.call_args
        assert args[0] in expected
        assert not kwargs
Esempio n. 4
0
def test_add_repos(_0, _1, _2, _3, path_input, expected):
    with patch('builtins.open', mock_open()) as mock_file:
        utils.add_repos(path_input)
    mock_file.assert_called_with('/root/.gita/repo_path', 'w')
    handle = mock_file()
    handle.write.assert_called_once_with(expected)