def test_classifier_is_called_with_correct_arguments(mocked_input, mocked_start): user_input = ["classify --network network -p path", "quit"] expected_call = [call(path="path", network="network")] mocked_input.side_effect = user_input con = Controller() con.start_interaction() mocked_start.assert_has_calls(expected_call)
def test_label_is_called_with_correct_arguments(mocked_input, mocked_start): user_input = ["label -name name --saving-path saving-path -p path", "quit"] expected_call = [ call(path="path", saving_path="saving-path", saving_name="name") ] mocked_input.side_effect = user_input con = Controller() con.start_interaction() mocked_start.assert_has_calls(expected_call)
def test_invalid_input_calls_print_error(mocked_input, mocked_print_error): user_input = [ "labeler -n name", "quit", ] mocked_input.side_effect = user_input con = Controller() con.start_interaction() mocked_print_error.assert_called_once()
def test_train_module_is_called_with_correct_arguments(mocked_input, mocked_train): user_input = ["train -n name -p path -s saving-path -t 0.8", "quit"] expected_call = [ call(name="name", matrices_path="path", neural_network_path=None, saving_path="saving-path", training_test_split=0.8) ] mocked_input.side_effect = user_input con = Controller() con.start_interaction() mocked_train.assert_has_calls(expected_call)
def test_help_flag_print(mocked_input, mocked_print): user_input = [ "label -h", "quit", ] label_command = LabelCommand() help_tuple = label_command.help_arguments call_list = [call(help_text) for help_text in help_tuple] expected = [call("These are the possible Tags for the label-command:") ] + call_list + [call("Finished")] mocked_input.side_effect = user_input con = Controller() con.start_interaction() mocked_print.assert_has_calls(expected) mocked_print.assert_called()
def test_wrong_float_format_prints_error_message(mocked_input, mocked_print): user_input = ["train --train 0,72 -n name -p path", "quit"] expected_calls = [ call( IllegalArgumentException("").get_type() + ": 0,72 is not a float"), call("Finished") ] mocked_input.side_effect = user_input Controller().start_interaction() mocked_print.assert_has_calls(expected_calls)
def test_invalid_config_file_prints_error_message(mocked_input, mocked_json, mocked_print): expected_calls = [ call("InvalidConfigException: config file could not be loaded"), call("Finished") ] mocked_input.side_effect = ["quit"] mocked_json.side_effect = Exception() Controller().start_interaction() mocked_print.assert_has_calls(expected_calls)
def test_wrong_integer_format_prints_error_message(mocked_input, mocked_print): user_input = ["collect -n name -a 50.000", "quit"] expected_calls = [ call( IllegalArgumentException("").get_type() + ": 50.000 is not a integer"), call("Finished") ] mocked_input.side_effect = user_input Controller().start_interaction() mocked_print.assert_has_calls(expected_calls)
def test_collect_with_wrong_os_prints_exception_message( mocked_input, mocked_print): user_input = ["collect -n name", "quit"] expected_calls = [ call( InvalidOSException("").get_type() + ": Collecting only works on linux with SSGet installed"), call("Finished") ] mocked_input.side_effect = user_input Controller().start_interaction() mocked_print.assert_has_calls(expected_calls)
def test_controller_with_two_iterations(mocked_input, mocked_parser, mocked_label, mocked_quit): user_input = [ "label -n name", "quit", ] parser_return = [ LabelCommand(), QuitCommand(), ] expected = [ call("label -n name"), call("quit"), ] mocked_input.side_effect = user_input mocked_parser.side_effect = parser_return con = Controller() con.start_interaction() mocked_parser.assert_has_calls(expected) mocked_label.assert_called_once() mocked_quit.assert_not_called()
def test_input_help_prints_help_info(mocked_cli, mocked_input): user_input = [ "help", "quit", ] expected = [call("These are the possible interactions:")] expected += [call(info) for info in CommandParser.get_valid_commands()] expected += [ call("for more information type in the command and -h or --help."), call("Finished") ] mocked_input.side_effect = user_input Controller().start_interaction() mocked_cli.print_line.asser_has_calls(expected)
from modules.controller.controller import Controller ## Run this script to start the command line interaction # # Example interaction: # collect -a 5 -n example_matrices -p modules/shared/data/ # quit Controller().start_interaction()
def test_label_command_call(mocked_input, mocked_label): user_input = ["label -n", "quit"] mocked_input.side_effect = user_input con = Controller() con.start_interaction() mocked_label.assert_called_once()
def test_classify_command_call(mocked_input, mocked_classifier_command): user_input = ["classify -p path -n network", "quit"] mocked_input.side_effect = user_input con = Controller() con.start_interaction() mocked_classifier_command.assert_called_once()
def test_collect_command_call(mocked_input, mocked_collect): user_input = ["collect -a", "quit"] mocked_input.side_effect = user_input con = Controller() con.start_interaction() mocked_collect.assert_called_once()
def test_train_command_call(mocked_input, mocked_train): user_input = ["train -n", "quit"] mocked_input.side_effect = user_input con = Controller() con.start_interaction() mocked_train.assert_called_once()
def test_ssget_update_command_calls_new_search(mocked_input, mocked_search): user_input = ["ssget -u", "quit"] mocked_input.side_effect = user_input Controller().start_interaction() mocked_search.assert_called()