예제 #1
0
    def get_fake_proxy_(self, request, response_body, status):
        from c2cgeoportal.views.tinyowsproxy import TinyOWSProxy
        from types import MethodType

        proxy = TinyOWSProxy(request)

        def fake_proxy(self,
                       url,
                       params=None,
                       method=None,
                       cache=False,
                       body=None,
                       headers=None):
            content = response_body

            class FakeResponse(dict):
                pass

            resp = FakeResponse()
            resp.status = status
            resp["content-type"] = "application/xml"

            return resp, content

        proxy._proxy = MethodType(fake_proxy, proxy, TinyOWSProxy)

        return proxy
예제 #2
0
    def test_parse_body_transaction_insert(self):
        from c2cgeoportal.views.tinyowsproxy import TinyOWSProxy

        request = _create_dummy_request()

        transaction_insert_request = load_file(TestTinyOWSProxyViewNoDb.transaction_insert_request_file)
        request.body = transaction_insert_request

        proxy = TinyOWSProxy(request)
        (operation, typename) = proxy._parse_body(request.body)
        self.assertEquals("transaction", operation)
        self.assertEquals(set(["parks"]), typename)
예제 #3
0
    def test_parse_body_lockfeature(self):
        from c2cgeoportal.views.tinyowsproxy import TinyOWSProxy

        request = _create_dummy_request()

        lockfeature_request = load_file(TestTinyOWSProxyViewNoDb.lockfeature_request_file)
        request.body = lockfeature_request

        proxy = TinyOWSProxy(request)
        (operation, typename) = proxy._parse_body(request.body)
        self.assertEquals("lockfeature", operation)
        self.assertEquals(set(["parks"]), typename)
예제 #4
0
    def test_parse_body_describefeaturetype(self):
        from c2cgeoportal.views.tinyowsproxy import TinyOWSProxy

        request = _create_dummy_request()

        describefeature_request = load_file(TestTinyOWSProxyViewNoDb.describefeature_request_file)
        request.body = describefeature_request

        proxy = TinyOWSProxy(request)
        (operation, typename) = proxy._parse_body(request.body)
        self.assertEquals("describefeaturetype", operation)
        self.assertEquals(set(["layer_1"]), typename)
예제 #5
0
    def test_parse_body_getcapabilities(self):
        from c2cgeoportal.views.tinyowsproxy import TinyOWSProxy

        request = _create_dummy_request()

        capabilities_request = load_file(TestTinyOWSProxyViewNoDb.capabilities_request_file)
        request.body = capabilities_request

        proxy = TinyOWSProxy(request)
        (operation, typename) = proxy._parse_body(request.body)
        self.assertEquals("getcapabilities", operation)
        self.assertEquals(set(), typename)
예제 #6
0
    def test_parse_body_transaction_insert(self):
        from c2cgeoportal.views.tinyowsproxy import TinyOWSProxy

        request = _create_dummy_request()

        transaction_insert_request = \
            load_file(TestTinyOWSProxyViewNoDb.transaction_insert_request_file)
        request.body = transaction_insert_request

        proxy = TinyOWSProxy(request)
        (operation, typename) = proxy._parse_body(request.body)
        self.assertEquals("transaction", operation)
        self.assertEquals(set(["parks"]), typename)
예제 #7
0
    def test_parse_body_lockfeature(self):
        from c2cgeoportal.views.tinyowsproxy import TinyOWSProxy

        request = _create_dummy_request()

        lockfeature_request = \
            load_file(TestTinyOWSProxyViewNoDb.lockfeature_request_file)
        request.body = lockfeature_request

        proxy = TinyOWSProxy(request)
        (operation, typename) = proxy._parse_body(request.body)
        self.assertEquals("lockfeature", operation)
        self.assertEquals(set(["parks"]), typename)
예제 #8
0
    def test_parse_body_describefeaturetype(self):
        from c2cgeoportal.views.tinyowsproxy import TinyOWSProxy

        request = _create_dummy_request()

        describefeature_request = \
            load_file(TestTinyOWSProxyViewNoDb.describefeature_request_file)
        request.body = describefeature_request

        proxy = TinyOWSProxy(request)
        (operation, typename) = proxy._parse_body(request.body)
        self.assertEquals("describefeaturetype", operation)
        self.assertEquals(set(["layer_1"]), typename)
예제 #9
0
    def test_parse_body_getcapabilities(self):
        from c2cgeoportal.views.tinyowsproxy import TinyOWSProxy

        request = _create_dummy_request()

        capabilities_request = \
            load_file(TestTinyOWSProxyViewNoDb.capabilities_request_file)
        request.body = capabilities_request

        proxy = TinyOWSProxy(request)
        (operation, typename) = proxy._parse_body(request.body)
        self.assertEquals("getcapabilities", operation)
        self.assertEquals(set(), typename)
예제 #10
0
    def get_fake_proxy_(self, request, response_body, status):
        from c2cgeoportal.views.tinyowsproxy import TinyOWSProxy
        from types import MethodType

        proxy = TinyOWSProxy(request)

        def fake_proxy(self, url, params=None, method=None, cache=False, body=None, headers=None):
            content = response_body

            class FakeResponse(dict):
                pass
            resp = FakeResponse()
            resp.status = status
            resp["content-type"] = "application/xml"

            return resp, content

        proxy._proxy = MethodType(fake_proxy, proxy, TinyOWSProxy)

        return proxy
예제 #11
0
    def test_proxy_not_auth(self):
        from c2cgeoportal.views.tinyowsproxy import TinyOWSProxy
        from pyramid.httpexceptions import HTTPUnauthorized

        request = _create_dummy_request()
        self.assertRaises(HTTPUnauthorized, TinyOWSProxy(request).proxy)