Пример #1
0
class TestDeviceDataCollectorNetconf(unittest.TestCase):
    def setUp(self):
        self._dao = InMemoryDao.getInstance()
        self.dataCollector = DeviceDataCollectorNetconf('1234', {}, InMemoryDao)

    def tearDown(self):
        InMemoryDao._destroy()
    
    @unittest.skip("need physical device to test")
    def testConnectToDevice(self):
        flexmock(self._dao).should_receive('getObjectById').and_return(Device("test", "qfx5100-48s-6q", "root", "Embe1mpls", "leaf", "", "192.168.48.182", None))

        dataCollector = DeviceDataCollectorNetconf('1234', {}, InMemoryDao)
        dataCollector._dao = self._dao
        dataCollector.manualInit()
        
        dataCollector.connectToDevice()
        
    def testConnectToDeviceValueError(self):
        flexmock(self._dao).should_receive('getObjectById').and_return(Device("test", "qfx5100-48s-6q", None, "Embe1mpls", "leaf", "", "0.0.0.0", None))
        self.dataCollector.manualInit()
        
        with self.assertRaises(DeviceConnectFailed) as ve:
            self.dataCollector.connectToDevice()

    def testConnectToDeviceConnectError(self):
        flexmock(self._dao).should_receive('getObjectById').and_return(Device("test", "qfx5100-48s-6q", "root", "Embe1mpls", "leaf", "", "0.0.0.0", None))
        self.dataCollector.manualInit()

        with self.assertRaises(DeviceConnectFailed) as de:
            self.dataCollector.connectToDevice()
        
        self.assertIsNotNone(de.exception.cause)
        self.assertTrue(issubclass(type(de.exception.cause), ConnectError))
Пример #2
0
    def testConnectToDevice(self):
        flexmock(self._dao).should_receive('getObjectById').and_return(Device("test", "qfx5100-48s-6q", "root", "Embe1mpls", "leaf", "", "192.168.48.182", None))

        dataCollector = DeviceDataCollectorNetconf('1234', {}, InMemoryDao)
        dataCollector._dao = self._dao
        dataCollector.manualInit()
        
        dataCollector.connectToDevice()
Пример #3
0
    def testConnectToDevice(self):
        flexmock(self._dao).should_receive('getObjectById').and_return(
            Device("test", "qfx5100-48s-6q", "root", "abcd1234", "leaf", "",
                   "192.168.48.182", None))

        dataCollector = DeviceDataCollectorNetconf('1234', {}, InMemoryDao)
        dataCollector._dao = self._dao
        dataCollector.manualInit()

        dataCollector.connectToDevice()
Пример #4
0
class TestDeviceDataCollectorNetconf(unittest.TestCase):
    def setUp(self):
        self._dao = InMemoryDao.getInstance()
        self.dataCollector = DeviceDataCollectorNetconf(
            '1234', {}, InMemoryDao)

    def tearDown(self):
        InMemoryDao._destroy()

    @unittest.skip("need physical device to test")
    def testConnectToDevice(self):
        flexmock(self._dao).should_receive('getObjectById').and_return(
            Device("test", "qfx5100-48s-6q", "root", "abcd1234", "leaf", "",
                   "192.168.48.182", None))

        dataCollector = DeviceDataCollectorNetconf('1234', {}, InMemoryDao)
        dataCollector._dao = self._dao
        dataCollector.manualInit()

        dataCollector.connectToDevice()

    def testConnectToDeviceValueError(self):
        flexmock(self._dao).should_receive('getObjectById').and_return(
            Device("test", "qfx5100-48s-6q", None, "abcd1234", "leaf", "",
                   "0.0.0.0", None))
        self.dataCollector.manualInit()

        with self.assertRaises(DeviceConnectFailed) as ve:
            self.dataCollector.connectToDevice()

    def testConnectToDeviceConnectError(self):
        flexmock(self._dao).should_receive('getObjectById').and_return(
            Device("test", "qfx5100-48s-6q", "root", "abcd1234", "leaf", "",
                   "0.0.0.0", None))
        self.dataCollector.manualInit()

        with self.assertRaises(DeviceConnectFailed) as de:
            self.dataCollector.connectToDevice()

        self.assertIsNotNone(de.exception.cause)
        self.assertTrue(issubclass(type(de.exception.cause), ConnectError))