Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_helpers(self):
"should be defined"
assert helpers.color_continuous_layer is not None
def test_size_category_layer(self):
"should create a layer with the proper attributes"
Source._get_geom_type = Mock(return_value='point')
layer = helpers.size_category_layer(
source='sf_neighborhoods',
value='name',
title='Neighborhoods'
)
self.assertNotEqual(layer.style, None)
self.assertEqual(layer.style._style['point']['width'], 'ramp(top($name, 5), [2, 20])')
self.assertEqual(layer.style._style['line']['width'], 'ramp(top($name, 5), [1, 10])')
self.assertEqual(layer.style._style['point']['color'], 'opacity(#F46D43, 0.8)')
self.assertEqual(layer.style._style['line']['color'], 'opacity(#4CC8A3, 0.8)')
self.assertNotEqual(layer.popup, None)
self.assertEqual(layer.popup._hover, [{
'title': 'Neighborhoods',
'value': '$name'
}])
def test_color_continuous_layer_popup(self):
"should show/hide the popup"
layer = helpers.color_continuous_layer(
'sf_neighborhoods',
'name',
popup=False
)
self.assertEqual(layer.popup._hover, [])
layer = helpers.color_continuous_layer(
'sf_neighborhoods',
'name',
popup=True
)
self.assertEqual(layer.popup._hover, [{
'title': 'name',
'value': '$name'
}])
def test_size_category_layer_animate(self, mocker):
"should animate a property and disable the popups"
setup_mocks(mocker)
layer = helpers.size_category_layer(
self.source,
'name',
animate='time'
)
assert layer.popup._hover == []
assert layer.widgets._widgets[0]._type == 'time-series'
assert layer.widgets._widgets[0]._title == 'Animation'
assert layer.widgets._widgets[0]._value == 'time'
def test_size_continuous_layer_popup(self):
"should show/hide the popup"
layer = helpers.size_continuous_layer(
'sf_neighborhoods',
'name',
popup=False
)
self.assertEqual(layer.popup._hover, [])
layer = helpers.size_continuous_layer(
'sf_neighborhoods',
'name',
popup=True
)
self.assertEqual(layer.popup._hover, [{
'title': 'name',
'value': '$name'
}])
def test_color_continuous_layer_point(self, mocker):
"should create a point type layer"
setup_mocks(mocker)
layer = helpers.color_continuous_layer(
self.source,
'name',
'Neighborhoods',
palette='prism'
)
assert layer.style._style['point']['color'] == 'opacity(ramp(linear($name, ' + \
'globalMIN($name), globalMAX($name)), prism), 1)'
def test_helpers(self):
"should be defined"
assert helpers.color_bins_layer is not None
def test_cluster_size_layer(self):
"should create a layer with the proper attributes"
Source._get_geom_type = Mock(return_value='point')
layer = helpers.cluster_size_layer(
source='sf_neighborhoods',
value='name'
)
self.assertNotEqual(layer.style, None)
self.assertEqual(
layer.style._style['point']['width'],
'ramp(linear(clusterCount(), viewportMIN(clusterCount()), viewportMAX(clusterCount())), [4.0, 16.0, 32])'
)
self.assertEqual(layer.style._style['point']['color'],
'opacity(#FFB927, 0.8)')
self.assertEqual(layer.style._style['point']['strokeColor'],
'opacity(#222,ramp(linear(zoom(),0,18),[0,0.6]))')
self.assertEqual(layer.style._style['point']['filter'], '1')
self.assertEqual(layer.style._style['point']['resolution'], '32')
self.assertNotEqual(layer.popup, None)
def test_helpers(self):
"should be defined"
self.assertNotEqual(helpers.size_continuous_layer, None)
def test_helpers(self):
"should be defined"
assert helpers.cluster_size_layer is not None