Ejemplo n.º 1
0
def test_get_extract_by_id(pyramid_test_config, params):
    with pyramid_test_config as pyramid_config:
        pyramid_config.add_renderer(
            'pyramid_oereb_extract_json',
            'pyramid_oereb.core.renderer.extract.json_.Renderer')
        request = MockRequest()
        request.matchdict.update({'format': 'JSON'})
        request.params.update(params)
        service = PlrWebservice(request)
        service.get_extract_by_id()
Ejemplo n.º 2
0
def test_return_no_content():
    request = MockRequest()
    request.matchdict.update({'format': 'XML'})
    request.params.update({'GEOMETRY': 'true', 'EGRID': 'MISSINGEGRID'})
    service = PlrWebservice(request)
    response = service.get_extract_by_id()
    assert isinstance(response, HTTPNoContent)
Ejemplo n.º 3
0
def test_format_url(real_estate_data):
    request = MockRequest()
    request.matchdict.update({'format': 'URL'})
    request.params.update({'EGRID': 'TEST'})
    service = PlrWebservice(request)
    response = service.get_extract_by_id()
    assert isinstance(response, HTTPFound)
    assert response.location == 'https://geoview.bl.ch/oereb/?egrid=TEST'
Ejemplo n.º 4
0
def test_mfp_service(mock_responses, pyramid_test_config,
                     real_estate_data,
                     municipalities, themes, real_estate_types_test_data, logos,
                     general_information
                     ):
    request = MockRequest()
    request.matchdict.update({
        'format': 'PDF'
    })
    request.params.update({
        # 'GEOMETRY': 'true',
        'EGRID': 'TEST',
        # 'TOPICS': topics
    })
    from pyramid_oereb.core.config import Config
    pyramid_test_config.add_renderer('pyramid_oereb_extract_print',
                                     Config.get('print').get('renderer'))
    service = PlrWebservice(request)
    response = service.get_extract_by_id()
    assert response.status_code == 200
Ejemplo n.º 5
0
def test_return_json(pyramid_oereb_test_config, pyramid_test_config,
                     schema_json_extract, egrid, topics,
                     extract_real_estate_data, main_schema, land_use_plans,
                     contaminated_sites):
    pyramid_test_config.add_renderer(
        'pyramid_oereb_extract_json',
        'pyramid_oereb.core.renderer.extract.json_.Renderer')
    request = MockRequest()
    request.matchdict.update({'format': 'JSON'})
    request.params.update({
        'GEOMETRY': 'true',
        'EGRID': egrid,
        'TOPICS': topics
    })
    service = PlrWebservice(request)
    response = service.get_extract_by_id()

    if topics == 'ALL' and egrid == 'TEST3':
        assert isinstance(response, HTTPNoContent)
        return
    Draft4Validator.check_schema(schema_json_extract)
    validator = Draft4Validator(schema_json_extract)
    response = json.loads(response.body.decode('utf-8'))
    validator.validate(response)

    assert isinstance(response, dict)

    extract = response.get('GetExtractByIdResponse').get('extract')
    real_estate = extract.get('RealEstate')

    assert isinstance(real_estate, dict)
    if topics == 'ALL' and egrid == 'TEST':
        assert len(real_estate.get('RestrictionOnLandownership')) == 2
        assert len(extract.get('ConcernedTheme')) == 2
        assert len(extract.get('NotConcernedTheme')) == 0
        assert len(extract.get('ThemeWithoutData')) == 0
        restrictions = real_estate.get('RestrictionOnLandownership')
        assert restrictions[0]['Theme']['Code'] == 'ch.Nutzungsplanung'
        assert restrictions[1]['Theme']['Code'] == 'ch.BelasteteStandorte'
        # simplified dataset, containing only two restrictions insetead of previously 14

    if topics == 'ALL_FEDERAL':
        assert len(real_estate.get('RestrictionOnLandownership')) == 2
        assert len(extract.get('ConcernedTheme')) == 2
        assert len(extract.get('NotConcernedTheme')) == 0
        assert len(extract.get('ThemeWithoutData')) == 0
        restrictions = real_estate.get('RestrictionOnLandownership')
        assert restrictions[0]['Theme']['Code'] == 'ch.Nutzungsplanung'
        assert restrictions[1]['Theme']['Code'] == 'ch.BelasteteStandorte'

    if topics == 'ch.BelasteteStandorte,ch.ProjektierungszonenEisenbahnanlagen':
        assert len(real_estate.get('RestrictionOnLandownership')) == 1
        assert len(extract.get('ConcernedTheme')) == 1
        assert len(extract.get('NotConcernedTheme')) == 0
        assert len(extract.get('ThemeWithoutData')) == 0
        restrictions = real_estate.get('RestrictionOnLandownership')
        assert restrictions[0]['Theme']['Code'] == 'ch.BelasteteStandorte'

    if topics == 'ALL' and egrid == 'TEST3':
        assert len(extract.get('ConcernedTheme')) == 3
        assert len(extract.get('NotConcernedTheme')) == 14
        assert len(extract.get('ThemeWithoutData')) == 0
        restrictions = real_estate.get('RestrictionOnLandownership')
        assert len(restrictions) == 4
        assert restrictions[1]['Theme'][
            'Code'] == 'ch.BaulinienNationalstrassen'
        assert restrictions[1]['Lawstatus']['Code'] == 'changeWithoutPreEffect'
        assert restrictions[2]['Theme'][
            'Code'] == 'ch.BaulinienNationalstrassen'
        assert restrictions[2]['Lawstatus']['Code'] == 'inForce'