From 027a86ff41e85c8a02b054192e42a63e416260ae Mon Sep 17 00:00:00 2001 From: Viktoras Makauskas Date: Sun, 1 Feb 2015 20:35:14 +0200 Subject: [PATCH] added operational info --- exampleProject/exampleApi/resources/__init__.py | 2 +- exampleProject/exampleApi/resources/operationalInfo.py | 10 ++++++++++ exampleProject/tests/testOperationalInfo.py | 9 +++++++++ paperThinRest/paperThinRest/httpLayer.py | 3 +-- 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 exampleProject/exampleApi/resources/operationalInfo.py create mode 100644 exampleProject/tests/testOperationalInfo.py diff --git a/exampleProject/exampleApi/resources/__init__.py b/exampleProject/exampleApi/resources/__init__.py index a92c3f8..dbc4570 100644 --- a/exampleProject/exampleApi/resources/__init__.py +++ b/exampleProject/exampleApi/resources/__init__.py @@ -1 +1 @@ -import projects \ No newline at end of file +import projects, operationalInfo \ No newline at end of file diff --git a/exampleProject/exampleApi/resources/operationalInfo.py b/exampleProject/exampleApi/resources/operationalInfo.py new file mode 100644 index 0000000..b6a4600 --- /dev/null +++ b/exampleProject/exampleApi/resources/operationalInfo.py @@ -0,0 +1,10 @@ +from paperThinRest.httpLayer import registerResource + +registerResource('/operational-info/',__name__) + + +def getItem(itemId): + if itemId=='ping': + return {'pong':True} + + return None diff --git a/exampleProject/tests/testOperationalInfo.py b/exampleProject/tests/testOperationalInfo.py new file mode 100644 index 0000000..a7af0fd --- /dev/null +++ b/exampleProject/tests/testOperationalInfo.py @@ -0,0 +1,9 @@ +from tests import testsSetup +testsSetup + +from paperThinRest.test.baseRestTestCase import BaseRestTestCase +class Test(BaseRestTestCase): + + def testPing(self): + data = self.expect(status=200).get('/operational-info/ping').json + self.assertEqual(data, {'pong':True}) diff --git a/paperThinRest/paperThinRest/httpLayer.py b/paperThinRest/paperThinRest/httpLayer.py index 1ae732e..b57d194 100644 --- a/paperThinRest/paperThinRest/httpLayer.py +++ b/paperThinRest/paperThinRest/httpLayer.py @@ -29,8 +29,7 @@ def getModuleMethod(name,defaultValue=None): mapToResource = getModuleMethod('mapToResource') if mapToResource is None: mapToResource = lambda thing: thing # a passthrough default implementation - - + createItem = getModuleMethod('createItem') if createItem is not None: def httpCreateItem():