예제 #1
0
파일: test_dream.py 프로젝트: ieure/dream
 def test_has_prefix(self):
     """Make sure endpoint URLs include the prefix."""
     prefix = "/foo"
     app = App(prefix=prefix)
     endpoints(app, "/endpoints")
     for endpoint in app.endpoints().iterkeys():
         self.assertTrue(prefix in endpoint)
예제 #2
0
파일: test_dream.py 프로젝트: ieure/dream
    def test_endpoints(self):
        """Make sure hidden functions don't show up in endpoints."""
        app = App()

        @app.expose('/endpoint')
        @hidden
        def endpoint(request):
            return Response()

        self.assertFalse(app.endpoints())
예제 #3
0
파일: test_dream.py 프로젝트: ieure/dream
class GetEndpointsTest(unittest.TestCase):

    """Test _get_endpoints."""

    def setUp(self):
        self.app = App()

    def test_endpoints(self):
        self.app.expose('foo')(lambda request: Response())
        self.app.expose('bar')(lambda request: Response())

        endpoints = self.app.endpoints()
        self.assertTrue('GET foo' in endpoints.keys())
        self.assertTrue('GET bar' in endpoints.keys())
예제 #4
0
class EndpointsTest(unittest.TestCase):

    """Test dream.endpoints()"""

    def setUp(self):
        self.app = App()
        endpoints(self.app, '/endpoints')

    def test_endpoints(self):
        self.assertTrue('GET /endpoints' in self.app.endpoints().keys())

    def test_endpoints_reponse(self):
        self.assertTrue(isinstance(
                self.app.route({'REQUEST_METHOD': 'GET',
                                'PATH_INFO': '/endpoints'}),
                HumanReadableJSONResponse))
예제 #5
0
파일: test_dream.py 프로젝트: ieure/dream
class EndpointsTest(unittest.TestCase):

    """Test dream.endpoints()"""

    def setUp(self):
        self.app = App()
        endpoints(self.app, '/endpoints')

    def test_endpoints(self):
        self.assertTrue('GET /endpoints' in self.app.endpoints().keys())

    def test_endpoints_reponse(self):
        (request, response) = self.app.route({'REQUEST_METHOD': 'GET',
                                              'PATH_INFO': '/endpoints'})
        self.assertTrue(isinstance(response, HumanReadableJSONResponse))

    def test_has_prefix(self):
        """Make sure endpoint URLs include the prefix."""
        prefix = "/foo"
        app = App(prefix=prefix)
        endpoints(app, "/endpoints")
        for endpoint in app.endpoints().iterkeys():
            self.assertTrue(prefix in endpoint)