Generate url for blob dicts right

Change-Id: Ia61c3e13b31c85dbe9cf8c4b027e25134613eb5e
This commit is contained in:
Mike Fedosin 2017-01-16 23:47:39 +03:00
parent 25ad2f35cf
commit 00fa51bf76
2 changed files with 12 additions and 2 deletions

View File

@ -103,7 +103,7 @@ class BlobFieldType(fields.FieldType):
blob_path = attr.split('[')
url = url + blob_path[0]
if len(blob_path) > 1:
url = '/%s' % blob_path[1][:-1]
url += '/%s' % blob_path[1][1:-2]
prim['url'] = url
return prim

View File

@ -692,9 +692,15 @@ class TestBlobs(base.TestArtifact):
self.get(url=url + '/dict_of_blobs/new_blob',
status=200))
# download blob from undefined dict property
# Download blob from undefined dict property
self.get(url=url + '/not_a_dict/not_a_blob', status=400)
# Blob url is generated right
art = self.get(url=url, status=200)
exp_blob_url = '/artifacts' + url + '/dict_of_blobs/new_blob'
self.assertEqual(exp_blob_url,
art['dict_of_blobs']['new_blob']['url'])
def test_blob_upload(self):
# create artifact with blob
data = 'data'
@ -733,6 +739,10 @@ class TestBlobs(base.TestArtifact):
self.assertIn('url', art['blob'])
self.assertNotIn('id', art['blob'])
# Blob url is generated right
exp_blob_url = '/artifacts' + url + '/blob'
self.assertEqual(exp_blob_url, art['blob']['url'])
# reUpload file to artifact
self.put(url=url + '/blob', data=data, status=409,
headers=headers)