def test_oneTrial(self, mock_print, mock_run_dig, mock_gen_stats): mock_run_dig.side_effect = [ dig.DigResults(answer=5, authority=0, additional=0, status="NOERROR", responding_server="", answer_section=[], authority_section=[], additional_section=[], query_time=120, msg_size=0, recursion_not_available=False), dig.DigResults(answer=5, authority=0, additional=0, status="NOERROR", responding_server="", answer_section=[], authority_section=[], additional_section=[], query_time=240, msg_size=0, recursion_not_available=False) ] recursive_reliability.test_reliability("b", "a", 1, 999) # Primer still runs dig_count = 2 self.assertEqual(dig_count, mock_run_dig.call_count) mock_run_dig.assert_has_calls([call(domain="a", target_server="b")] * dig_count) self.assertEqual(0, mock_gen_stats.call_count) self.assertEqual(0, mock_print.call_count)
def test_threeTrials_multipleResultsBadCov(self, mock_print, mock_run_dig, mock_gen_stats, mock_calculate_cov): mock_run_dig.side_effect = [ dig.DigResults(answer=5, authority=0, additional=0, status="NOERROR", responding_server="", answer_section=[], authority_section=[], additional_section=[], query_time=4, msg_size=0, recursion_not_available=False), dig.DigResults(answer=5, authority=0, additional=0, status="NOERROR", responding_server="", answer_section=[], authority_section=[], additional_section=[], query_time=2, msg_size=0, recursion_not_available=False), dig.DigResults(answer=5, authority=0, additional=0, status="NOERROR", responding_server="", answer_section=[], authority_section=[], additional_section=[], query_time=4, msg_size=0, recursion_not_available=False), dig.DigResults(answer=5, authority=0, additional=0, status="NOERROR", responding_server="", answer_section=[], authority_section=[], additional_section=[], query_time=2, msg_size=0, recursion_not_available=False) ] mock_gen_stats.side_effect = ["generated_stats_go_here"] mock_calculate_cov.side_effect = [1000] recursive_reliability.test_reliability("b", "a", 3, 999) dig_count = 4 self.assertEqual(dig_count, mock_run_dig.call_count) mock_run_dig.assert_has_calls([call(domain="a", target_server="b")] * dig_count) self.assertEqual(1, mock_calculate_cov.call_count) self.assertEqual(0, mock_gen_stats.call_count) self.assertEqual(0, mock_print.call_count)