示例#1
0
def test_two_matrices_are_classified(mocked_cli, mocked_keras,
                                     mocked_validator, mocked_np):
    Classifier.set_output_service(CLIOutputService(mocked_cli))
    mocked_validator.side_effect = [True, True]
    CLIOutputService(mocked_cli)
    matrix_path = "modules/test/unittest/shared/data/two_labeled_matrices.hdf5"
    mocked_np.side_effect = [[1, 1]]
    Classifier.start(matrix_path, "")
    mocked_cli.assert_has_calls([
        call.print("matrix: 1, predicted solver: Cg"),
        call.print("matrix: 2, predicted solver: Cg")
    ])
示例#2
0
def test_classify_throws_error_if_matrix_is_irregular(mocked_validator,
                                                      mocked_cli):
    Classifier.set_output_service(CLIOutputService(mocked_cli))
    mocked_validator.side_effect = [False]
    CLIOutputService(mocked_cli)
    Classifier.start(
        "modules/test/unittest/shared/data/one_labeled_matrix.hdf5", "network")
    mocked_cli.assert_has_calls(
        [call.print("IllegalArgumentException: The matrix is not regular")])
示例#3
0
def test_matrix_is_classified_with_cg_as_result(mocked_cli, mocked_keras,
                                                mocked_validator, mocked_np):
    Classifier.set_output_service(CLIOutputService(mocked_cli))
    mocked_validator.side_effect = [True]
    CLIOutputService(mocked_cli)
    matrix_path = "modules/test/unittest/shared/data/one_labeled_matrix.hdf5"
    mocked_np.side_effect = [[1]]
    Classifier.start(matrix_path, "")
    mocked_cli.assert_has_calls(
        [call.print("matrix: 1, predicted solver: Cg")])
def test_print_error(mocked_cli):
    error = IllegalArgumentException("Error")
    output_service = CLIOutputService(mocked_cli)
    output_service.print_error(error)
    mocked_cli.assert_has_calls(
        [call.print(error.get_type() + ": " + "Error")])
def test_print_line(mocked_cli):
    output_service = CLIOutputService(mocked_cli)
    output_service.print_line("Hallo")
    mocked_cli.assert_has_calls([call.print("Hallo")])