Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2012-09-24 09:42:56 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2012-09-24 09:42:56 (GMT)
commit6dc4237b46dbe600d3e88cfafc5aa07e29f4bfa8 (patch)
treedd5285c47716391aea46985be8d75c72e0300e3f /tests
parentb213ba6544df29f032dc1c7383dfe50f7c4b2953 (diff)
Simplify returning BLOB urls from GET commands
Diffstat (limited to 'tests')
-rwxr-xr-xtests/units/datastore.py4
-rwxr-xr-xtests/units/injector.py2
-rwxr-xr-xtests/units/node.py19
-rwxr-xr-xtests/units/remote_mount.py8
-rwxr-xr-xtests/units/router.py22
5 files changed, 17 insertions, 38 deletions
diff --git a/tests/units/datastore.py b/tests/units/datastore.py
index 6f12f2e..de1e67d 100755
--- a/tests/units/datastore.py
+++ b/tests/units/datastore.py
@@ -104,7 +104,7 @@ class DatastoreTest(tests.Test):
'user': [],
'author': [],
},
- artifacts.get('1').properties())
+ artifacts.get('1').properties(['guid', 'context', 'activity_id', 'ctime', 'description', 'keep', 'mime_type', 'tags', 'timestamp', 'mtime', 'title', 'filesize', 'traits', 'layer', 'user', 'author']))
self.assertEqual(
'preview-1',
file(artifacts.get('1').meta('preview')['path']).read())
@@ -130,7 +130,7 @@ class DatastoreTest(tests.Test):
'user': [],
'author': [],
},
- artifacts.get('2').properties())
+ artifacts.get('2').properties(['guid', 'context', 'activity_id', 'ctime', 'description', 'keep', 'mime_type', 'tags', 'timestamp', 'mtime', 'title', 'filesize', 'traits', 'layer', 'user', 'author']))
self.assertEqual(
'preview-2',
file(artifacts.get('2').meta('preview')['path']).read())
diff --git a/tests/units/injector.py b/tests/units/injector.py
index 29acf96..0c36459 100755
--- a/tests/units/injector.py
+++ b/tests/units/injector.py
@@ -265,7 +265,7 @@ class InjectorTest(tests.Test):
'[Activity]',
'name = TestActivity',
'bundle_id = bundle_id',
- 'exec = false',
+ 'exec = true',
'icon = icon',
'activity_version = 1',
'license = Public Domain',
diff --git a/tests/units/node.py b/tests/units/node.py
index d0ff38f..b4ec682 100755
--- a/tests/units/node.py
+++ b/tests/units/node.py
@@ -307,19 +307,20 @@ class NodeTest(tests.Test):
{'guid': guid3, 'icon': 'http://localhost/foo/bar', 'layer': ['public']},
call(cp, method='GET', document='context', guid=guid3, reply=['guid', 'icon', 'layer']))
self.assertEqual(
- {'guid': guid4, 'data': 'http://localhost/report/%s/data' % guid4, 'layer': ['public']},
+ {'guid': guid4, 'data': None, 'layer': ['public']},
call(cp, method='GET', document='report', guid=guid4, reply=['guid', 'data', 'layer']))
- self.assertEqual([
- {'guid': guid1, 'icon': 'http://localhost/static/images/missing.png', 'layer': ['public']},
- {'guid': guid2, 'icon': 'http://foo/bar', 'layer': ['public']},
- {'guid': guid3, 'icon': 'http://localhost/foo/bar', 'layer': ['public']},
- {'guid': guid5, 'icon': ['http://localhost/1', 'http://2'], 'layer': ['public']},
- ],
- call(cp, method='GET', document='context', reply=['guid', 'icon', 'layer'])['result'])
+ self.assertEqual(
+ sorted([
+ {'guid': guid1, 'icon': 'http://localhost/static/images/missing.png', 'layer': ['public']},
+ {'guid': guid2, 'icon': 'http://foo/bar', 'layer': ['public']},
+ {'guid': guid3, 'icon': 'http://localhost/foo/bar', 'layer': ['public']},
+ {'guid': guid5, 'icon': ['http://localhost/1', 'http://2'], 'layer': ['public']},
+ ]),
+ sorted(call(cp, method='GET', document='context', reply=['guid', 'icon', 'layer'])['result']))
self.assertEqual([
- {'guid': guid4, 'data': 'http://localhost/report/%s/data' % guid4, 'layer': ['public']},
+ {'guid': guid4, 'data': None, 'layer': ['public']},
],
call(cp, method='GET', document='report', reply=['guid', 'data', 'layer'])['result'])
diff --git a/tests/units/remote_mount.py b/tests/units/remote_mount.py
index 40e7cfb..ed8beef 100755
--- a/tests/units/remote_mount.py
+++ b/tests/units/remote_mount.py
@@ -312,13 +312,13 @@ class RemoteMountTest(tests.Test):
self.touch((cache_path, 'blob-2'))
blob = remote.get(['context', guid, 'preview'], cmd='get_blob')
self.assertEqual('blob-2', file(blob['path']).read())
- self.assertEqual(3, json.load(file(cache_path + '.meta'))['seqno'])
+ seqno = json.load(file(cache_path + '.meta'))['seqno']
self.touch(('file', 'blob-3'))
remote.put(['context', guid, 'preview'], cmd='upload_blob', path=abspath('file'))
blob = remote.get(['context', guid, 'preview'], cmd='get_blob')
self.assertEqual('blob-3', file(blob['path']).read())
- self.assertEqual(4, json.load(file(cache_path + '.meta'))['seqno'])
+ assert seqno < json.load(file(cache_path + '.meta'))['seqno']
def test_DoNotStaleBLOBs(self):
self.start_ipc_and_restful_server()
@@ -338,7 +338,7 @@ class RemoteMountTest(tests.Test):
cache_path = 'cache/context/%s/%s/preview' % (guid[:2], guid)
self.touch((cache_path, 'blob-2'))
- self.assertEqual(3, json.load(file(cache_path + '.meta'))['seqno'])
+ seqno = json.load(file(cache_path + '.meta'))['seqno']
# Shift seqno
remote.put(['context', guid], {'title': 'title-2'})
@@ -346,7 +346,7 @@ class RemoteMountTest(tests.Test):
blob = remote.get(['context', guid, 'preview'], cmd='get_blob')
self.assertEqual('blob-2', file(blob['path']).read())
- self.assertEqual(4, json.load(file(cache_path + '.meta'))['seqno'])
+ assert seqno < json.load(file(cache_path + '.meta'))['seqno']
if __name__ == '__main__':
diff --git a/tests/units/router.py b/tests/units/router.py
index 7b9c5ca..5c3facb 100755
--- a/tests/units/router.py
+++ b/tests/units/router.py
@@ -104,24 +104,6 @@ class RouterTest(tests.Test):
'result': sorted([])},
rest.get('/document', reply='guid,stored,term'))
- def test_JsonAutoEncoding(self):
- self.fork(self.restful_server, [User, Document])
- rest = tests.Request('http://localhost:8800')
-
- guid = rest.post('/document', {'term': 'term'})
-
- self.assertRaises(RuntimeError, rest.get, '/document/' + guid + '/json')
-
- rest.put('/document/' + guid + '/json', -1)
- self.assertEqual(
- -1,
- rest.get('/document/' + guid + '/json'))
-
- rest.put('/document/' + guid + '/json', {'foo': None})
- self.assertEqual(
- {'foo': None},
- rest.get('/document/' + guid + '/json'))
-
def test_StreamedResponse(self):
class CommandsProcessor(ad.CommandsProcessor):
@@ -339,10 +321,6 @@ class Document(ad.Document):
def blob(self, value):
return value
- @ad.active_property(ad.BlobProperty, mime_type='application/json')
- def json(self, value):
- return value
-
@ad.active_property(ad.StoredProperty, default='')
def author(self, value):
return value