Exemplo n.º 1
0
 def testDeviceSetupInvalidAddresses(self):
     # 10.0.0.1/32 denotes a network, not an address (technically).
     dev = device.Device(addresses=['10.0.0.1/32'])
     self.assertEqual(dev.addresses, [])
     # 10.0.0.1/24 denotes a network.
     dev = device.Device(addresses=['10.0.0.1/24'])
     self.assertEqual(dev.addresses, [])
Exemplo n.º 2
0
    def testDeviceAddressesProperty(self):
        dev = device.Device()
        self.assertEqual(dev.addresses, [])

        def set_valid():
            dev.addresses = ['10.0.0.1']

        def set_invalid_1():
            dev.addresses = ['10.0.0.1/32']

        def set_invalid_2():
            dev.addresses = ['10.0.0.0/24']

        def del_invalid():
            del dev.addresses

        self.assertRaises(ValueError, set_invalid_1)
        self.assertRaises(ValueError, set_invalid_2)
        set_valid()
        self.assertEqual(dev.addresses, [ipaddr.IPAddress('10.0.0.1')])
        self.assertRaises(AttributeError, del_invalid)
Exemplo n.º 3
0
 def setUp(self):
     self.device = device.Device(name='test1.popname', addresses='10.0.0.1')
     self.credential = credential.Credential(regexp='.*',
                                             connect_method='foo')
     self.session = session.Session(device=self.device)
     self.session.credential = self.credential
Exemplo n.º 4
0
 def testDeviceSetupValidAddress(self):
     dev = device.Device(addresses='10.0.0.1')
     self.assertEqual(dev.addresses, [ipaddr.IPAddress('10.0.0.1')])
Exemplo n.º 5
0
 def testDeviceSetupDefaults(self):
     dev = device.Device()
     self.assertEqual(dev.addresses, [])
     self.assert_(dev.name is None)
     self.assert_(dev.vendor is None)
Exemplo n.º 6
0
 def testDeviceSetupInvalidAddressCausesConnectError(self):
     # 10.0.0.1/32 denotes a network, not an address (technically).
     fake_dev = device.Device(addresses=['10.0.0.1/32'])
     self.assertEqual(fake_dev.addresses, [])
     self.assertRaises(errors.DeviceWithoutAddressError, fake_dev.connect)