Beispiel #1
0
def test_test_tools_records_retry_exception():
    interactor = MockGalaxyInteractor()
    f = NamedTemporaryFile()
    results = Results("my suite", f.name)
    test_references = [
        TestReference("bad", "0.1.0", 0),
    ]
    with mock.patch(VT_PATH) as mock_verify:
        assert_results_not_written(results)

        count = 0

        def side_effect(*args, **kwd):
            nonlocal count
            raise_exception = count == 0
            count += 1
            if raise_exception:
                raise Exception("Cow")

        mock_verify.side_effect = side_effect
        run(
            interactor,
            test_references,
            results,
            retries=1,
        )
        calls = mock_verify.call_args_list
        assert len(calls) == 2
        assert len(results.test_exceptions) == 0
        assert_results_written(results)
Beispiel #2
0
def test_test_tools_no_history_cleanup():
    interactor = MockGalaxyInteractor()
    f = NamedTemporaryFile()
    results = Results("my suite", f.name)
    test_references = [
        TestReference("cat", "0.1.0", 0),
    ]
    with mock.patch(VT_PATH) as mock_verify:
        assert_results_not_written(results)
        run(
            interactor,
            test_references,
            results,
            no_history_cleanup=True,
        )
        calls = mock_verify.call_args_list
        assert len(calls) == 1
        assert len(results.test_exceptions) == 0
        assert_results_written(results)
        assert interactor.history_created
        assert not interactor.history_deleted
Beispiel #3
0
def test_test_tools_no_history_reuse():
    interactor = MockGalaxyInteractor()
    f = NamedTemporaryFile()
    results = Results("existing suite", f.name)
    test_references = [
        TestReference("cat", "0.1.0", 0),
    ]
    with mock.patch(VT_PATH) as mock_verify:
        assert_results_not_written(results)
        run(
            interactor,
            test_references,
            results,
            no_history_reuse=True,
        )
        calls = mock_verify.call_args_list
        assert len(calls) == 1
        assert len(results.test_exceptions) == 0
        assert_results_written(results)
        assert interactor.history_id == NEW_HISTORY_ID
        assert interactor.history_name == EXISTING_HISTORY_NAME
        assert interactor.history_created
        assert interactor.history_deleted
Beispiel #4
0
def test_results():
    f = NamedTemporaryFile()
    results = Results("my suite", f.name)
    results.register_result({
        "id": "foo",
        "has_data": True,
        "data": {
            "status": "success"
        }
    })
    results.write()
    message = results.info_message()

    with open(f.name) as f:
        report_obj = json.load(f)
    assert "tests" in report_obj
    assert len(report_obj["tests"]) == 1
    assert report_obj["results"]["total"] == 1, report_obj["results"]
    assert report_obj["results"]["errors"] == 0
    assert report_obj["results"]["skips"] == 0

    assert "Passed tool tests (1)" in message
    assert "Skipped tool tests (0)" in message

    results.register_result({
        "id": "bar",
        "has_data": True,
        "data": {
            "status": "skip"
        }
    })
    results.write()
    message = results.info_message()

    with open(f.name) as f:
        report_obj = json.load(f)
    assert len(report_obj["tests"]) == 2
    assert report_obj["results"]["skips"] == 1
    assert "Passed tool tests (1)" in message
    assert "Skipped tool tests (1)" in message