示例#1
0
def test_run_report_and_rerun(bson_library, environ):
    flask_app = create_app()
    with flask_app.app_context() as c:
        serialiser = get_serializer()
        overrides = {"n_points": 5}
        report_name = "fake/report"
        report_title = "my report title"
        mailto = "*****@*****.**"
        job_id = run_report(report_name, report_title, mailto, overrides, generate_pdf_output=False, prepare_only=True)
        _check_report_output(
            job_id,
            serialiser,
            overrides=overrides,
            report_name=report_name,
            report_title=report_title,
            mailto=mailto,
            generate_pdf_output=False,
        )

        new_job_id = _rerun_report(job_id, prepare_only=True)
        _check_report_output(
            new_job_id,
            serialiser,
            overrides=overrides,
            report_name=report_name,
            report_title="Rerun of " + report_title,
            mailto=mailto,
            generate_pdf_output=False,
        )
        assert new_job_id == serialiser.get_latest_job_id_for_name_and_params(report_name, overrides)
        assert not {job_id, new_job_id} - set(serialiser.get_all_job_ids_for_name_and_params(report_name, overrides))
        assert new_job_id == serialiser.get_latest_successful_job_id_for_name_and_params(report_name, overrides)
        assert job_id != serialiser.get_latest_successful_job_id_for_name_and_params(report_name, overrides)
示例#2
0
def test_run_report_and_rerun(bson_library, mongo_host, workspace,
                              test_db_name, test_lib_name):
    _setup_workspace(workspace)

    for k, v in _environ(mongo_host, workspace, test_db_name,
                         test_lib_name).items():
        os.environ[k] = v
    try:
        flask_app = create_app()
        with flask_app.app_context() as c:
            serialiser = get_serializer()
            overrides = {"n_points": 5}
            report_name = "fake/report"
            report_title = "my report title"
            mailto = "*****@*****.**"
            job_id = run_report(report_name,
                                report_title,
                                mailto,
                                overrides,
                                generate_pdf_output=False,
                                prepare_only=True)
            _check_report_output(
                job_id,
                serialiser,
                overrides=overrides,
                report_name=report_name,
                report_title=report_title,
                mailto=mailto,
                generate_pdf_output=False,
            )

            new_job_id = _rerun_report(job_id, prepare_only=True)
            _check_report_output(
                new_job_id,
                serialiser,
                overrides=overrides,
                report_name=report_name,
                report_title="Rerun of " + report_title,
                mailto=mailto,
                generate_pdf_output=False,
            )
            assert new_job_id == serialiser.get_latest_job_id_for_name_and_params(
                report_name, overrides)
            assert not {job_id, new_job_id} - set(
                serialiser.get_all_job_ids_for_name_and_params(
                    report_name, overrides))
            assert new_job_id == serialiser.get_latest_successful_job_id_for_name_and_params(
                report_name, overrides)
            assert job_id != serialiser.get_latest_successful_job_id_for_name_and_params(
                report_name, overrides)
    finally:
        for k, __ in _environ(mongo_host, workspace, test_db_name,
                              test_lib_name).items():
            del os.environ[k]