def test_search_commands_whenTermIsDifferentCase_shouldNotReturn(
         self) -> None:
     store = SqlCommandStore(':memory:')
     store.add_command(Command('Add'))
     matches = store.search_commands(["add"])
     self.assertEqual(0, len(matches))
     matches = store.search_commands(["Add"])
     self.assertEqual(1, len(matches))
 def test_search_commands_with_sqlstore(self) -> None:
     file_name = os.path.join(TEST_FILES_PATH, "test_input.txt")
     store = SqlCommandStore(':memory:')
     history_processor = command_store_lib.HistoryProcessor(store, file_name, '', 1)
     history_processor.process_history_file()
     matches = store.search_commands(["add"], search_info=True)
     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)
 def test_search_commands_whenHasContext_shouldCorrectlyAddContext(
         self) -> None:
     store = SqlCommandStore(':memory:')
     store.add_command(
         Command(command_str='Add', directory_context='directory/path'))
     matches = store.search_commands(["Add"])
     self.assertEqual(1, len(matches))
 def test_readHistoryFile_whenFileRead_shouldFinishWithWriteEnd(self) -> None:
     file_name = os.path.join(TEST_FILES_PATH, "test_input.txt")
     with open(file_name, 'rb') as hist_file:
         hist_file_content = hist_file.read()
     store = SqlCommandStore(':memory:')
     history_processor = command_store_lib.HistoryProcessor(store, file_name, '', 1)
     with patch('remember.command_store_lib.open', mock_open(read_data=hist_file_content)) as m:
         history_processor.process_history_file()
         history_processor.update_history_file()
     handle = m()
     handle.write.assert_called_with(f'{command_store_lib.PROCESSED_TO_TAG}\n')
     matches = store.search_commands(["add"], search_info=True)
     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)
    def test_search_commands_sorted(self) -> None:
        command_store = SqlCommandStore(':memory:')
        self.assertEqual(0, command_store.get_num_commands())
        command_str = "some command string"
        command = Command(command_str, 10.0, 1)
        command_store.add_command(command)
        command_str2 = "somelater command string"
        command2 = Command(command_str2, 20.0, 1)
        command_store.add_command(command2)

        result = command_store.search_commands(["some"],
                                               starts_with=False,
                                               sort=True)
        self.assertEqual(result[0].get_unique_command_id(),
                         command2.get_unique_command_id())
        self.assertEqual(result[1].get_unique_command_id(),
                         command.get_unique_command_id())