Пример #1
0
    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']
Пример #2
0
 def testAdd(self, mock_path_fname, tmp_path, input, expected):
     def side_effect(input, _=None):
         return tmp_path / f'{input}.txt'
     mock_path_fname.side_effect = side_effect
     utils.get_repos.cache_clear()
     __main__.main(input)
     utils.get_repos.cache_clear()
     got = utils.get_repos()
     assert len(got) == 1
     assert got['gita']['type'] == expected
Пример #3
0
    def testLl(self, mock_path_fname, capfd, tmp_path):
        """
        functional test
        """

        # avoid modifying the local configuration
        def side_effect(input):
            return tmp_path / f'{input}.txt'

        #mock_path_fname.return_value = tmp_path / 'path_config.txt'
        mock_path_fname.side_effect = side_effect
        __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
        assert info.Color.end in out

        # no color on branch name
        __main__.main(['ll', '-C'])
        out, err = capfd.readouterr()
        assert err == ''
        assert 'gita' in out
        assert info.Color.end not in out

        __main__.main(['ls', 'gita'])
        out, err = capfd.readouterr()
        assert err == ''
        assert out.strip() == utils.get_repos()['gita']
Пример #4
0
    def test_ll(self, mock_path_fname, capfd, tmp_path):
        """
        functional test
        """
        # avoid modifying the local configuration
        def side_effect(input, _=None):
            return tmp_path / f"{input}.txt"

        mock_path_fname.side_effect = side_effect
        utils.get_repos.cache_clear()
        __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
        assert info.Color.end in out

        # no color on branch name
        __main__.main(["ll", "-C"])
        out, err = capfd.readouterr()
        assert err == ""
        assert "gita" in out
        assert info.Color.end not in out

        __main__.main(["ls", "gita"])
        out, err = capfd.readouterr()
        assert err == ""
        assert out.strip() == utils.get_repos()["gita"]["path"]
Пример #5
0
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
Пример #6
0
 def testEmptyPath(self, *_):
     utils.get_repos.cache_clear()
     repos = utils.get_repos()
     assert repos == {}
Пример #7
0
 def test(self, *_):
     utils.get_repos.cache_clear()
     repos = utils.get_repos()
     assert repos == {'repo1': '/a/bcd/repo1', 'repo2': '/e/fgh/repo2'}