Esempio n. 1
0
 def testAdd(self, mock_write, *_):
     args = argparse.Namespace()
     args.to_group =  ['a', 'c']
     args.group_cmd = 'add'
     args.gname = 'zz'
     utils.get_groups.cache_clear()
     __main__.f_group(args)
     mock_write.assert_called_once_with({'zz': ['a', 'c']}, 'a+')
Esempio n. 2
0
 def testRenameError(self, *_):
     args = argparse.Namespace()
     args.gname = 'xx'
     args.new_name = 'yy'
     args.group_cmd = 'rename'
     utils.get_groups.cache_clear()
     with pytest.raises(SystemExit, match='yy already exists.'):
         __main__.f_group(args)
Esempio n. 3
0
 def testAdd(self, mock_write, _, __, monkeypatch):
     args = argparse.Namespace()
     args.to_group = ['a', 'c']
     args.group_cmd = 'add'
     utils.get_groups.cache_clear()
     monkeypatch.setattr('builtins.input', lambda _: 'zz')
     __main__.f_group(args)
     mock_write.assert_called_once_with({'zz': ['a', 'c']}, 'a+')
Esempio n. 4
0
def test_group_display(_, capfd):
    args = argparse.Namespace()
    args.to_group = None
    utils.get_groups.cache_clear()
    __main__.f_group(args)
    out, err = capfd.readouterr()
    assert err == ''
    assert 'xx: a, b\nyy: a, c, d\n' == out
Esempio n. 5
0
 def test_ls(self, _, capfd):
     args = argparse.Namespace()
     args.to_group = None
     args.group_cmd = "ls"
     utils.get_groups.cache_clear()
     __main__.f_group(args)
     out, err = capfd.readouterr()
     assert err == ""
     assert "xx yy\n" == out
Esempio n. 6
0
 def testRmRepo(self, mock_write, *_):
     args = argparse.Namespace()
     args.from_group = ['a', 'c']
     args.group_cmd = 'rmrepo'
     args.gname = 'xx'
     utils.get_groups.cache_clear()
     __main__.f_group(args)
     mock_write.assert_called_once_with(
             {'xx': ['b'], 'yy': ['a', 'c', 'd']}, 'w')
Esempio n. 7
0
 def testAddToExisting(self, mock_write, *_):
     args = argparse.Namespace()
     args.to_group =  ['a', 'c']
     args.group_cmd = 'add'
     args.gname = 'xx'
     utils.get_groups.cache_clear()
     __main__.f_group(args)
     mock_write.assert_called_once_with(
             {'xx': ['a', 'b', 'c'], 'yy': ['a', 'c', 'd']}, 'w')
Esempio n. 8
0
 def testRename(self, mock_write, _):
     args = argparse.Namespace()
     args.gname = 'xx'
     args.new_name = 'zz'
     args.group_cmd = 'rename'
     utils.get_groups.cache_clear()
     __main__.f_group(args)
     expected = {'yy': ['a', 'c', 'd'], 'zz': ['a', 'b']}
     mock_write.assert_called_once_with(expected, 'w')
Esempio n. 9
0
 def testLl(self, _, capfd):
     args = argparse.Namespace()
     args.to_group = None
     args.group_cmd = None
     utils.get_groups.cache_clear()
     __main__.f_group(args)
     out, err = capfd.readouterr()
     assert err == ''
     assert 'xx: a b\nyy: a c d\n' == out
Esempio n. 10
0
 def test_add(self, mock_write, *_):
     args = argparse.Namespace()
     args.to_group = ["a", "c"]
     args.group_cmd = "add"
     args.gname = "zz"
     utils.get_groups.cache_clear()
     __main__.f_group(args)
     mock_write.assert_called_once_with(
         {"zz": {"repos": ["a", "c"], "path": ""}}, "a+"
     )
Esempio n. 11
0
 def test_ll_with_group(self, _, __, capfd):
     args = argparse.Namespace()
     args.to_group = None
     args.group_cmd = None
     args.to_show = "yy"
     utils.get_groups.cache_clear()
     __main__.f_group(args)
     out, err = capfd.readouterr()
     assert err == ""
     assert "a c d\n" == out
Esempio n. 12
0
 def test_rename(self, mock_write, *_):
     args = argparse.Namespace()
     args.gname = "xx"
     args.new_name = "zz"
     args.group_cmd = "rename"
     utils.get_groups.cache_clear()
     __main__.f_group(args)
     expected = {
         "yy": {"repos": ["a", "c", "d"], "path": ""},
         "zz": {"repos": ["a", "b"], "path": ""},
     }
     mock_write.assert_called_once_with(expected, "w")
Esempio n. 13
0
 def test_ll(self, _, __, capfd):
     args = argparse.Namespace()
     args.to_group = None
     args.group_cmd = None
     args.to_show = None
     utils.get_groups.cache_clear()
     __main__.f_group(args)
     out, err = capfd.readouterr()
     assert err == ""
     assert (
         out
         == "\x1b[4mxx\x1b[0m: \n  - a\n  - b\n\x1b[4myy\x1b[0m: \n  - a\n  - c\n  - d\n"
     )
Esempio n. 14
0
 def test_rm_repo(self, mock_write, *_):
     args = argparse.Namespace()
     args.to_rm = ["a", "c"]
     args.group_cmd = "rmrepo"
     args.gname = "xx"
     utils.get_groups.cache_clear()
     __main__.f_group(args)
     mock_write.assert_called_once_with(
         {
             "xx": {"repos": ["b"], "path": ""},
             "yy": {"repos": ["a", "c", "d"], "path": ""},
         },
         "w",
     )