def test_proxy_get_capabilities_user2(self): request = _create_dummy_request(username=u"__test_user2") proxy = self.get_fake_proxy_(request, load_file(TestTinyOWSProxyView.capabilities_response_file), 200) response = proxy.proxy() filtered = load_file(TestTinyOWSProxyView.capabilities_response_filtered_file2) response.body = response.body.replace(" \n", "") self.assertEquals(filtered, response.body) self.assertEquals("200 OK", response.status)
def test_proxy_get_capabilities_get(self): request = _create_dummy_request(username=u"__test_user1") request.params.update(dict(service="wfs", version="1.1.0", request="GetCapabilities")) proxy = self.get_fake_proxy_(request, load_file(TestTinyOWSProxyView.capabilities_response_file), 200) response = proxy.proxy() filtered = load_file(TestTinyOWSProxyView.capabilities_response_filtered_file1) response.body = response.body.replace(" \n", "") self.assertEquals(filtered, response.body) self.assertEquals("200 OK", response.status)
def test_proxy_get_capabilities_user2(self): request = _create_dummy_request(username=u"__test_user2") proxy = self.get_fake_proxy_( request, load_file(TestTinyOWSProxyView.capabilities_response_file), 200) response = proxy.proxy() filtered = load_file( TestTinyOWSProxyView.capabilities_response_filtered_file2) response.body = response.body.replace(" \n", "") self.assertEquals(filtered, response.body) self.assertEquals("200 OK", response.status)
def test_proxy_get_capabilities_get(self): request = _create_dummy_request(username=u"__test_user1") request.params.update( dict(service="wfs", version="1.1.0", request="GetCapabilities")) proxy = self.get_fake_proxy_( request, load_file(TestTinyOWSProxyView.capabilities_response_file), 200) response = proxy.proxy() filtered = load_file( TestTinyOWSProxyView.capabilities_response_filtered_file1) response.body = response.body.replace(" \n", "") self.assertEquals(filtered, response.body) self.assertEquals("200 OK", response.status)
def test_capabilities_filter_featuretype_private_layer(self): xml = load_file(TestFilterCapabilities.capabilities_file) layers_whitelist = set() layers_whitelist.add("parks") filtered_xml = self._filter_xml(xml, u"FeatureType", layers_whitelist) self.assertTrue("<Name>tows:parks</Name>" in filtered_xml)
def test_proxy_describe_feature_type_post(self): request = _create_dummy_request(username=u"__test_user1") request.method = "POST" request.body = load_file(TestTinyOWSProxyView.describefeaturetype_request_file) proxy = self.get_fake_proxy_(request, "unfiltered response", 200) response = proxy.proxy() self.assertEquals("200 OK", response.status)
def test_proxy_describe_feature_type_post_multiple_types(self): from pyramid.httpexceptions import HTTPBadRequest request = _create_dummy_request(username=u"__test_user1") request.method = "POST" request.body = load_file(TestTinyOWSProxyView.describefeaturetype_request_multiple_file) proxy = self.get_fake_proxy_(request, "", None) self.assertRaises(HTTPBadRequest, proxy.proxy)
def test_proxy_describe_feature_type_post_multiple_types(self): from pyramid.httpexceptions import HTTPBadRequest request = _create_dummy_request(username=u"__test_user1") request.method = "POST" request.body = load_file( TestTinyOWSProxyView.describefeaturetype_request_multiple_file) proxy = self.get_fake_proxy_(request, "", None) self.assertRaises(HTTPBadRequest, proxy.proxy)
def test_proxy_describe_feature_type_post(self): request = _create_dummy_request(username=u"__test_user1") request.method = "POST" request.body = load_file( TestTinyOWSProxyView.describefeaturetype_request_file) proxy = self.get_fake_proxy_(request, "unfiltered response", 200) response = proxy.proxy() self.assertEquals("200 OK", response.status)
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)
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)
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)
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)
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)
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)
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)
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)