| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #!/usr/bin/env python
- # coding=utf-8
- #
- #
- import unittest
- import logging
- import os,sys
- from ConfigParser import ConfigParser
- import urllib
- import urlparse
- OWSVIEWER_DIR=os.path.abspath(os.path.join(os.path.dirname(__file__),".."))
- sys.path.append(OWSVIEWER_DIR)
- from OWS import *
- class TestOWS(unittest.TestCase):
- """Base class for OWS services (WFS, WCS)
- """
- owsUrl = None
- config = None
- service = None
- def setUp(self):
- # set logging
- logging.basicConfig(level=logging.DEBUG)
-
- # mapfile for original services
- mapfile = os.path.join(OWSVIEWER_DIR,"tests","mapfiles","ows.map")
- self.config = ConfigParser.ConfigParser()
- self.config.read(os.path.join(OWSVIEWER_DIR,"tests","test.cfg"))
- self.owsUrl = self._getURLWithMap(mapfile)
- os.environ.update({"QUERY_STRING":
- "owsService=%s&owsUrl=%s"%(self.service,urllib.quote(self.owsUrl))})
- self.service = getService()
- def _getURLWithMap(self,mapfile):
- # create URL which will produce WCS and WFS services for testing
- # purposes
- owsUrl = urlparse.urlparse(self.config.get("OWSServer","owsserver"))
- owsParams = urlparse.parse_qs(owsUrl[4])
- owsParams["map"] = mapfile
- return urlparse.urlunparse((owsUrl[0],owsUrl[1],owsUrl[2], owsUrl[3],
- urllib.unquote(urllib.urlencode(owsParams,True)),owsUrl[5]))
|