'Tests deletion of image type asset'

def test_delete_image_type_asset(self):

    image_asset = self.get_sample_asset(self.asset_name, asset_type='image')
    thumbnail_image_asset = self.get_sample_asset('delete_test_thumbnail', asset_type='image')
    response = self.client.post(self.url, {'name': 'delete_image_test', 'file': image_asset})
    self.assertEquals(response.status_code, 200)
    uploaded_image_url = json.loads(response.content)['asset']['url']
    response = self.client.post(self.url, {'name': 'delete_image_thumb_test', 'file': thumbnail_image_asset})
    self.assertEquals(response.status_code, 200)
    thumbnail_url = json.loads(response.content)['asset']['url']
    thumbnail_location = StaticContent.get_location_from_path(thumbnail_url)
    image_asset_location = AssetLocation.from_deprecated_string(uploaded_image_url)
    content = contentstore().find(image_asset_location)
    content.thumbnail_location = thumbnail_location
    contentstore().save(content)
    with mock.patch('opaque_keys.edx.locator.CourseLocator.make_asset_key') as mock_asset_key:
        mock_asset_key.return_value = thumbnail_location
        test_url = reverse_course_url('assets_handler', self.course.id, kwargs={'asset_key_string': unicode(uploaded_image_url)})
        resp = self.client.delete(test_url, HTTP_ACCEPT='application/json')
        self.assertEquals(resp.status_code, 204)
