Esempio n. 1
0
    def test__remove_outdated_interfaces(self):
        device = fake_network.FakeDevice(
            'foobarquuz', [dict(ip_version=4, cidr='1.0.0.0/27')])
        devices = [fake_network.FakeDevice('foobar')]
        self.ip().get_devices = mock.Mock(return_value=devices)

        bc = BaseChild()
        self.mock_object(bc, 'unplug')

        bc._remove_outdated_interfaces(device)
        bc.unplug.assert_called_once_with('foobar')
Esempio n. 2
0
    def test__get_set_of_device_cidrs(self):
        device = fake_network.FakeDevice('foo')
        expected = set(('1.0.0.0/27', '2.0.0.0/27'))

        bc = BaseChild()
        result = bc._get_set_of_device_cidrs(device)

        self.assertEqual(expected, result)
Esempio n. 3
0
    def test__get_set_of_device_cidrs_exception(self):
        device = fake_network.FakeDevice('foo')
        self.mock_object(device.addr, 'list', mock.Mock(
            side_effect=Exception('foo does not exist')))

        bc = BaseChild()
        result = bc._get_set_of_device_cidrs(device)

        self.assertEqual(set(), result)