Ignore:
Timestamp:
15/06/07 14:51:13 (13 years ago)
Author:
spascoe
Message:

Various changes. Some test data is generated with make_data.py and this
is used to test the csml_wms controller. These tests pass.

Also there are some subsetToGridSeries tests. These fail at the moment. They need refining to check they are valid tests.

Location:
TI05-delivery/ows_framework/trunk/ows_server/ows_server/tests
Files:
3 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/tests/__init__.py

    r2476 r2594  
    3232        TestCase.__init__(self, *args) 
    3333 
     34 
     35 
     36# Generate test data 
     37import make_data 
     38make_data.main() 
     39 
    3440__all__ = ['url_for', 'TestController'] 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/tests/functional/test_csml_api.py

    r2494 r2594  
    11from ows_server.tests import * 
    22 
    3 class TestCsmlApiController(TestController): 
    4     def test_index(self): 
    5         response = self.app.get(url_for(controller='csml_api')) 
    6         # Test response... 
     3#class TestCsmlApiController(TestController): 
     4#    def test_index(self): 
     5#        response = self.app.get(url_for(controller='csml_api')) 
     6#        # Test response... 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/tests/functional/test_csml_wms.py

    r2501 r2594  
    11from ows_server.tests import * 
     2import cElementTree as ET 
     3from cStringIO import StringIO 
     4import Image 
    25 
    3 class TestCsmlWmsController(TestController): 
    4     def test_index(self): 
    5         response = self.app.get(url_for(controller='csml_wms')) 
    6         # Test response... 
     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 shoukd 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 TracChangeset for help on using the changeset viewer.