source: TI05-delivery/ows_framework/trunk/ows_server/ows_server/tests/functional/test_csml_wms.py @ 2596

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI05-delivery/ows_framework/trunk/ows_server/ows_server/tests/functional/test_csml_wms.py@2596
Revision 2596, 1.9 KB checked in by spascoe, 12 years ago (diff)

Improved tests.

Line 
1from ows_server.tests import *
2import cElementTree as ET
3from cStringIO import StringIO
4import Image
5
6wms_ns = 'http://www.opengis.net/wms'
7
8# This depends on the value randomly generated by csmlscan.
9# However make_data.py sets the random seed so this should work.
10test_feature_id = 'DVVhDIq2'
11
12class TestGetCapabilities(TestController):
13    def setUp(self):
14        url = url_for(controller='csml_wms',
15                      file='test',
16                      request='GetCapabilities',
17                      service='WMS',
18                      version='1.3.0',
19                      )
20       
21        print 'Capabilities URL = %s' % url
22
23        self.response = self.app.get(url)
24        self.xml = ET.XML(self.response.body)
25
26    def testRootNode(self):
27        assert self.xml.tag == '{%s}WMS_Capabilities' % wms_ns
28
29    def testLayers(self):
30        layers = self.xml.findall('./{%(ns)s}Service/{%(ns)s}Capability/{%(ns)s}Layer' % dict(ns=wms_ns))
31
32        # Assert there is one base layer
33        assert len(layers) == 1
34
35        # With 4 sub-layers
36        layers = layers[0].findall('./{%(ns)s}Layer' % dict(ns=wms_ns))
37        assert len(layers) == 4
38
39class TestGetMap(TestController):
40    def setUp(self):
41        url = url_for(controller='csml_wms', file='test',
42                      request='GetMap',
43                      layers=test_feature_id,
44                      bbox='-180,-90,180,90',
45                      time='1980-01-01T00:00:00.0',
46                      crs='CRS:84', width='100', height='100', styles='',
47                      version='1.3.0', format='image/png')
48
49        self.response = self.app.get(url)
50
51    def testContentType(self):
52        assert self.response.header('Content-type') == 'image/png'
53
54    def testImage(self):
55        img = Image.open(StringIO(self.response.body))
56
57        assert img.format == 'PNG'
58        assert img.size == (100, 100)
59       
Note: See TracBrowser for help on using the repository browser.