diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2014-05-12 15:12:24 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2014-05-12 15:50:02 (GMT) |
commit | e0008f8b1cd2ccb1e044dfbabfa30c54d07d71fa (patch) | |
tree | 4208645b16b277cb55872ea85a5aa7ec479d1291 /tests/units/db/db_routes.py | |
parent | fbfc90eae2909a640dfee17715f39234522ea3bf (diff) |
Revert node statistics
Diffstat (limited to 'tests/units/db/db_routes.py')
-rwxr-xr-x | tests/units/db/db_routes.py | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/tests/units/db/db_routes.py b/tests/units/db/db_routes.py index e9f3b28..86c699c 100755 --- a/tests/units/db/db_routes.py +++ b/tests/units/db/db_routes.py @@ -19,7 +19,7 @@ from __init__ import tests from sugar_network import db, toolkit from sugar_network.db import routes as db_routes from sugar_network.model.user import User -from sugar_network.toolkit.router import Router, Request, Response, fallbackroute, ACL, File +from sugar_network.toolkit.router import Router, Request, Response, fallbackroute, ACL, File, postroute from sugar_network.toolkit.coroutine import this from sugar_network.toolkit import coroutine, http, i18n @@ -1851,6 +1851,53 @@ class DbRoutesTest(tests.Test): [{'event': 'delete', 'resource': 'document', 'guid': guid}], events) + def test_ThisResourceInPostrouteOnCreation(self): + + class Document(db.Resource): + + @db.stored_property() + def prop(self, value): + return value + + class Routes(db.Routes): + + @postroute + def postroute(self, result, exception): + return this.resource.properties(['guid', 'prop']) + + volume = db.Volume(tests.tmpdir, [Document]) + router = Router(Routes(volume)) + + self.assertEqual({ + 'guid': 'guid', + 'prop': 'probe', + }, + this.call(method='POST', path=['document'], content={'guid': 'guid', 'prop': 'probe'})) + + def test_ThisResourceInPostrouteOnDeletion(self): + + class Document(db.Resource): + + @db.stored_property() + def prop(self, value): + return value + + class Routes(db.Routes): + + @postroute + def postroute(self, result, exception): + return this.resource.properties(['guid', 'prop']) + + volume = db.Volume(tests.tmpdir, [Document]) + router = Router(Routes(volume)) + + this.call(method='POST', path=['document'], content={'guid': 'guid', 'prop': 'probe'}) + self.assertEqual({ + 'guid': 'guid', + 'prop': 'probe', + }, + this.call(method='DELETE', path=['document', 'guid'])) + if __name__ == '__main__': tests.main() |