def test_fixed_ips_ip_address_only(self): node_props = {'fixed_ip': '1.2.3.4'} with mock.patch( 'neutron_plugin.port.' 'get_openstack_id_of_single_connected_node_by_openstack_type', self._get_connected_subnet_mock(return_empty=True)): with mock.patch( 'neutron_plugin.port.ctx', self._get_mock_ctx_with_node_properties(node_props)): port = {} neutron_plugin.port._handle_fixed_ips(port) self.assertEquals([{'ip_address': '1.2.3.4'}], port.get('fixed_ips'))
def test_fixed_ips_subnet_only(self): node_props = {'fixed_ip': ''} mock_neutron = MockNeutronClient(update=True) with mock.patch( 'neutron_plugin.port.' 'get_openstack_ids_of_connected_nodes_by_openstack_type', self._get_connected_subnets_mock(return_empty=False)): with mock.patch( 'neutron_plugin.port.ctx', self._get_mock_ctx_with_node_properties(node_props)): port = {} neutron_plugin.port._handle_fixed_ips(port, mock_neutron) self.assertEquals([{ 'subnet_id': 'some-subnet-id' }], port.get('fixed_ips'))