Changeset 1068

Show
Ignore:
Timestamp:
04/02/08 05:15:42
Author:
domlowe
Message:

reinstated content metadata in WMS and fixed telacapabilities test

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OWSLib/branches/wcstemp/owslib/wms.py

    r1042 r1068  
    209209                self.abstract = None 
    210210        self.keywords = [f.text for f in self._root.findall('KeywordList/Keyword')] 
    211         self.accessconstraints = self._root.find('AccessConstraints').text 
    212         self.fees = self._root.find('Fees').text 
     211        accessconstraints=self._root.find('AccessConstraints') 
     212        if accessconstraints is not None: 
     213            self.accessconstraints = accessconstraints.text 
     214        fees = self._root.find('Fees') 
     215        if fees is not None: 
     216            self.fees = fees.text 
    213217              
    214218class ServiceProvider(object): 
     
    218222        self.name=self._root.find('ContactInformation/ContactPersonPrimary/ContactOrganization').text 
    219223        self.url=self._root.find('OnlineResource').attrib.get('{http://www.w3.org/1999/xlink}href', '') 
    220         self.contact=self._root.find('ContactInformation/ContactElectronicMailAddress').text 
    221          
     224        #contact metadata 
     225        contact = self._root.find('ContactInformation') 
     226        ## sometimes there is a contact block that is empty, so make 
     227        ## sure there are children to parse 
     228        if contact is not None and contact.getchildren(): 
     229            self.contact = ContactMetadata(contact) 
     230        else: 
     231            self.contact = None 
     232             
    222233class ContentMetadata: 
    223234        """ 
  • OWSLib/branches/wcstemp/tests/TelaCapabilities.txt

    r1061 r1068  
    1212Test capabilities 
    1313 
    14     >>> wms.capabilities.servic
     14    >>> wms.identification.typ
    1515    'OGC:WMS' 
    1616 
    17     >>> wms.capabilities.title 
     17    >>> wms.identification.title 
    1818    'BM' 
    1919 
    20     >>> wms.capabilities.abstract 
     20    >>> wms.identification.abstract 
    2121    'Blue Marble 200409' 
    2222     
    23     >>> wms.capabilities.link 
     23    >>> wms.provider.url 
    2424    'http://wms.telascience.org/cgi-bin/ngBM_wms?' 
    2525     
    26     >>> wms.capabilities.keywords 
     26    >>> wms.identification.keywords 
    2727    [] 
    2828 
    29     >>> p = wms.capabilities.provider 
     29    >>> p = wms.provider.contact 
    3030    >>> p.name 
    3131    'Norman Vine' 
     
    3535Test available content layers 
    3636 
    37     >>> [layer.name for layer in wms.capabilities.contents] 
    38     ['world.topo.bathy.200409', 'USGS_1ft_San_Diego'] 
     37    >>> wms.contents.keys() 
     38    ['USGS_1ft_San_Diego', 'world.topo.bathy.200409', 'ngBM'] 
     39 
    3940     
    40     >>> [layer.title for layer in wms.capabilities.contents] 
    41     ['world.topo.bathy.200409', 'USGS 1ft San Diego'] 
     41    >>> [wms[layer].title for layer in wms.contents] 
     42    ['USGS 1ft San Diego', 'world.topo.bathy.200409', 'BM'] 
     43 
    4244     
    4345Test single item accessor 
    4446 
    45     >>> wms.capabilities.getContentByName('world.topo.bathy.200409').title 
     47    >>> wms['world.topo.bathy.200409'].title 
    4648    'world.topo.bathy.200409' 
    4749     
    48     >>> wms.capabilities.getContentByName('world.topo.bathy.200409').boundingBox 
     50    >>> wms['world.topo.bathy.200409'].boundingBox 
    4951    (-180.0, -90.0, 180.0, 90.0, 'EPSG:4326') 
    5052     
    51     >>> wms.capabilities.getContentByName('world.topo.bathy.200409').boundingBoxWGS84 
     53    >>> wms['world.topo.bathy.200409'].boundingBoxWGS84 
    5254    (-180.0, -90.0, 180.0, 90.0) 
    5355     
    54     >>> wms.capabilities.getContentByName('world.topo.bathy.200409').crsOptions 
    55     ['EPSG:4326'] 
     56    >>> wms['world.topo.bathy.200409'].crsOptions 
     57    ['init=epsg:4326'] 
    5658     
    57     >>> wms.capabilities.getContentByName('world.topo.bathy.200409').styles 
     59    >>> wms['world.topo.bathy.200409'].styles 
    5860    {} 
    5961     
    6062Expect a KeyError for invalid names 
    6163 
    62     >>> wms.capabilities.getContentByName('utterly bogus').title 
     64    >>> wms['utterly bogus'].title 
    6365    Traceback (most recent call last): 
    6466    ... 
     
    6769Test operations 
    6870 
    69     >>> [op.name for op in wms.capabilities.operations] 
     71    >>> [op.name for op in wms.operations] 
    7072    ['GetCapabilities', 'GetMap', 'GetFeatureInfo', 'DescribeLayer', 'GetLegendGraphic'] 
    7173     
    72     >>> wms.capabilities.getOperationByName('GetMap').methods 
     74    >>> wms.getOperationByName('GetMap').methods 
    7375    {'Post': {'url': 'http://wms.telascience.org/cgi-bin/ngBM_wms?'}, 'Get': {'url': 'http://wms.telascience.org/cgi-bin/ngBM_wms?'}} 
    7476     
    75     >>> wms.capabilities.getOperationByName('GetMap').formatOptions 
     77    >>> wms.getOperationByName('GetMap').formatOptions 
    7678    ['image/gif', 'image/png', 'image/jpeg', 'image/wbmp', 'image/tiff', 'image/png; mode=24bit'] 
    7779 
    7880Test exceptions 
    7981 
    80     >>> wms.capabilities.exceptions 
     82    >>> wms.exceptions 
    8183    ['application/vnd.ogc.se_xml', 'application/vnd.ogc.se_inimage', 'application/vnd.ogc.se_blank'] 
    8284 
  • OWSLib/branches/wcstemp/tests/wms_JPLCapabilities.txt

    r1042 r1068  
    3131    >>> wms.provider.url 
    3232    'http://OnEarth.jpl.nasa.gov/index.html' 
    33     >>> wms.provider.contact 
     33 
     34Check contact info (some of it is missing) 
     35    >>> wms.provider.contact.name 
     36    'Lucian Plesea' 
     37    >>> wms.provider.contact.email 
    3438    'lucian.plesea@jpl.nasa.gov' 
     39    >>> wms.provider.contact.address 
     40    >>> wms.provider.contact.city 
     41    >>> wms.provider.contact.country 
     42    >>> wms.provider.contact.region 
     43    >>> wms.provider.contact.postcode 
     44    >>> wms.provider.contact.organization 
     45    'JPL' 
     46    >>> wms.provider.contact.position 
    3547 
    3648