Example #1
0
def test_get_extension_bad():
    params = {'data-format': 'unsupported_extension'}
    req = Request.blank('?' + urlencode(params))
    assert get_extension(req.environ) == None

    # data-format not in the request params
    req = Request.blank('')
    assert get_extension(req.environ) == None
Example #2
0
    def __call__(self, environ, start_response):
        '''Fire off pydap requests and return an iterable (from :func:`ziperator`)'''
        req = Request(environ)
        form = req.params
        climo = True if 'download-climatology' in form else False

        filters = validate_vars(environ)
        stns = get_stn_list(self.session, filters)

        ext = get_extension(environ)
        if not ext:
            return HTTPBadRequest("Requested extension not supported")(environ, start_response)
                
        status = '200 OK'
        response_headers = [('Content-type','application/zip'), ('Content-Disposition', 'filename="pcds_data.zip"')]
        start_response(status, response_headers)
        environ['pydap.handlers.pcic.dsn'] = self.dsn

        responders = chain(get_all_metadata_index_responders(self.session, stns, climo),
                           get_pcds_responders(self.dsn, stns, ext, get_clip_dates(environ), environ)
                           )

        return ziperator(responders)
Example #3
0
def test_get_extension_good():
    params = {'data-format': 'csv'}
    req = Request.blank('?' + urlencode(params))
    assert get_extension(req.environ) == 'csv'