def test_example_report_do_list(example_report): "Check email actions with no whitelisting or blacklisting." reps = example_report recipients = sorted([ '*****@*****.**', '*****@*****.**', '*****@*****.**', 'john@_company.com', 'sam@not_a_company.com', ]) assert SendEmail(recipients=recipients, notification=Notify(what='variable_failing', subject='Project #1', params=BldVariable( project='Project #1', varname='c_compiler', varvalue='clang')), sent_to=[]) in reps assert SendEmail(recipients=['*****@*****.**'], notification=Notify(what='variable_failing', subject='Repo1', params=BldVariable( project='Repo1', varname='ghcver', varvalue='ghc881')), sent_to=[]) in reps assert SendEmail(recipients=['*****@*****.**', 'george@_company.com'], notification=Notify(what='main_good', subject='Repo1', params='master'), sent_to=[]) in reps
def test_example_report_take_actions(send_email, inp_configs, example_report): "Check email actions with no whitelisting or blacklisting." send_email.side_effect = lambda r, s, m: r rep = hh.perform_hh_actions(inp_configs, example_report) for each in rep: if isinstance(each, SendEmail): print('') print(each) recipients = sorted([ '*****@*****.**', '*****@*****.**', 'john@_company.com', '*****@*****.**', 'sam@not_a_company.com', ]) recipients_with_owner = sorted(recipients + ['george@_company.com']) assert SendEmail(recipients=recipients, notification=Notify(what='variable_failing', subject='Project #1', params=BldVariable( project='Project #1', varname='c_compiler', varvalue='clang')), sent_to=recipients) in rep assert SendEmail(recipients=["*****@*****.**"], notification=Notify(what='variable_failing', subject='Repo1', params=BldVariable( project='Repo1', varname='ghcver', varvalue='ghc881')), sent_to=["*****@*****.**"]) in rep assert SendEmail(recipients=["*****@*****.**", "george@_company.com"], notification=Notify(what='main_good', subject='Repo1', params='master'), sent_to=["*****@*****.**", "george@_company.com"]) in rep assert SendEmail(recipients=filter(lambda r: 'betty' not in r, recipients_with_owner), notification=Notify(what='main_submodules_good', subject='Project #1', params='master'), sent_to=filter(lambda r: 'betty' not in r, recipients_with_owner)) in rep send_email.assert_has_calls([ call(recipients, ANY, ANY), call(list(filter(lambda r: 'betty' not in r, recipients_with_owner)), ANY, ANY), call(["*****@*****.**", "george@_company.com"], ANY, ANY), call(["*****@*****.**"], ANY, ANY), ], any_order=True) assert send_email.call_count == 4
def test_example_report_do_list_b(testing_dir, generated_inp_config_bldconfigs): "Check email blacklist only disables blacklisted." for each in generated_inp_config_bldconfigs.result_sets: each.builder._build_results = { "R1": texres.build_results, "R10": [], "Repo1": tdups.build_results, }[[R.repo_name for R in each.inp_desc.RL if R.project_repo][0]] reps = generate_report( testing_dir, generated_inp_config_bldconfigs, tdups.prior + texres.prior, reporting_logic_defs=''' email_domain_blacklist("not_a_company.com"). ''', ) for each in reps: if isinstance(each, SendEmail): print('') print(each) recipients = sorted([ '*****@*****.**', '*****@*****.**', '*****@*****.**', 'john@_company.com', ]) assert SendEmail(recipients=recipients, notification=Notify(what='variable_failing', subject='Project #1', params=BldVariable( project='Project #1', varname='c_compiler', varvalue='clang')), sent_to=[]) in reps assert SendEmail(recipients=['*****@*****.**'], notification=Notify(what='variable_failing', subject='Repo1', params=BldVariable( project='Repo1', varname='ghcver', varvalue='ghc881')), sent_to=[]) in reps assert SendEmail(recipients=['*****@*****.**', 'george@_company.com'], notification=Notify(what='main_good', subject='Repo1', params='master'), sent_to=[]) in reps
def test_example_report_do_list_w(testing_dir, generated_inp_config_bldconfigs): "Check email whitelist auto-disable all and only allow whitelisted." for each in generated_inp_config_bldconfigs.result_sets: each.builder._build_results = { "R1": texres.build_results, "R10": [], "Repo1": tdups.build_results, }[[R.repo_name for R in each.inp_desc.RL if R.project_repo][0]] reps = generate_report( testing_dir, generated_inp_config_bldconfigs, tdups.prior + texres.prior, reporting_logic_defs=''' email_domain_whitelist("_company.com"). ''', ) for each in reps: if isinstance(each, SendEmail): print('') print(each) recipients = sorted([ 'john@_company.com', ]) assert SendEmail(recipients=recipients, notification=Notify(what='variable_failing', subject='Project #1', params=BldVariable( project='Project #1', varname='c_compiler', varvalue='clang')), sent_to=[]) in reps
def test_example_report_varfail_do_email_again(generate_hydra_results): """Express a prior send of an email to the target; this ensures that these prior sends are retained. """ bldcfgs, reps = generate_hydra_results( build_results=build_results, prior=prior + [ SendEmail(recipients=['*****@*****.**'], notification=Notify(what='variable_failing', subject='Project #1', params=BldVariable( project='Project #1', varname='c_compiler', varvalue='clang')), sent_to=['*****@*****.**']) ], ) for each in reps: print('') print(each) print('') print(len(reps)) recipients = sorted([ '*****@*****.**', '*****@*****.**', 'john@_company.com', 'sam@not_a_company.com', '*****@*****.**' ]) assert SendEmail(recipients=recipients, notification=Notify(what='variable_failing', subject='Project #1', params=BldVariable( project='Project #1', varname='c_compiler', varvalue='clang')), sent_to=[]) not in reps assert SendEmail(recipients=recipients, notification=Notify(what='variable_failing', subject='Project #1', params=BldVariable( project='Project #1', varname='c_compiler', varvalue='clang')), sent_to=['*****@*****.**']) in reps
def test_example_report_varfail_do_email(example_hydra_results): bldcfgs, reps = example_hydra_results print('') print(len(reps)) assert SendEmail(recipients=sorted([ '*****@*****.**', '*****@*****.**', '*****@*****.**', 'john@_company.com', 'sam@not_a_company.com' ]), notification=Notify(what='variable_failing', subject='Project #1', params=BldVariable( project='Project #1', varname='c_compiler', varvalue='clang')), sent_to=[]) in reps