Exemple #1
0
    def setUp(self):
        """This setup creates a status that is not ok"""
        self.netbox_patcher = patch('nav.watchdog.tests.Netbox')
        self.lookup_patcher = patch('nav.watchdog.tests.reverse_lookup')
        netbox = self.netbox_patcher.start()
        lookup = self.lookup_patcher.start()

        lookup.return_value = {
            '129.241.23.23': ['netbox1'],
            '129.241.23.24': ['netbox1'],
        }
        n1 = Mock()
        n1.ip = '129.241.23.23'
        n2 = Mock()
        n2.ip = '129.241.23.24'
        netbox.objects.all = Mock(return_value=[n1, n2])
        self.test = tests.TestDuplicateHostnameForIP()
Exemple #2
0
 def test_errors_should_be_of_type_testresult(self, netboxes):
     self.test = tests.TestDuplicateHostnameForIP()
     self.test.run()
     assert isinstance(self.test.errors.pop(), tests.TestResult)
Exemple #3
0
 def test_length_of_errors_when_run_is_one(self, netboxes):
     self.test = tests.TestDuplicateHostnameForIP()
     self.test.run()
     assert len(self.test.errors) == 1
Exemple #4
0
 def test_length_of_errors_when_initialized_is_zero(self, netboxes):
     self.test = tests.TestDuplicateHostnameForIP()
     assert len(self.test.errors) == 0
Exemple #5
0
 def test_status_when_initialized_is_unknown(self, netboxes):
     self.test = tests.TestDuplicateHostnameForIP()
     assert self.test.status == tests.STATUS_UNKNOWN
Exemple #6
0
 def test_get_status(self, netboxes):
     self.test = tests.TestDuplicateHostnameForIP()
     assert self.test.get_status() == tests.STATUS_NOT_OK