Ejemplo n.º 1
0
    def test_numeric_hostname(self):
        # Base DAP URL
        b = rewrite_url('http://127.0.0.1:8001/etopo120.cdf')
        self.assertEqual(b, 'http://localhost/etopo120.cdf')

        # Base DAP URL plus pathspec
        b = rewrite_url('http://127.0.0.1:8001/foo/bar/baz/quux/etopo121.cdf')
        self.assertEqual(b, 'http://localhost/etopo121.cdf')
    def test_numeric_hostname(self):
        # Base DAP URL
        b = rewrite_url('http://127.0.0.1:8001/etopo120.cdf')
        self.assertEqual(b, 'http://localhost/etopo120.cdf')

        # Base DAP URL plus pathspec
        b = rewrite_url('http://127.0.0.1:8001/foo/bar/baz/quux/etopo121.cdf')
        self.assertEqual(b, 'http://localhost/etopo121.cdf')
    def test_pydap_urls(self):
        # Variable access, generated by pydap web interface
        b = rewrite_url('http://amoeba.ucsd.edu:8001/glacier.nc.ascii?var232%5B0:1:0%5D%5B0:1:0%5D%5B0:1:601%5D%5B0:1:401%5D&')
        self.assertEqual(b, 'http://localhost/glacier.nc.ascii?var232%5B0:1:0%5D%5B0:1:0%5D%5B0:1:601%5D%5B0:1:401%5D&')

        # Same thing, no port number
        b = rewrite_url('http://amoeba.ucsd.edu/glacier.nc.ascii?var232%5B0:1:0%5D%5B0:1:0%5D%5B0:1:601%5D%5B0:1:401%5D&')
        self.assertEqual(b, 'http://localhost/glacier.nc.ascii?var232%5B0:1:0%5D%5B0:1:0%5D%5B0:1:601%5D%5B0:1:401%5D&')
    def test_variable_access(self):
        b = rewrite_url('http://server.edu/cgi-bin/nph-dods/grid-data/temp2.dat.dds?g[20:21][40:42]')
        self.assertEqual(b, 'http://localhost/temp2.dat.dds?g[20:21][40:42]')

        b = rewrite_url('http://server.edu/grid-data/temp2.dat.das?grid[20:21][40:42]')
        self.assertEqual(b, 'http://localhost/temp2.dat.das?grid[20:21][40:42]')

        b = rewrite_url('http://server.edu/cgi-bin/nph-dods/grid-data/temp2.dat.dods?g[20:21][40:42]')
        self.assertEqual(b, 'http://localhost/temp2.dat.dods?g[20:21][40:42]')
    def test_ref_urls(self):
        # From DAP2 spec, Examples section
        b = rewrite_url('http://server.edu/cgi-bin/nph-dods/data/temp.dat.dds')
        self.assertEqual(b, 'http://localhost/temp.dat.dds')

        # DAS version
        b = rewrite_url('http://server.edu/cgi-bin/nph-dods/data/temp.dat.das')
        self.assertEqual(b, 'http://localhost/temp.dat.das')

        # DODS
        b = rewrite_url('http://server.edu/cgi-bin/nph-dods/data/temp.dat.dods')
        self.assertEqual(b, 'http://localhost/temp.dat.dods')
Ejemplo n.º 6
0
    def test_ref_urls(self):
        # From DAP2 spec, Examples section
        b = rewrite_url('http://server.edu/cgi-bin/nph-dods/data/temp.dat.dds')
        self.assertEqual(b, 'http://localhost/temp.dat.dds')

        # DAS version
        b = rewrite_url('http://server.edu/cgi-bin/nph-dods/data/temp.dat.das')
        self.assertEqual(b, 'http://localhost/temp.dat.das')

        # DODS
        b = rewrite_url(
            'http://server.edu/cgi-bin/nph-dods/data/temp.dat.dods')
        self.assertEqual(b, 'http://localhost/temp.dat.dods')
Ejemplo n.º 7
0
    def test_variable_access(self):
        b = rewrite_url(
            'http://server.edu/cgi-bin/nph-dods/grid-data/temp2.dat.dds?g[20:21][40:42]'
        )
        self.assertEqual(b, 'http://localhost/temp2.dat.dds?g[20:21][40:42]')

        b = rewrite_url(
            'http://server.edu/grid-data/temp2.dat.das?grid[20:21][40:42]')
        self.assertEqual(b,
                         'http://localhost/temp2.dat.das?grid[20:21][40:42]')

        b = rewrite_url(
            'http://server.edu/cgi-bin/nph-dods/grid-data/temp2.dat.dods?g[20:21][40:42]'
        )
        self.assertEqual(b, 'http://localhost/temp2.dat.dods?g[20:21][40:42]')
Ejemplo n.º 8
0
    def test_pydap_urls(self):
        # Variable access, generated by pydap web interface
        b = rewrite_url(
            'http://amoeba.ucsd.edu:8001/glacier.nc.ascii?var232%5B0:1:0%5D%5B0:1:0%5D%5B0:1:601%5D%5B0:1:401%5D&'
        )
        self.assertEqual(
            b,
            'http://localhost/glacier.nc.ascii?var232%5B0:1:0%5D%5B0:1:0%5D%5B0:1:601%5D%5B0:1:401%5D&'
        )

        # Same thing, no port number
        b = rewrite_url(
            'http://amoeba.ucsd.edu/glacier.nc.ascii?var232%5B0:1:0%5D%5B0:1:0%5D%5B0:1:601%5D%5B0:1:401%5D&'
        )
        self.assertEqual(
            b,
            'http://localhost/glacier.nc.ascii?var232%5B0:1:0%5D%5B0:1:0%5D%5B0:1:601%5D%5B0:1:401%5D&'
        )
Ejemplo n.º 9
0
    def op_get_url(self, content, headers, msg):
        """
        Rewrite the URL, forward the request to the DAP server
        """
        src_url = content
        new_url = rewrite_url(src_url)

        logging.debug('Old url: %s New url: %s' % (src_url, new_url))
        # Note that _http_op is inherited fetcher code...
        return self._http_op('GET', new_url, msg)
Ejemplo n.º 10
0
    def op_get_url(self, content, headers, msg):
        """
        Rewrite the URL, forward the request to the DAP server
        """
        src_url = content
        new_url = rewrite_url(src_url)

        logging.debug('Old url: %s New url: %s' % (src_url, new_url))
        # Note that _http_op is inherited fetcher code...
        return self._http_op('GET', new_url, msg)