예제 #1
0
    def test_data_returns_mac_address(self):
        interface = factory_models.InterfaceFactory()
        mac = models.MacAddress.create(interface_id=interface.id,
                                       address="ab-bc-cd-12-23-34")

        data = views.InterfaceConfigurationView(interface).data()

        self.assertEqual(data['mac_address'], mac.unix_format)
        self.assertEqual(data['id'], interface.virtual_interface_id)
예제 #2
0
    def test_data_returns_deallocated_ip_info(self):
        block = factory_models.IpBlockFactory()
        interface = factory_models.InterfaceFactory(vif_id_on_device="123")
        ip = factory_models.IpAddressFactory(ip_block_id=block.id,
                                              interface_id=interface.id)
        ip.deallocate()
        deallocated_ip = models.IpAddress.find(ip.id)
        expected_ip_config = _ip_data(deallocated_ip, block)
        ip_configuration_view = views.IpConfigurationView(deallocated_ip)

        self.assertEqual(expected_ip_config, ip_configuration_view.data()[0])
예제 #3
0
    def test_data_returns_ip_address_configuration_information(self):
        interface = factory_models.InterfaceFactory()

        ip1 = factory_models.IpAddressFactory(interface_id=interface.id)
        ip2 = factory_models.IpAddressFactory(interface_id=interface.id)

        data = views.InterfaceConfigurationView(interface).data()

        self.assertEqual(len(data['ip_addresses']), 2)
        self.assertItemsEqual(data['ip_addresses'],
                              views.IpConfigurationView(ip1, ip2).data())
예제 #4
0
    def test_data_returns_route_info(self):
        block = factory_models.IpBlockFactory()
        interface = factory_models.InterfaceFactory(vif_id_on_device="123")
        route1 = factory_models.IpRouteFactory(source_block_id=block.id)
        route2 = factory_models.IpRouteFactory(source_block_id=block.id)
        ip = factory_models.IpAddressFactory(ip_block_id=block.id,
                                             interface_id=interface.id)
        expected_ip_config_routes = [_route_data(route1), _route_data(route2)]

        ip_configuration_view = views.IpConfigurationView(ip).data()[0]
        ip1_config_routes = ip_configuration_view['ip_block'].pop('ip_routes')

        self.assertItemsEqual(expected_ip_config_routes, ip1_config_routes)
예제 #5
0
    def test_data_returns_block_ip_info(self):
        block1 = factory_models.IpBlockFactory()
        block2 = factory_models.IpBlockFactory()
        interface = factory_models.InterfaceFactory(vif_id_on_device="123")
        ip1 = factory_models.IpAddressFactory(ip_block_id=block1.id,
                                              interface_id=interface.id)
        ip2 = factory_models.IpAddressFactory(ip_block_id=block2.id,
                                              interface_id=interface.id)
        expected_ip1_config = _ip_data(ip1, block1)
        expected_ip2_config = _ip_data(ip2, block2)

        ip_configuration_view = views.IpConfigurationView(ip1, ip2)

        self.assertEqual(expected_ip1_config, ip_configuration_view.data()[0])
        self.assertEqual(expected_ip2_config, ip_configuration_view.data()[1])