def test_read_with_specified_language():
    with requests_mock.mock() as m:
        with open('./tests/resources/geolink_v1.1.1.xml', 'rb') as f:
            m.get('http://oereblex.example.com/api/geolinks/100.xml?locale=fr', content=f.read())
        source = OEREBlexSource(host='http://oereblex.example.com', language='de', canton='BL')
        params = MockParameter()
        params.set_language('fr')
        source.read(params, 100)
        assert len(source.records) == 2
        document = source.records[0]
        assert document.responsible_office.name == {'fr': 'Landeskanzlei'}
        assert document.text_at_web == {
            'fr': 'http://oereblex.example.com/api/attachments/313'
        }
예제 #2
0
def test_read_with_specified_language(oereblex_test_config):
    with requests_mock.mock() as m:
        with open('./tests/resources/geolink_v1.2.2.xml', 'rb') as f:
            m.get('http://oereblex.example.com/api/geolinks/100.xml?locale=fr',
                  content=f.read())
        source = OEREBlexSource(
            host='http://oereblex.example.com',
            language='de',
            canton='BL',
            version='1.2.2',
            code='ch.Waldabstandslinien',
        )
        params = MockParameter()
        params.set_language('fr')
        source.read(params, 100)
        assert len(source.records) == 9
        document = source.records[0]
        assert document.responsible_office.name == {
            'fr': 'Bauverwaltung Gemeinde'
        }
        assert document.text_at_web == {
            'fr': 'http://oereblex.example.com/api/attachments/4735'
        }
        assert document.index == 30