'Ensure that image locations can be removed.
Image locations should be able to be added and removed simultaneously
as long as the image has fewer than the limited number of image
locations after the transaction.'

def test_update_add_and_remove_location_under_limit(self):

    self.stubs.Set(store, 'get_size_from_backend', unit_test_utils.fake_get_size_from_backend)
    self.config(show_multiple_locations=True)
    request = unit_test_utils.get_fake_request()
    changes = [{'op': 'add', 'path': ['locations', '-'], 'value': {'url': ('%s/fake_location_1' % BASE_URI), 'metadata': {}}}, {'op': 'add', 'path': ['locations', '-'], 'value': {'url': ('%s/fake_location_2' % BASE_URI), 'metadata': {}}}]
    self.controller.update(request, UUID1, changes)
    self.config(image_location_quota=2)
    changes = [{'op': 'remove', 'path': ['locations', '0']}, {'op': 'remove', 'path': ['locations', '0']}, {'op': 'add', 'path': ['locations', '-'], 'value': {'url': ('%s/fake_location_3' % BASE_URI), 'metadata': {}}}]
    output = self.controller.update(request, UUID1, changes)
    self.assertEqual(UUID1, output.image_id)
    self.assertEqual(2, len(output.locations))
    self.assertIn('fake_location_3', output.locations[1]['url'])
    self.assertNotEqual(output.created_at, output.updated_at)
