Пример #1
0
    def test_ignored(self):
        f = Hsrp(device=self.device)
        # Get 'show hsrp all' output
        f.maker.outputs[ShowHsrpAll] = {'': HsrpOutput.showHsrpAllOutput}
        # Get 'show hsrp summary' output
        f.maker.outputs[ShowHsrpSummary] = {
            '': HsrpOutput.showHsrpSummaryOutput
        }
        # Get 'show hsrp delay' output
        f.maker.outputs[ShowHsrpDelay] = {'': HsrpOutput.showHsrpDelayOutput}
        g = Hsrp(device=self.device)
        # Get 'show hsrp all' output
        g.maker.outputs[ShowHsrpAll] = {'': HsrpOutput.showHsrpAllOutput}
        # Get 'show hsrp summary' output
        g.maker.outputs[ShowHsrpSummary] = {
            '': HsrpOutput.showHsrpSummaryOutput
        }
        # Get 'show hsrp delay' output
        g.maker.outputs[ShowHsrpDelay] = {'': HsrpOutput.showHsrpDelayOutput}

        # Learn the feature
        f.learn()
        g.learn()

        f.s = 2

        self.assertNotEqual(f, g)
        # Verify diff now
        diff = f.diff(g)
        sorted_diff = str(diff)
        sorted_result = ("+s: 2")
        self.assertEqual(sorted_diff, sorted_result)
Пример #2
0
    def test_ignored(self):
        f = Hsrp(device=self.device)
        # Get 'show hsrp all' output
        f.maker.outputs[ShowHsrpAll] = {'': HsrpOutput.showHsrpAllOutput}
        # Get 'show hsrp summary' output
        f.maker.outputs[ShowHsrpSummary] = {
            '': HsrpOutput.showHsrpSummaryOutput
        }
        # Get 'show hsrp delay' output
        f.maker.outputs[ShowHsrpDelay] = {'': HsrpOutput.showHsrpDelayOutput}
        g = Hsrp(device=self.device)
        # Get 'show hsrp all' output
        g.maker.outputs[ShowHsrpAll] = {'': HsrpOutput.showHsrpAllOutput}
        # Get 'show hsrp summary' output
        g.maker.outputs[ShowHsrpSummary] = {
            '': HsrpOutput.showHsrpSummaryOutput
        }
        # Get 'show hsrp delay' output
        g.maker.outputs[ShowHsrpDelay] = {'': HsrpOutput.showHsrpDelayOutput}

        # Learn the feature
        f.learn()
        g.learn()

        f.diff_ignore.append('info[Ethernet1/3][bfd_sessions_total]')

        self.assertNotEqual(f, g)
        # Verify diff now
        diff = f.diff(g)
        sorted_diff = str(diff)
        sorted_result = (
            "+diff_ignore: deque(['maker', 'callables', "
            "'device', 'info[Ethernet1/3][bfd_sessions_total]'])\n"
            "-diff_ignore: deque(['maker', 'callables', 'device'])")
        self.assertEqual(sorted_diff, sorted_result)
Пример #3
0
    def test_incomplete_output(self):
        f = Hsrp(device=self.device)
        # Get 'show hsrp all' output
        f.maker.outputs[ShowHsrpAll] = {'': HsrpOutput.showHsrpAllOutput}
        # Get 'show hsrp summary' output
        f.maker.outputs[ShowHsrpSummary] = {
            '': HsrpOutput.showHsrpSummaryOutput
        }
        # Get 'show hsrp delay' output
        f.maker.outputs[ShowHsrpDelay] = {'': ''}
        # Learn the feature
        f.learn()

        with self.assertRaises(KeyError):
            hsrp_groups = f.info['Ethernet1/3']['delay']['reload_delay']
Пример #4
0
    def test_missing_attributes(self):
        f = Hsrp(device=self.device)
        # Get 'show hsrp all' output
        f.maker.outputs[ShowHsrpAll] = {'': HsrpOutput.showHsrpAllOutput}
        # Get 'show hsrp summary' output
        f.maker.outputs[ShowHsrpSummary] = {
            '': HsrpOutput.showHsrpSummaryOutput
        }
        # Get 'show hsrp delay' output
        f.maker.outputs[ShowHsrpDelay] = {'': HsrpOutput.showHsrpDelayOutput}
        # Learn the feature
        f.learn()

        with self.assertRaises(KeyError):
            hsrp_bfd_sessions_total = f.info['bfd_sessions_total']
Пример #5
0
    def test_full(self):

        f = Hsrp(device=self.device)
        # Get 'show hsrp all' output
        f.maker.outputs[ShowHsrpAll] = {'': HsrpOutput.showHsrpAllOutput}
        # Get 'show hsrp summary' output
        f.maker.outputs[ShowHsrpSummary] = {
            '': HsrpOutput.showHsrpSummaryOutput
        }
        # Get 'show hsrp delay' output
        f.maker.outputs[ShowHsrpDelay] = {'': HsrpOutput.showHsrpDelayOutput}
        # Learn the feature
        f.learn()
        # Check
        self.maxDiff = None
        self.assertEqual(f.info, HsrpOutput.hsrpOpsOutput)
Пример #6
0
 def test_selective_attribute(self):
     f = Hsrp(device=self.device)
     # Get 'show hsrp all' output
     f.maker.outputs[ShowHsrpAll] = {'': HsrpOutput.showHsrpAllOutput}
     # Get 'show hsrp summary' output
     f.maker.outputs[ShowHsrpSummary] = {
         '': HsrpOutput.showHsrpSummaryOutput
     }
     # Get 'show hsrp delay' output
     f.maker.outputs[ShowHsrpDelay] = {'': HsrpOutput.showHsrpDelayOutput}
     # Learn the feature
     f.learn()
     # Check match
     self.assertEqual(110, f.info['Ethernet1/3']['address_family']['ipv4']\
             ['version'][2]['groups'][0]['priority'])
     # Check does not match
     self.assertNotEqual(100, f.info['Ethernet1/3']['delay']\
         ['minimum_delay'])