Changeset 2594 for TI05-delivery


Ignore:
Timestamp:
15/06/07 14:51:13 (12 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
Files:
4 added
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/csml_util.py

    r2593 r2594  
    3838    return d 
    3939 
    40 #THIS FUNCTION CAN BE DELETED AFTER extractToVariable HAS BEEN TESTED: 
    41 #---------------------------------------------------------------------------------------------------- 
    42 def extract(feature, sel): 
    43     # Get temporary extract dir 
    44     extract_dir = request.environ['paste.config']['app_conf']['tmp_dir'] 
    45      
    46     # Subset the feature 
    47     (fd, filename) = tempfile.mkstemp('.nc', 'csml_wms_', extract_dir); os.close(fd) 
    48     feature.subsetToGridSeries(ncname=os.path.basename(filename), 
    49                                outputdir=os.path.dirname(filename), 
    50                                time=sel['time'] # work around for CSML bug 
    51                                #**sel 
    52                                ) 
    53     d = cdms.open(filename) 
    54     #var = d(feature.name.CONTENT, squeeze=1) 
    55     # Work around for CSML bug 
    56     var = d(feature.name.CONTENT, longitude=sel['longitude'], latitude=sel['latitude'], 
    57             squeeze=1) 
    58  
    59     d.close() 
    60     os.remove(filename) 
    61     return var 
    62 #---------------------------------------------------------------------------------------------------- 
    6340         
    6441def extractToNetCDF(feature, sel): 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/render.py

    r2586 r2594  
    138138            img = img.transpose(Image.FLIT_LEFT_RIGHT) 
    139139 
    140         return img 
     140        return img.resize((width, height)) 
    141141 
    142142 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/validators.py

    r2578 r2594  
    3333        bbox_t = [float(x) for x in bbox.split(',')] 
    3434    except ValueError: 
    35         raise InvalidParameterValue("Incorrect BBOX specification %s" % bboxStr, 'bbox') 
     35        raise InvalidParameterValue("Incorrect BBOX specification %s" % bbox, 'bbox') 
    3636 
    3737    if len(bbox_t) != 4: 
    38         raise InvalidParameterValue("Incorrect BBOX specification %s" % bboxStr, 'bbox') 
     38        raise InvalidParameterValue("Incorrect BBOX specification %s" % bbox, 'bbox') 
    3939 
    4040    return bbox_t 
  • 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         
  • TI05-delivery/ows_framework/trunk/ows_server/test.ini

    r2476 r2594  
    1313use = egg:Paste#http 
    1414host = 0.0.0.0 
    15 port = 5000 
     15port = 8080 
    1616 
    1717[app:main] 
    1818use = config:development.ini 
     19csml_dir = %(here)s/ows_server/tests/data 
    1920 
    2021# Add additional test specific configuration options as necessary. 
Note: See TracChangeset for help on using the changeset viewer.