def test_fixed_values(self): template = CouchDBMDTemplate({'hello': 'world', 'foo': 123}) doc = template.doc(Tile((0, 0, 1)), tile_grid(4326)) assert_almost_equal(doc['timestamp'], time.time(), 2) eq_(doc['hello'], 'world') eq_(doc['foo'], 123)
def test_fixed_values(self): template = CouchDBMDTemplate({'hello': 'world', 'foo': 123}) doc = template.doc(Tile((0, 0, 1)), tile_grid(4326)) assert doc['timestamp'] == pytest.approx(time.time(), 0.1) assert doc['hello'] == 'world' assert doc['foo'] == 123
def test_template_values(self): template = CouchDBMDTemplate({'row': '{{y}}', 'tile_column': '{{x}}', 'zoom': '{{level}}', 'time': '{{timestamp}}', 'coord': '{{wgs_tile_centroid}}', 'datetime': '{{utc_iso}}', 'coord_webmerc': '{{tile_centroid}}'}) doc = template.doc(Tile((1, 0, 2)), tile_grid(3857)) assert_almost_equal(doc['time'], time.time(), 2) assert 'timestamp' not in doc eq_(doc['row'], 0) eq_(doc['tile_column'], 1) eq_(doc['zoom'], 2) assert_almost_equal(doc['coord'][0], -45.0) assert_almost_equal(doc['coord'][1], -79.17133464081945) assert_almost_equal(doc['coord_webmerc'][0], -5009377.085697311) assert_almost_equal(doc['coord_webmerc'][1], -15028131.257091932) assert re.match('20\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ', doc['datetime']), doc['datetime']
def create_couchdb_export_cache(export_path, db_name, file_ext, couchdb_port, app_state): md_template = CouchDBMDTemplate({}) cache_dir = app_state.user_temp_dir() url = 'http://%s:%s' % ('127.0.0.1', couchdb_port) return CouchDBCache(url=url, db_name=db_name, md_template=md_template, lock_dir=cache_dir, file_ext=file_ext, tile_grid=DEFAULT_GRID)
def create_couchdb_cache(app_state, task=False, layer=False): cache_dir = app_state.user_temp_dir() if task: db_name = task.layer.name file_ext = task.source.format if layer: gbi_server = layer.gbi_server if gbi_server is not None: gbi_server.app_state = app_state db_name = gbi_server.raster_prefix + layer.name else: db_name = "%s_%s_%s" % (layer.prefix, app_state.config.get( 'app', 'raster_prefix'), layer.name) file_ext = layer.format port = app_state.config.get('couchdb', 'port') url = 'http://127.0.0.1:%s' % (port, ) md_template = CouchDBMDTemplate({}) return CouchDBCache(url=url, db_name=db_name, md_template=md_template, lock_dir=cache_dir, file_ext=file_ext, tile_grid=DEFAULT_GRID)
def create_couchdb_cache(wmts_source, app_state): cache_dir = app_state.user_temp_dir() db_name = wmts_source.name file_ext = wmts_source.format port = app_state.config.get('couchdb', 'port') url = 'http://127.0.0.1:%s' % (port, ) md_template = CouchDBMDTemplate({}) return CouchDBCache(url=url, db_name=db_name, md_template=md_template, lock_dir=cache_dir, file_ext=file_ext, tile_grid=DEFAULT_GRID)
def setup(self): if not os.environ.get('MAPPROXY_TEST_COUCHDB'): raise SkipTest() couch_address = os.environ['MAPPROXY_TEST_COUCHDB'] db_name = 'mapproxy_test_%d' % random.randint(0, 100000) TileCacheTestBase.setup(self) md_template = CouchDBMDTemplate({'row': '{{y}}', 'tile_column': '{{x}}', 'zoom': '{{level}}', 'time': '{{timestamp}}', 'coord': '{{wgs_tile_centroid}}'}) self.cache = CouchDBCache(couch_address, db_name, file_ext='png', tile_grid=tile_grid(3857, name='global-webmarcator'), md_template=md_template)
def test_template_values(self): template = CouchDBMDTemplate({ 'row': '{{y}}', 'tile_column': '{{x}}', 'zoom': '{{level}}', 'time': '{{timestamp}}', 'coord': '{{wgs_tile_centroid}}', 'datetime': '{{utc_iso}}', 'coord_webmerc': '{{tile_centroid}}' }) doc = template.doc(Tile((1, 0, 2)), tile_grid(3857)) assert doc['time'] == pytest.approx(time.time(), 0.1) assert 'timestamp' not in doc assert doc['row'] == 0 assert doc['tile_column'] == 1 assert doc['zoom'] == 2 assert doc['coord'][0] == pytest.approx(-45.0) assert doc['coord'][1] == pytest.approx(-79.17133464081945) assert doc['coord_webmerc'][0] == pytest.approx(-5009377.085697311) assert doc['coord_webmerc'][1] == pytest.approx(-15028131.25709193) assert re.match(r'20\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ', doc['datetime']), doc['datetime']
def test_empty(self): template = CouchDBMDTemplate({}) doc = template.doc(Tile((0, 0, 1)), tile_grid(4326)) assert_almost_equal(doc['timestamp'], time.time(), 2)
def test_empty(self): template = CouchDBMDTemplate({}) doc = template.doc(Tile((0, 0, 1)), tile_grid(4326)) assert doc['timestamp'] == pytest.approx(time.time(), 0.1)