def glc(): # glc: Geonotebook Layer Collection foo = layers.GeonotebookLayer('foo', None, None, vis_url='vis') bar = layers.GeonotebookLayer('bar', None, None, vis_url='vis') baz = layers.GeonotebookLayer('baz', None, None, vis_url='vis') return layers.GeonotebookLayerCollection([foo, bar, baz])
def test_layer_collection_append_exposed_layer(glc): pre_length = len(glc) l = layers.GeonotebookLayer('test_layer', None, None, expose_as='test') glc.append(l) # Expose_as is not just for system layers assert glc['test_layer'] == l assert pre_length == len(glc) - 1 assert glc.test == l
def test_layer_collection_append_system_layer(glc): pre_length = len(glc) l = layers.GeonotebookLayer('test_layer', None, None, system_layer=True) glc.append(l) # System layers don't show up in length assert len(glc) == pre_length # System layers are not accessible via key index with pytest.raises(KeyError): glc['test_layer']
def test_layer_reprs(visserver): assert str(layers.GeonotebookLayer('gnbl', None, None)) == \ "<GeonotebookLayer('gnbl')>" assert str(layers.AnnotationLayer('al', None, None)) == \ "<AnnotationLayer('al')>" assert str(layers.NoDataLayer('ndl', None, None)) == "<NoDataLayer('ndl')>" assert str(layers.DataLayer('dl', None, None, vis_url='bogus')) == \ "<DataLayer('dl')>" assert str(layers.SimpleLayer('sl', None, None, vis_url='bogus')) == \ "<SimpleLayer('sl')>" assert str( layers.TimeSeriesLayer('tsl', None, [RDMock(name='bogus_data')]) ) == \ "<TimeSeriesLayer('tsl')>"
def geonotebook_layer(): return layers.GeonotebookLayer('foo', None, None, vis_url='vis')
def test_layer_collection_append_same_layer(glc): l = layers.GeonotebookLayer('test_layer', None, None) glc.append(l) with pytest.raises(Exception): glc.append(l)
def test_layer_collection_append_layer(glc): l = layers.GeonotebookLayer('test_layer', None, None) glc.append(l) assert glc['test_layer'] == l assert glc[-1] == l
def test_layer_collection_setitem_with_system_layer(glc): l = layers.GeonotebookLayer('test_layer', None, None, system_layer=True) with pytest.raises(Exception): glc['test_layer'] = l
def test_layer_collection_setitem_with_int(glc): l = layers.GeonotebookLayer('test_layer', None, None) glc[0] = l assert glc.find("foo") == l assert glc[0] == l
def test_layer_collection_append_exposed_layer_bad_attr(glc): l = layers.GeonotebookLayer('test_layer', None, None, expose_as='_layers') with pytest.raises(RuntimeError): glc.append(l)