def test_no_select(self): y = ''' buildings: types: - polygons ''' m, errors = Mapping.validate(y) self.assertTrue(m is None) self.assertTrue(len(errors) == 1)
def test_wrong_yaml_list(self): y = ''' buildings: types: polygons select: - building ''' m, errors = Mapping.validate(y) self.assertTrue(m is None) self.assertTrue(len(errors) == 1)
def test_wrong_toplevel_themes(self): y = ''' - buildings: types: - polygons select: - building ''' m, errors = Mapping.validate(y) self.assertTrue(m is None) self.assertTrue(len(errors) == 1)
def test_invalid_yaml_parse(self): y = ''' buildings: - types: - polygons select: - building ''' m, errors = Mapping.validate(y) self.assertTrue(m is None) self.assertTrue(len(errors) == 1)
def test_wrong_yaml_parse(self): y = ''' buildings: - types: - polygons - select: - building ''' m, errors = Mapping.validate(y) self.assertTrue(m is None) self.assertTrue(len(errors) == 1) self.assertTrue('must be YAML dict' in errors[0])
def test_invalid_sql(self): y = ''' buildings: types: - polygons select: - building where: XXX aaa ''' m, errors = Mapping.validate(y) self.assertTrue(m is None) self.assertTrue(len(errors) == 1)
def validate_feature_selection(value): from osm_export_tool.mapping import Mapping m, errors = Mapping.validate(value) if not m: raise ValidationError(errors)
def test_empty_yaml(self): y = ''' ''' m, errors = Mapping.validate(y) self.assertTrue(m is None) self.assertTrue(len(errors) == 1)