Example #1
0
    def test_empty_output(self):
        self.maxDiff = None
        ntp = Ntp(device=self.device)
        # Get outputs
        ntp.maker.outputs[ShowNtpPeerStatus] = \
            {"": {}}

        ntp.maker.outputs[ShowNtpPeers] = \
            {"": {}}

        # Learn the feature
        ntp.learn()

        # Check no attribute not found
        with self.assertRaises(AttributeError):
            ntp.info['clock_state']
Example #2
0
    def test_incomplete_output(self):
        self.maxDiff = None

        ntp = Ntp(device=self.device)

        # Get outputs
        ntp.maker.outputs[ShowNtpPeerStatus] = \
            {"": NtpOutput.ShowNtpPeerStatus}

        ntp.maker.outputs[ShowNtpPeers] = \
            {"": {}}

        # Learn the feature
        ntp.learn()

        # Check no attribute not found
        with self.assertRaises(KeyError):
            ntp.info['unicast_configuration']
Example #3
0
    def test_output_with_attribute(self):
        self.maxDiff = None
        ntp = Ntp(device=self.device,
                  attributes=[
                      'info[associations][(.*)]',
                      'info[unicast_configuration][(.*)]'
                  ])
        # Get outputs
        ntp.maker.outputs[ShowNtpPeerStatus] = \
            {"": NtpOutput.ShowNtpPeerStatus}

        ntp.maker.outputs[ShowNtpPeers] = \
            {"": NtpOutput.ShowNtpPeers}

        # Learn the feature
        ntp.learn()

        # Check no attribute not found
        with self.assertRaises(KeyError):
            ntp.info['clock_state']

        # info - unicast_configuration
        self.assertEqual(ntp.info['vrf'], NtpOutput.Ntp_info['vrf'])
Example #4
0
    def test_complete_output(self):
        self.maxDiff = None
        ntp = Ntp(device=self.device)
        # Get outputs
        ntp.maker.outputs[ShowNtpPeerStatus] = \
            {"": NtpOutput.ShowNtpPeerStatus}

        ntp.maker.outputs[ShowNtpPeers] = \
            {"": NtpOutput.ShowNtpPeers}

        # Learn the feature
        ntp.learn()

        # Verify Ops was created successfully
        self.assertEqual(ntp.info, NtpOutput.Ntp_info)

        # Check specific attribute values
        # info - default vrf
        self.assertEqual(
            ntp.info['clock_state']['system_status']['clock_state'],
            'synchronized')
        # info - vrf VRF1
        self.assertEqual(ntp.info['vrf']['default']['unicast_configuration']['address']\
                                 ['10.16.2.2']['type']['server']['type'], 'server')
Example #5
0
    def test_complete_output(self):
        self.maxDiff = None
        ntp = Ntp(device=self.device)

        # Return outputs above as inputs to parser when called
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper

        # Learn the feature
        ntp.learn()

        # Verify Ops was created successfully
        # no associtaion attribtues since there is only one synch
        # server which shouldn't go to association
        self.assertEqual(ntp.info, NtpOutputNoConfig.Ntp_info)

        # Check specific attribute values
        # info - default vrf
        self.assertEqual(
            ntp.info['clock_state']['system_status']['associations_address'],
            '127.127.1.0')
        # info - vrf default
        self.assertEqual(ntp.info['vrf']['default']['unicast_configuration']['address']\
                                 ['127.127.1.0']['type']['server']['type'], 'server')