コード例 #1
0
    def test_layer1(self):
        """Testing method / function layer1."""
        # Initializing key variables
        expected_dict = {
            199: {'cdpCacheDeviceId': 'byte_string_1',
                  'cdpCachePlatform': 'byte_string_1',
                  'cdpCacheDevicePort': 'byte_string_1'},
            299: {'cdpCacheDeviceId': 'byte_string_2',
                  'cdpCachePlatform': 'byte_string_2',
                  'cdpCacheDevicePort': 'byte_string_2'}
        }

        # Set the stage for SNMPwalk
        snmpobj = Mock(spec=Query)
        mock_spec = {'swalk.return_value': self.walk_results_string}
        snmpobj.configure_mock(**mock_spec)

        # Get results
        testobj = testimport.init_query(snmpobj)
        results = testobj.layer1()

        # Basic testing of results
        for primary in results.keys():
            for secondary in results[primary].keys():
                self.assertEqual(
                    results[primary][secondary],
                    expected_dict[primary][secondary])
コード例 #2
0
    def test_layer1(self):
        """Testing method / function layer1."""
        # Initializing key variables
        expected_dict = {
            199: {
                'cdpCacheDeviceId': 'byte_string_1',
                'cdpCachePlatform': 'byte_string_1',
                'cdpCacheDevicePort': 'byte_string_1'
            },
            299: {
                'cdpCacheDeviceId': 'byte_string_2',
                'cdpCachePlatform': 'byte_string_2',
                'cdpCacheDevicePort': 'byte_string_2'
            }
        }

        # Set the stage for SNMPwalk
        snmpobj = Mock(spec=Query)
        mock_spec = {'swalk.return_value': self.walk_results_string}
        snmpobj.configure_mock(**mock_spec)

        # Get results
        testobj = testimport.init_query(snmpobj)
        results = testobj.layer1()

        # Basic testing of results
        for primary in results.keys():
            for secondary in results[primary].keys():
                self.assertEqual(results[primary][secondary],
                                 expected_dict[primary][secondary])
コード例 #3
0
    def test_supported(self):
        """Testing method / function supported."""
        # Set the stage for oid_exists returning True
        snmpobj = Mock(spec=Query)
        mock_spec = {'oid_exists.return_value': True}
        snmpobj.configure_mock(**mock_spec)

        # Test supported
        testobj = testimport.init_query(snmpobj)
        self.assertEqual(testobj.supported(), True)

        # Set the stage for oid_exists returning False
        mock_spec = {'oid_exists.return_value': False}
        snmpobj.configure_mock(**mock_spec)

        # Test unsupported
        testobj = testimport.init_query(snmpobj)
        self.assertEqual(testobj.supported(), False)
コード例 #4
0
    def test_supported(self):
        """Testing method / function supported."""
        # Set the stage for oid_exists returning True
        snmpobj = Mock(spec=Query)
        mock_spec = {'oid_exists.return_value': True}
        snmpobj.configure_mock(**mock_spec)

        # Test supported
        testobj = testimport.init_query(snmpobj)
        self.assertEqual(testobj.supported(), True)

        # Set the stage for oid_exists returning False
        mock_spec = {'oid_exists.return_value': False}
        snmpobj.configure_mock(**mock_spec)

        # Test unsupported
        testobj = testimport.init_query(snmpobj)
        self.assertEqual(testobj.supported(), False)
コード例 #5
0
    def test_cdpcachedeviceid(self):
        """Testing method / function cdpcachedeviceid."""
        # Set the stage for SNMPwalk
        snmpobj = Mock(spec=Query)
        mock_spec = {'swalk.return_value': self.walk_results_string}
        snmpobj.configure_mock(**mock_spec)

        # Get results
        testobj = testimport.init_query(snmpobj)
        results = testobj.cdpcachedeviceid()

        # Basic testing of results
        for key in results.keys():
            self.assertEqual(isinstance(key, int), True)

        # Test that we are getting the correct OID
        results = testobj.cdpcachedeviceid(oidonly=True)
        self.assertEqual(results, '.1.3.6.1.4.1.9.9.23.1.2.1.1.6')
コード例 #6
0
    def test_cdpcachedeviceid(self):
        """Testing method / function cdpcachedeviceid."""
        # Set the stage for SNMPwalk
        snmpobj = Mock(spec=Query)
        mock_spec = {'swalk.return_value': self.walk_results_string}
        snmpobj.configure_mock(**mock_spec)

        # Get results
        testobj = testimport.init_query(snmpobj)
        results = testobj.cdpcachedeviceid()

        # Basic testing of results
        for key in results.keys():
            self.assertEqual(isinstance(key, int), True)

        # Test that we are getting the correct OID
        results = testobj.cdpcachedeviceid(oidonly=True)
        self.assertEqual(results, '.1.3.6.1.4.1.9.9.23.1.2.1.1.6')