def test_add(sp, tempfile, setup_edit_patches, cleandir, add_cmd, funk_dict): """Tests add command.""" funk_cmd_string = funk_dict[add_cmd.funk] setup_edit_patches(sp, tempfile, funk_cmd_string) add_cmd() loaded_funks = shared.load_funks() assert loaded_funks == {add_cmd.funk: funk_cmd_string} assert len(loaded_funks) == 1
def test_edit(sp, tempfile, setup_edit_patches, cleandir, fake_db, edit_cmd): """Tests edit command.""" edited_cmd_string = 'TEST COMMAND STRING' setup_edit_patches(sp, tempfile, edited_cmd_string) edit_cmd() loaded_funks = shared.load_funks() assert loaded_funks[edit_cmd.funk] == '{} "$@"'.format(edited_cmd_string)
def test_edit_format(sp, tempfile, setup_edit_patches, cleandir, fake_db, funk_dict): """Tests that the edit command reformats command strings when needed.""" edited_cmd_string = 'EDITED CMD STRING' setup_edit_patches(sp, tempfile, edited_cmd_string) some_funk = list(funk_dict.keys())[0] cmd = commands.Edit([some_funk]) cmd() loaded_funks = shared.load_funks() assert loaded_funks[some_funk] == '{} "$@"'.format(edited_cmd_string)
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 = shared.load_funks() if y_or_n == "y": cmd_string = funk_dict[OLD] else: cmd_string = funk_dict[NEW] assert loaded_funks[NEW] == cmd_string
def test_remove(cleandir, fake_db, remove_cmd): """Tests remove command.""" remove_cmd() loaded_funks = shared.load_funks() assert remove_cmd.funk not in loaded_funks
def test_rename(cleandir, fake_db, rename_cmd, funk_dict): """Test rename command.""" old_cmd_string = funk_dict[rename_cmd.funk] rename_cmd() loaded_funks = shared.load_funks() assert loaded_funks[rename_cmd.args[0]] == old_cmd_string