

@mock.patch.object(objects.RequestSpec, '_to_legacy_instance')
@mock.patch.object(base, 'obj_to_primitive')
def test_to_legacy_request_spec_dict(self, image_to_primitive, spec_to_legacy_instance):
    fake_image_dict = mock.Mock()
    image_to_primitive.return_value = fake_image_dict
    fake_instance = {
        'root_gb': 1.0,
        'ephemeral_gb': 1.0,
        'memory_mb': 1.0,
        'vcpus': 1,
        'numa_topology': None,
        'pci_requests': None,
        'project_id': fakes.FAKE_PROJECT_ID,
        'availability_zone': 'nova',
        'uuid': '1',
    }
    spec_to_legacy_instance.return_value = fake_instance
    fake_flavor = objects.Flavor(root_gb=10, ephemeral_gb=0, memory_mb=512, vcpus=1)
    spec = objects.RequestSpec(num_instances=1, image=objects.ImageMeta(), numa_topology=None, pci_requests=None, project_id=1, availability_zone='nova', instance_uuid=uuids.instance, flavor=fake_flavor)
    spec_dict = spec.to_legacy_request_spec_dict()
    expected = {
        'num_instances': 1,
        'image': fake_image_dict,
        'instance_properties': fake_instance,
        'instance_type': fake_flavor,
    }
    self.assertEqual(expected, spec_dict)

dataset/ETHPy150Open openstack/nova/nova/tests/unit/objects/test_request_spec.py _TestRequestSpecObject.test_to_legacy_request_spec_dict/original