def test_breakdown_resets_to_null_when_calculus_errors_out(betamax_recorder): engineer_traction = EngineerTractionFormula(betamax_recorder.session) test_moniker_A = ('build_metrics', 'build times') test_moniker_B = ('nonexistent_framework', 'nonexistent_suite') cassette_preffix_A = '-'.join(filter(None, test_moniker_A)) cassette_preffix_B = '-'.join(filter(None, test_moniker_B)) # run happy path calculus with betamax_recorder.use_cassette(f'{cassette_preffix_A}', serialize_with='prettyjson'): engineer_traction( *test_moniker_A) # let it perform calculus & cache breakdown _ = engineer_traction.breakdown() # now run alternated path calculus with betamax_recorder.use_cassette(f'{cassette_preffix_B}', serialize_with='prettyjson'): with pytest.raises(NoFiledBugs): engineer_traction( *test_moniker_B) # intentionally blows up while doing calculus # cached breakdown got invalidated & can no longer be obtained with pytest.raises(RuntimeError): _ = engineer_traction.breakdown()
def test_breakdown_updates_between_calculations(betamax_recorder): engineer_traction = EngineerTractionFormula(betamax_recorder.session) test_moniker_A = ('build_metrics', 'build times') test_moniker_B = ('talos', 'tp5n', 'nonmain_startup_fileio') cassette_preffix_A = '-'.join(filter(None, test_moniker_A)) cassette_preffix_B = '-'.join(filter(None, test_moniker_B)) with betamax_recorder.use_cassette(f'{cassette_preffix_A}', serialize_with='prettyjson'): engineer_traction( *test_moniker_A) # let it perform calculus & cache breakdown breakdown_A = engineer_traction.breakdown() with betamax_recorder.use_cassette(f'{cassette_preffix_B}', serialize_with='prettyjson'): engineer_traction( *test_moniker_B) # let it perform calculus & cache breakdown breakdown_B = engineer_traction.breakdown() assert breakdown_A != breakdown_B
def test_formula_filters_out_bugs_that_didnt_cool_down_yet( framework, suite, test, betamax_recorder): engineer_traction = EngineerTractionFormula(betamax_recorder.session) cassette = '-'.join(filter(None, [framework, suite, test])) with betamax_recorder.use_cassette(f'{cassette}', serialize_with='prettyjson'): engineer_traction(framework, suite, test) # let it perform calculus & cache breakdown # left with cooled down bugs only all_filed_bugs, _ = engineer_traction.breakdown() for bug in all_filed_bugs: assert engineer_traction.has_cooled_down(bug)
def test_formula_fetches_bugs_from_quantifying_period(framework, suite, test, betamax_recorder): engineer_traction = EngineerTractionFormula(betamax_recorder.session) cassette = '-'.join(filter(None, [framework, suite, test])) with betamax_recorder.use_cassette(f'{cassette}', serialize_with='prettyjson'): engineer_traction(framework, suite, test) # let it perform calculus & cache breakdown all_filed_bugs, except_new_bugs = engineer_traction.breakdown() assert len(all_filed_bugs) > 0 for bug in all_filed_bugs: creation_time = datetime.strptime(bug['creation_time'], BZ_DATETIME_FORMAT) assert creation_time >= engineer_traction.oldest_timestamp
def test_accessing_breakdown_without_prior_calculus_errors_out( nonblock_session): engineer_traction = EngineerTractionFormula(nonblock_session) with pytest.raises(RuntimeError): _ = engineer_traction.breakdown()