'Tests that we can add image metadata with properties and
enable encryption.'

def test_add_image_with_location_data_with_encryption(self):

    self.client.metadata_encryption_key = '1234567890123456'
    location = 'file:///tmp/glance-tests/%d'
    loc_meta = {'key': 'value'}
    fixture = {'name': 'fake    public    image', 'is_public': True, 'disk_format': 'vmdk', 'container_format': 'ovf', 'size': 19, 'location_data': [{'url': (location % 1), 'metadata': loc_meta, 'status': 'active'}, {'url': (location % 2), 'metadata': {}, 'status': 'active'}], 'properties': {'distro': 'Ubuntu    10.04    LTS'}}
    new_image = self.client.add_image(fixture)
    self.assertEqual((location % 1), new_image['location'])
    self.assertEqual(2, len(new_image['location_data']))
    self.assertEqual((location % 1), new_image['location_data'][0]['url'])
    self.assertEqual(loc_meta, new_image['location_data'][0]['metadata'])
    self.assertEqual((location % 2), new_image['location_data'][1]['url'])
    self.assertEqual({}, new_image['location_data'][1]['metadata'])
    self.client.metadata_encryption_key = None
