Beispiel #1
0
def test_sub_theme():
    parameters = Parameter(
        response_format='xml',
        flavour='reduced',
        with_geometry=False,
        images=True,
        identdn='BL0200002829',
        number='1000',
        egrid='CH775979211712',
        language='de')
    renderer = Renderer(DummyRenderInfo())
    renderer._language = u'de'
    renderer._request = MockRequest()
    renderer._request.route_url = lambda url, **kwargs: "http://example.com/current/view"
    legend_entry = LegendEntryRecord(
        symbol=ImageRecord('1'.encode('utf-8')),
        legend_text={'de': 'legend1'},
        type_code='LandUsePlans',
        type_code_list='bla',
        theme=ThemeRecord(u'LandUsePlans', {'de': 'Theme 1'}),
        sub_theme={'de': 'sub theme de'}
    )
    content = template.render(**{
        'params': parameters,
        'localized': renderer.get_localized_text,
        'multilingual': renderer.get_multilingual_text,
        'legend_entry': legend_entry
    }).decode('utf-8').split('\n')
    no_empty_lines = list(filter(lambda line: line != '', content))
    assert no_empty_lines[19] == '<data:SubTheme>sub theme de</data:SubTheme>'
    assert len(no_empty_lines) == 20
Beispiel #2
0
def test_extract_against_schema(parameter, test_extract):
    extract = test_extract
    renderer = Renderer(DummyRenderInfo())
    renderer._language = u'de'
    renderer._request = MockRequest()
    renderer._request.route_url = lambda url, **kwargs: "http://example.com/current/view"
    rendered = renderer._render(extract, parameter)

    xmlschema_doc = etree.parse(schema_xml_extract)
    xmlschema = etree.XMLSchema(xmlschema_doc)
    buffer = BytesIO(rendered)
    doc = etree.parse(buffer)
    xmlschema.assertValid(doc)
def test_sub_theme():
    parameters = Parameter(flavour='reduced',
                           format='xml',
                           geometry=False,
                           images=True,
                           identdn='BL0200002829',
                           number='1000',
                           egrid='CH775979211712',
                           language='de')
    renderer = Renderer(DummyRenderInfo())
    renderer._language = u'de'
    renderer._request = MockRequest()
    renderer._request.route_url = lambda url, **kwargs: "http://example.com/current/view"
    office = OfficeRecord(name={'de': 'office de'})
    law_status = LawStatusRecord(code='runningModifications',
                                 text={'de': 'law status de'})
    geometry = GeometryRecord(law_status,
                              datetime.now(),
                              Polygon(),
                              'test',
                              office=office)
    public_law_restriction = PlrRecord(
        theme=ThemeRecord(u'LandUsePlans', {'de': 'Theme 1'}),
        information={'de': 'information de'},
        law_status=law_status,
        published_from=datetime.now(),
        responsible_office=office,
        symbol=ImageRecord('1'.encode('utf-8')),
        view_service=ViewServiceRecord(reference_wms='',
                                       layer_index=0,
                                       layer_opacity=1.0),
        geometries=[geometry],
        sub_theme={'de': 'sub theme de'})
    content = template.render(
        **{
            'params': parameters,
            'localized': renderer.get_localized_text,
            'multilingual': renderer.get_multilingual_text,
            'public_law_restriction': public_law_restriction
        }).decode('utf-8').split('\n')
    no_empty_lines = list(filter(lambda line: line != '', content))
    assert no_empty_lines[
        18] == '    <data:SubTheme>sub theme de</data:SubTheme>'
    assert len(no_empty_lines) == 72