Esempio n. 1
0
def test_rename_overwrite(getch, y_or_n, cleandir, fake_db, funk_dict):
    """Test that rename overwrites existing function names properly."""
    getch.side_effect = lambda x: y_or_n
    fnames = [name for name in funk_dict]
    OLD, NEW = fnames[0], fnames[1]
    cmd = commands.Rename([OLD, NEW])
    cmd()

    loaded_funks = load_funks()
    if y_or_n == "y":
        cmd_string = funk_dict[OLD]
    else:
        cmd_string = funk_dict[NEW]

    assert loaded_funks[NEW] == cmd_string
Esempio n. 2
0
def test_rename_fail(cleandir, fake_db):
    """Test that rename command fails when OLD funk does not exist."""
    cmd = commands.Rename(['bad_funk', 'NEW'])
    with pytest.raises(errors.FunkNotDefinedError):
        cmd()
Esempio n. 3
0
def rename_cmd(args):
    """Builds and returns 'rename' command"""
    cmd = commands.Rename([args.args[0], 'NEW'])
    return cmd