Beispiel #1
0
    def test_main_helper_no_matching_resource_record_error(self):
        """
        Test case for when the resolver raises a DNSNoMatchingResourceRecordError
        """
        mock_resolver: Mock = Mock(**{'ask.side_effect': DNSNoMatchingResourceRecordError('No Matching Resource Record Error Message')})

        with redirect_stdout(self.buffer):
            main_helper(mock_resolver, "www.cs.ubc.ca", "1.2.3.4", False, False)

        self.assertEqual(self.buffer.getvalue(), "\nNo Matching Resource Record Error Message\n")
Beispiel #2
0
    def test_main_helper_zero_counter_error(self):
        """
        Test case for when the resolver raises a DNSZeroCounterError
        """
        mock_resolver: Mock = Mock(**{'ask.side_effect': DNSZeroCounterError('Zero Counter Error Message')})

        with redirect_stdout(self.buffer):
            main_helper(mock_resolver, "www.cs.ubc.ca", "1.2.3.4", False, False)

        self.assertEqual(self.buffer.getvalue(), "\nZero Counter Error Message\n")
Beispiel #3
0
    def test_main_helper_one_answer_returned(self):
        """
        Test case for when the resolver returns a single answer
        """
        mock_resolver: Mock = Mock(**{'ask.return_value': [ResourceRecord("www.ubc.cs.ca", 1, 1, 600, 4, "1.2.3.4")]})

        with redirect_stdout(self.buffer):
            main_helper(mock_resolver, "www.cs.ubc.ca", "1.2.3.4", False, False)

        self.assertEqual(self.buffer.getvalue(), "\nAnswers:"
                                                 "\n  www.cs.ubc.ca 600   A 1.2.3.4\n")