Example #1
0
 def test_setup_args_for_search_should_make_call_but_return_exit(
         self, process_mock: mock.Mock, print_mock: mock.Mock,
         load_mock: mock.Mock, executor: mock.Mock) -> None:
     with mock.patch('argparse.ArgumentParser.parse_args',
                     return_value=argparse.Namespace(
                         json=True,
                         sql=False,
                         all=True,
                         startswith=True,
                         execute=True,
                         save_dir='save_dir',
                         history_file_path='hist',
                         max=1,
                         query='grep')):
         with mock.patch('remember.command_store_lib.open',
                         mock.mock_open()) as write_mock:
             interactor_mock = Mock()
             interactor_mock.run.return_value = ''
             executor.return_value = interactor_mock
             remember_main.main()
             print_mock.assert_not_called()
             load_mock.assert_called_once()
             process_mock.assert_called_once()
             executor.assert_called_once()
             write_mock.assert_called_once()
Example #2
0
 def test_run_remember_command_whenCalled_shouldputArgsInRightSpots(
         self, method_mock: Mock) -> None:
     with mock.patch('argparse.ArgumentParser.parse_args',
                     return_value=argparse.Namespace(
                         json=True,
                         sql=False,
                         all=True,
                         startswith=True,
                         execute=True,
                         save_dir='save_dir',
                         history_file_path='hist',
                         max=1,
                         query=['grep'])):
         remember_main.main()
         method_mock.assert_called_once_with("save_dir", "hist", ['grep'],
                                             True, True, True, 1)
Example #3
0
 def test_setup_args_for_search_should_make_appropriate_calls_into_command_store_lib(
         self, process_mock: mock.Mock, print_mock: mock.Mock,
         load_mock: mock.Mock) -> None:
     with mock.patch('argparse.ArgumentParser.parse_args',
                     return_value=argparse.Namespace(
                         json=True,
                         sql=False,
                         all=True,
                         startswith=True,
                         execute=False,
                         save_dir='save_dir',
                         history_file_path='hist',
                         max=1000,
                         query='grep')):
         with mock.patch('remember.command_store_lib.open',
                         mock.mock_open()) as write_mock:
             remember_main.main()
             print_mock.assert_called_once()
             load_mock.assert_called_once()
             process_mock.assert_called_once()
             write_mock.assert_called_once()
Example #4
0
 def test_setup_args_for_search_but_missing_save_dir_should_return_error_string(
         self) -> None:
     with mock.patch('argparse.ArgumentParser.parse_args',
                     return_value=argparse.Namespace(
                         json=True,
                         sql=False,
                         all=True,
                         startswith=True,
                         execute=False,
                         save_dir=None,
                         history_file_path='hist',
                         max=1000,
                         query='query')):
         result = remember_main.main()
         assert result
         assert result.startswith("To many or too few args")
Example #5
0
 def test_setup_args_for_search_but_missing_history_file_path_should_return_error_string(
         self, _: mock.Mock) -> None:
     result = remember_main.main()
     assert result
     assert result.startswith("To many or too few args")