def test_format_document(params, document, result_dict): renderer = Renderer(DummyRenderInfo()) renderer._language = u'de' renderer._params = params result = renderer.format_document(document) assert isinstance(result, dict) assert result == result_dict
def test_format_real_estate(config): assert isinstance(config._config, dict) renderer = Renderer(DummyRenderInfo()) renderer._language = u'de' renderer._params = Parameter( 'reduced', 'json', True, False, 'BL0200002829', '1000', 'CH775979211712', 'de') geometry = MultiPolygon([Polygon([(0, 0), (1, 1), (1, 0)])]) view_service = ViewServiceRecord(u'http://geowms.bl.ch', u'http://geowms.bl.ch') document = DocumentRecord(law_status(), datetime.date.today(), {u'de': u'Test Dokument'}, OfficeRecord({u'de': u'BUD'}), {'de': 'http://mein.dokument.ch'}) real_estate = RealEstateRecord(u'RealEstate', u'BL', u'Liestal', 2829, 11395, geometry, u'http://www.geocat.ch', u'1000', u'BL0200002829', u'CH775979211712', u'Subunit', [], references=[document]) real_estate.plan_for_land_register = view_service result = renderer.format_real_estate(real_estate) assert isinstance(result, dict) assert result == { 'Type': u'RealEstate', 'Canton': u'BL', 'Municipality': u'Liestal', 'FosNr': 2829, 'LandRegistryArea': 11395, 'PlanForLandRegister': renderer.format_map(view_service), 'Limit': renderer.from_shapely(geometry), 'Number': u'1000', 'IdentDN': u'BL0200002829', 'EGRID': u'CH775979211712', 'SubunitOfLandRegister': u'Subunit', 'MetadataOfGeographicalBaseData': u'http://www.geocat.ch', 'Reference': [renderer.format_document(document)] }
def test_format_plr(parameter): with pyramid_oereb_test_config(): renderer = Renderer(DummyRenderInfo()) renderer._language = 'de' renderer._params = parameter renderer._request = MockRequest() document = DocumentRecord('Law', law_status(), datetime.date.today(), {u'de': u'Test Dokument'}, OfficeRecord({u'de': u'BUD'}), {'de': 'http://mein.dokument.ch'}) if parameter.flavour == 'reduced': documents = [document] else: documents = None theme = ThemeRecord(u'ContaminatedSites', {u'de': u'Test theme'}) office = OfficeRecord({'de': 'Test Office'}) legend_entry = LegendEntryRecord(ImageRecord( base64.b64encode('1'.encode('utf-8'))), {'de': 'Test'}, 'CodeA', 'TypeCodeList', theme, view_service_id=1) view_service = ViewServiceRecord('http://geowms.bl.ch', 1, 1.0, {'de': u'http://geowms.bl.ch'}, [legend_entry]) geometry = GeometryRecord(law_status(), datetime.date.today(), Point(1, 1)) plr = PlrRecord(theme, {'de': 'Test'}, law_status(), datetime.date.today(), office, ImageRecord('1'.encode('utf-8')), view_service, [geometry], sub_theme={'de': 'Subtopic'}, other_theme='Additional topic', type_code='CodeA', type_code_list='TypeCodeList', documents=documents, view_service_id=1) plr.part_in_percent = 0.5 if parameter.flavour == 'full': with pytest.raises(ValueError): renderer.format_plr([plr]) else: result = renderer.format_plr([plr]) assert isinstance(result, list) assert len(result) == 1 assert isinstance(result[0], dict) expected = { 'Information': renderer.get_multilingual_text(plr.information), 'Theme': renderer.format_theme(plr.theme), 'Lawstatus': { 'Code': 'inForce', 'Text': { 'Language': 'de', 'Text': 'In Kraft' } }, 'ResponsibleOffice': renderer.format_office(plr.responsible_office), 'Map': renderer.format_map(plr.view_service), 'SubTheme': 'Subtopic', 'OtherTheme': 'Additional topic', 'TypeCode': 'CodeA', 'TypeCodelist': 'TypeCodeList', 'LegalProvisions': [renderer.format_document(document)], 'PartInPercent': 0.5 } if parameter.images: expected.update({ 'Symbol': base64.b64encode('1'.encode('utf-8')).decode('ascii') }) else: expected.update({ 'SymbolRef': 'http://example.com/image/symbol/{theme}/{view_service_id}/{code}' .format(theme='ContaminatedSites', view_service_id=1, code='CodeA') }) assert result[0] == expected