Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def testCreateClasses(self):
classes = style.construct_classes(self.classes, self.properties)
self.assertEqual(classes, [u'apple_fruit'])
classes = style.construct_classes(self.classes, {'apple': u'fruit'})
self.assertEqual(classes, [u'apple_fruit'])
classes = style.construct_classes(self.classes, {'apple': u'früit'})
self.assertEqual(classes, [u'apple_früit'])
classes = style.construct_classes(self.classes, {'apple': 1})
self.assertEqual(classes, [u'apple_1'])
def testCreateClasses(self):
classes = style.construct_classes(self.classes, self.properties)
self.assertEqual(classes, [u'apple_fruit'])
classes = style.construct_classes(self.classes, {'apple': u'fruit'})
self.assertEqual(classes, [u'apple_fruit'])
classes = style.construct_classes(self.classes, {'apple': u'früit'})
self.assertEqual(classes, [u'apple_früit'])
classes = style.construct_classes(self.classes, {'apple': 1})
self.assertEqual(classes, [u'apple_1'])
def testCreateClassesMissing(self):
classes = style.construct_classes(self.classes, {'apple': ''})
self.assertEqual(classes, [u'apple_'])
classes = style.construct_classes(self.classes, {'apple': None})
self.assertEqual(classes, [u'apple_None'])
def testConstructClasses(self):
self.assertEqual(style.construct_classes(('foo',), {'foo': 'bar'}), [u'foo_bar'])
self.assertEqual(style.construct_classes(['foo'], {'foo': 'bar'}), [u'foo_bar'])
self.assertEqual(style.construct_classes(['foo'], {'foo': None}), [u'foo_None'])
if geom is None:
raise ValueError('NULL geometry')
# Apply transformations to the geometry.
for t in transforms:
geom = t(geom) if t is not None else geom
except ValueError as e:
self.log.warning('error transforming feature %s of %s: %s',
kwargs.get('id', feature.get('id', '?')), name, e)
return ''
# Set up the element's properties.
drawargs = _style.construct_datas(datas, feature['properties'])
classes = _style.construct_classes(classes, feature['properties'])
# Add the layer name to the class list.
if name != '?':
classes.insert(0, _style.sanitize(name))
drawargs['class'] = ' '.join(classes)
if 'id_field' in kwargs and kwargs['id_field'] in feature['properties']:
drawargs['id'] = _style.sanitize(feature['properties'].get(kwargs['id_field']))
try:
# Draw the geometry.
return draw.geometry(geom, precision=precision, **drawargs)
except errors.SvgisError as e:
self.log.warning('unable to draw feature %s of %s: %s',