diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2012-03-17 07:51:35 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2012-03-17 07:51:35 (GMT) |
commit | 38528f7c492b469e1a5b797efa5fd40e8e259907 (patch) | |
tree | 87040a32256b3f03938780e7c3b3255c3cf80e04 | |
parent | b7533c7bc7ae06ca90f201d3c4701882d8836524 (diff) |
Stat blob properties
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | restful_document/document.py | 5 | ||||
-rwxr-xr-x | tests/units/document.py | 9 |
3 files changed, 13 insertions, 2 deletions
@@ -0,0 +1 @@ +* router treats http://localhost:8000//user not as http://localhost:8000/user diff --git a/restful_document/document.py b/restful_document/document.py index a62c002..e83b991 100644 --- a/restful_document/document.py +++ b/restful_document/document.py @@ -86,6 +86,11 @@ class Document(ad.Document): else: return self[prop] + @restful_method(method='GET', cmd='stat') + def restful_stat_blob(self, prop=None): + enforce(prop, _('Property name is not specified')) + return self.stat_blob(prop) + def all_properties(self, reply): result = {} for prop_name in (reply or ['guid']): diff --git a/tests/units/document.py b/tests/units/document.py index 348d8c7..9e58546 100755 --- a/tests/units/document.py +++ b/tests/units/document.py @@ -3,6 +3,7 @@ import json import time +import hashlib from __init__ import tests from tests import Resource @@ -158,12 +159,16 @@ class DocumentTest(tests.Test): 'term4', json.loads(rest.get('/document/' + guid_2 + '/term', headers=tests.creds()).body_string())) + payload = 'blob' headers = tests.creds() headers['Content-Type'] = 'application/octet-stream' - rest.put('/document/' + guid_2 + '/blob', payload='blob', headers=headers) + rest.put('/document/' + guid_2 + '/blob', payload=payload, headers=headers) self.assertEqual( - 'blob', + payload, rest.get('/document/' + guid_2 + '/blob', headers=tests.creds()).body_string()) + self.assertEqual( + {'size': len(payload), 'sha1sum': hashlib.sha1(payload).hexdigest()}, + json.loads(rest.get('/document/' + guid_2 + '/blob', headers=tests.creds(), cmd='stat').body_string())) rest.delete('/document/' + guid_2, headers=tests.creds()) |