'Ensure that updating image properties counts existing image properties
when enforcing property quota.'

def test_update_image_with_too_many_properties_without_purge_props(self):

    self.config(image_property_quota=1)
    request = unit_test_utils.get_fake_request(path='/images')
    headers = {'x-image-meta-disk-format': 'ami', 'x-image-meta-container-format': 'ami', 'x-image-meta-name': 'foo', 'x-image-meta-size': '0', 'x-image-meta-property-x_all_permitted_create': '1', 'x-auth-token': 'user:tenant:admin'}
    for (k, v) in six.iteritems(headers):
        request.headers[k] = v
    created_image = request.get_response(self.api)
    res_body = jsonutils.loads(created_image.body)['image']
    image_id = res_body['id']
    another_request = unit_test_utils.get_fake_request(path=('/images/%s' % image_id), method='PUT')
    headers = {'x-auth-token': 'user:tenant:joe_soap', 'x-glance-registry-purge-props': 'False', 'x-image-meta-property-x_all_permitted': '1'}
    for (k, v) in six.iteritems(headers):
        another_request.headers[k] = v
    output = another_request.get_response(self.api)
    self.assertEqual(http_client.REQUEST_ENTITY_TOO_LARGE, output.status_int)
    self.assertIn('Attempted:    2,    Maximum:    1', output.text)
