コード例 #1
0
 def test_delete_sql_whenExists_shouldDeleteFromStore(self):
     file_name = os.path.join(TEST_FILES_PATH, "test_input.txt")
     self.assertTrue(os.path.isfile(file_name))
     store = command_store_lib.SqlCommandStore(':memory:')
     command_store_lib.read_history_file(store, file_name, "doesntmatter",
                                         None, False)
     self.assertTrue(store.has_command_by_name("vim somefile.txt"))
     self.assertIsNotNone(store.delete_command('vim somefile.txt'))
     self.assertFalse(store.has_command_by_name("vim somefile.txt"))
コード例 #2
0
 def test_search_commands(self):
     file_name = os.path.join(TEST_FILES_PATH, "test_input.txt")
     store = command_store_lib.CommandStore()
     command_store_lib.read_history_file(store, file_name, "doesntmatter",
                                         None, False)
     matches = store.search_commands(["add"])
     self.assertIsNotNone(matches)
     matches = store.search_commands(["add"], True)
     self.assertTrue(len(matches) == 0)
     matches = store.search_commands(["subl"], True)
     self.assertTrue(len(matches) == 1)
コード例 #3
0
 def test_readFile(self):
     file_name = os.path.join(TEST_FILES_PATH, "test_input.txt")
     store = command_store_lib.CommandStore()
     command_store_lib.read_history_file(store, file_name, "doesntmatter",
                                         None, False)
     self.assertTrue(store.has_command_by_name("vim somefile.txt"))
     self.assertTrue(store.has_command_by_name("rm somefile.txt"))
     self.assertTrue(store.has_command_by_name("whereis script"))
     self.assertTrue(store.has_command_by_name("vim /usr/bin/script"))
     self.assertFalse(store.has_command_by_name("vim somefil"))
     self.assertEqual(
         2,
         store.get_command_by_name("rm somefile.txt").get_count_seen())
コード例 #4
0
def generate_store_from_args(history_file_path, save_directory, use_json,
                             use_sql):
    store_file_path = com_lib.get_file_path(save_directory, use_json, use_sql)
    commands_file_path = os.path.join(save_directory, com_lib.FILE_STORE_NAME)
    ignore_rule_file = os.path.join(save_directory, IGNORE_RULE_FILE_NAME)
    if not os.path.isfile(ignore_rule_file):
        ignore_rule_file = None
    else:
        print('Using ignore rules from ' + ignore_rule_file)
    store_type = com_lib.get_store_type(use_json, use_sql)
    store = com_lib.load_command_store(store_file_path, store_type)
    com_lib.read_history_file(store, history_file_path, commands_file_path,
                              ignore_rule_file)
    print('Reading ' + history_file_path)
    if com_lib.save_command_store(store, store_file_path, use_json):
        print('Writing file out to ' + store_file_path)
コード例 #5
0
 def test_ignoreRule_whenFileDoestExist_shouldNotCrash(self):
     file_name = os.path.join(TEST_FILES_PATH, "test_input.txt")
     store = command_store_lib.CommandStore()
     command_store_lib.read_history_file(store, file_name, "doesntmatter",
                                         "test_files/fileNotthere.txt",
                                         False)