

@mock.patch.object(glance.api, 'glance')
def test_image_create_private(self, gc):
    request = self.mock_rest_request(body='{"name": "Test",\n            "disk_format": "aki", "import_data": false,\n            "visibility": "private", "container_format": "aki",\n            "protected": false, "image_url": "test.com",\n            "source_type": "url", "architecture": "testArch",\n            "description": "description", "kernel": "kernel",\n            "min_disk": 10, "min_ram": 5, "ramdisk": 10 }\n        ')
    new = gc.image_create.return_value
    new.to_dict.return_value = {
        'name': 'testimage',
    }
    new.name = 'testimage'
    metadata = {
        'name': 'Test',
        'disk_format': 'aki',
        'container_format': 'aki',
        'is_public': False,
        'protected': False,
        'min_disk': 10,
        'min_ram': 5,
        'location': 'test.com',
        'properties': {
            'description': 'description',
            'architecture': 'testArch',
            'ramdisk_id': 10,
            'kernel_id': 'kernel',
        },
    }
    response = glance.Images().post(request)
    self.assertStatusCode(response, 201)
    self.assertEqual(response.content.decode('utf-8'), '{"name": "testimage"}')
    self.assertEqual(response['location'], '/api/glance/images/testimage')
    gc.image_create.assert_called_once_with(request, **metadata)

dataset/ETHPy150Open openstack/horizon/openstack_dashboard/test/api_tests/glance_rest_tests.py ImagesRestTestCase.test_image_create_private/original