class HuaweiTest(unittest2.TestCase):
    """test huawei switch snmp get."""
    def setUp(self):
        super(HuaweiTest, self).setUp()
        logsetting.init()
        self.huawei = Huawei()
        self.sys_info = 'Huawei Technologies'

    def tearDown(self):
        del self.huawei
        super(HuaweiTest, self).tearDown()

    def test_is_this_vendor(self):
        """test device vendor is haiwei."""
        # Incorrect system information
        incorrect_sys_info = "xxx"
        self.assertFalse(self.huawei.is_this_vendor(incorrect_sys_info))

        # Correct vendor
        self.assertTrue(self.huawei.is_this_vendor(self.sys_info))
Esempio n. 2
0
class HuaweiTest(unittest2.TestCase):
    """test huawei switch snmp get."""

    def setUp(self):
        super(HuaweiTest, self).setUp()
        logsetting.init()
        self.huawei = Huawei()
        self.sys_info = 'Huawei Technologies'

    def tearDown(self):
        del self.huawei
        super(HuaweiTest, self).tearDown()

    def test_is_this_vendor(self):
        """test device vendor is haiwei."""
        # Incorrect system information
        incorrect_sys_info = "xxx"
        self.assertFalse(
            self.huawei.is_this_vendor(incorrect_sys_info))

        # Correct vendor
        self.assertTrue(
            self.huawei.is_this_vendor(self.sys_info))
class HuaweiTest(unittest2.TestCase):

    def setUp(self):
        self.huawei = Huawei()
        self.correct_host = '172.29.8.40'
        self.correct_credentials = {'Version': 'v2c', 'Community': 'public'}

    def tearDown(self):
        del self.huawei

    @patch('compass.hdsdiscovery.utils.snmp_get')
    def test_IsThisVendor_WithIncorrectIPFormat(self, snmp_get_mock):
        snmp_get_mock.return_value = None

        #host is incorrest IP address format
        self.assertFalse(self.huawei.is_this_vendor('500.10.1.2000',
                                                    self.correct_credentials))

    @patch('compass.hdsdiscovery.utils.snmp_get')
    def test_IsThisVendor_WithWrongCredential(self, snmp_get_mock):
        snmp_get_mock.return_value = None

        #Credential's keyword is incorrect
        self.assertFalse(
            self.huawei.is_this_vendor(self.correct_host,
                                       {'username': '******',
                                        'Community': 'public'}))

        #Incorrect Version
        self.assertFalse(
            self.huawei.is_this_vendor(self.correct_host,
                                       {'Version': 'v1',
                                        'Community': 'public'}))

        #Incorrect Community
        self.assertFalse(
            self.huawei.is_this_vendor(self.correct_host,
                                       {'Version': 'v2c',
                                        'Community': 'private'}))

    @patch('compass.hdsdiscovery.utils.snmp_get')
    def test_IsThisVendor_WithCorrectInput(self, snmp_get_mock):
        snmp_get_mock.return_value = "Huawei"
        self.assertTrue(self.huawei.is_this_vendor(self.correct_host,
                                                   self.correct_credentials))

    @patch('compass.hdsdiscovery.utils.snmp_get')
    def test_IsThisVendor_WithIncorrectVendor(self, snmp_get_mock):

        snmp_get_mock.return_value = None
        self.assertFalse(
            self.huawei.is_this_vendor('1.1.1.1',
                                       {'Version': 'v1',
                                        'Community': 'private'}))
 def setUp(self):
     self.huawei = Huawei()
     self.correct_host = '172.29.8.40'
     self.correct_credentials = {'Version': 'v2c', 'Community': 'public'}
Esempio n. 5
0
 def setUp(self):
     super(HuaweiTest, self).setUp()
     logsetting.init()
     self.huawei = Huawei()
     self.sys_info = 'Huawei Technologies'
 def setUp(self):
     super(HuaweiTest, self).setUp()
     logsetting.init()
     self.huawei = Huawei()
     self.sys_info = 'Huawei Technologies'