source: cows/trunk/cows/test/testapp/controllers/wxs.py @ 4613

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows/trunk/cows/test/testapp/controllers/wxs.py@4613
Revision 4613, 1.1 KB checked in by spascoe, 12 years ago (diff)

Improved testing for COWS.

To effectively test COWS you need a Pylons application. I've created a
mini pylons app in cows/test/testapp that is automatically wired into
the Pylons testing framework when you run "nosetests cows". See
cows/test/README.

Line 
1import logging
2
3log = logging.getLogger(__name__)
4
5from cows.pylons.ows_controller import OWSController, addOperation
6
7class WxsController(OWSController):
8
9    service = 'WXS'
10    owsOperations = (OWSController.owsOperations + ['GetPiza'])
11
12    validVersions = ['0.1']
13
14    def _loadCapabilities(self):
15        """This is a hook used to populate c.capabilites with service metadata.
16
17        """
18        pass
19
20    def _renderCapabilities(self, version, format):
21        """Select a Genshi template for rendering the capabilities according
22        to version and format.
23
24        c.capabilities will contain the OWS-Common model for the capabilities.
25
26        Return any pylons controller response.
27        """
28        pass
29
30    def GetPiza(self):
31        toppings = self.getOwsParam('toppings',
32                                    default='cheese,tomato').split(',')
33
34        response.headers['Content-Type'] = 'text/plain'
35        if len(toppings) > 1:
36            t1 = toppings[:-1]
37            t2 = toppings[-1]
38            return 'One %s and %s piza to go!' % (', '.join(t1), t2)
39        else:
40            return 'One %s piza to go!' % toppings[0]
Note: See TracBrowser for help on using the repository browser.