예제 #1
0
    def test_search_gziptext_cache(self, gziptext_cache):
        """Test the search method with strange character in the output.

        Test whether the output has the correct encoding, both with and
        without using the cache.

        Parameters
        ----------
        gziptext_cache : pytest.fixture providing
                pydov.util.caching.GzipTextFileCache
            GzipTextFileCache using a temporary directory and a maximum age
            of 1 second.

        """
        boringsearch = BoringSearch()
        query = PropertyIsEqualTo(
            propertyname='pkey_boring',
            literal=build_dov_url('data/boring/1928-031159'))

        df = boringsearch.search(query=query,
                                 return_fields=('pkey_boring', 'uitvoerder',
                                                'mv_mtaw'))

        assert df.uitvoerder[0] == u'Societé Belge des Bétons'

        assert os.path.exists(os.path.join(
            gziptext_cache.cachedir, 'boring', '1928-031159.xml.gz'))

        df = boringsearch.search(query=query,
                                 return_fields=('pkey_boring', 'uitvoerder',
                                                'mv_mtaw'))

        assert df.uitvoerder[0] == u'Societé Belge des Bétons'
예제 #2
0
    def test_wfs_only(self, force_rebuild_wfs, test_hook_count):
        """Test the search method providing both a location and a query.

        Test whether a dataframe is returned.

        Parameters
        ----------
        force_rebuild_wfs : pytest.fixture
            Fixture removing cached WFS capabilities document.
        test_hook_count : pytest.fixture
            Fixture removing default hooks and installing HookCounter.

        """
        query = PropertyIsEqualTo(propertyname='boornummer',
                                  literal='GEO-04/169-BNo-B1')

        boringsearch = BoringSearch()
        boringsearch.search(query=query,
                            return_fields=('pkey_boring', 'x', 'y'))

        assert pydov.hooks[0].count_wfs_search_init == 1
        assert pydov.hooks[0].count_wfs_search_result == 1
        assert pydov.hooks[0].count_wfs_search_result_received == 1
        assert pydov.hooks[0].count_inject_wfs_getfeature_response == 1

        assert pydov.hooks[0].count_xml_received == 0
        assert pydov.hooks[0].count_inject_xml_response == 0
        assert pydov.hooks[0].count_xml_cache_hit == 0
        assert pydov.hooks[0].count_xml_downloaded == 0

        assert pydov.hooks[0].count_meta_received > 0
        assert pydov.hooks[0].count_inject_meta_response > 0
예제 #3
0
    def test_wfs_only(self, temp_hooks):
        """Test the search method providing both a location and a query.

        Test whether a dataframe is returned.

        Parameters
        ----------
        mp_remote_describefeaturetype : pytest.fixture
            Monkeypatch the call to a remote DescribeFeatureType of the
            dov-pub:Boringen layer.
        mp_remote_wfs_feature : pytest.fixture
            Monkeypatch the call to get WFS features.
        temp_hooks : pytest.fixture
            Fixture removing default hooks and installing HookCounter.

        """
        query = PropertyIsEqualTo(propertyname='boornummer',
                                  literal='GEO-04/169-BNo-B1')

        boringsearch = BoringSearch()
        df = boringsearch.search(query=query,
                                 return_fields=('pkey_boring', 'x', 'y'))

        assert pydov.hooks[0].count_wfs_search_init == 1
        assert pydov.hooks[0].count_wfs_search_result == 1
        assert pydov.hooks[0].count_xml_requested == 0
        assert pydov.hooks[0].count_xml_cache_hit == 0
        assert pydov.hooks[0].count_xml_downloaded == 0
예제 #4
0
    def test_hooks(self, test_hook_types):
        """Test the argument types of the hook events.

        Parameters
        ----------
        test_hook_types : pytest.fixture
            Fixture removing default hooks and installing HookTester.

        """
        query = PropertyIsEqualTo(propertyname='boornummer',
                                  literal='GEO-04/169-BNo-B1')

        boringsearch = BoringSearch()
        boringsearch.search(query=query)
예제 #5
0
    def test_search(self, nocache):
        """Test the search method with strange character in the output.

        Test whether the output has the correct encoding.

        """
        boringsearch = BoringSearch()
        query = PropertyIsEqualTo(
            propertyname='pkey_boring',
            literal='https://www.dov.vlaanderen.be/data/boring/1928-031159')

        df = boringsearch.search(query=query,
                                 return_fields=('pkey_boring', 'uitvoerder'))

        assert df.uitvoerder[0] == u'Societé Belge des Bétons'
예제 #6
0
    def test_hooks(self, force_rebuild_wfs, test_hook_types):
        """Test the argument types of the hook events.

        Parameters
        ----------
        force_rebuild_wfs : pytest.fixture
            Fixture removing cached WFS capabilities document.
        test_hook_types : pytest.fixture
            Fixture removing default hooks and installing HookTester.

        """
        query = PropertyIsEqualTo(propertyname='boornummer',
                                  literal='GEO-04/169-BNo-B1')

        boringsearch = BoringSearch()
        df = boringsearch.search(query=query)
예제 #7
0
    def test_default_hooks(self, nocache):
        """Test the default hooks by performing a simple search.

        Test whether no exceptions are raised.

        Parameters
        ----------
        nocache : pytest.fixture
            Fixture temporarily disabling caching.

        """
        pydov.hooks = Hooks((SimpleStatusHook(), ))

        query = PropertyIsEqualTo(propertyname='boornummer',
                                  literal='GEO-04/169-BNo-B1')

        boringsearch = BoringSearch()
        boringsearch.search(query=query)
예제 #8
0
    def get_search_object(self):
        """Get an instance of the search object for this type.

        Returns
        -------
        pydov.search.boring.BoringSearch
            Instance of BoringSearch used for searching.

        """
        return BoringSearch()
예제 #9
0
    def test_search(self, nocache):
        """Test the search method with strange character in the output.

        Test whether the output has the correct encoding.

        Parameters
        ----------
        nocache : pytest.fixture
            Fixture to disable caching.

        """
        boringsearch = BoringSearch()
        query = PropertyIsEqualTo(
            propertyname='pkey_boring',
            literal=build_dov_url('data/boring/1928-031159'))

        df = boringsearch.search(query=query,
                                 return_fields=('pkey_boring', 'uitvoerder'))

        assert df.uitvoerder[0] == u'Societé Belge des Bétons'
예제 #10
0
    def test_hooks_inject(self, test_hook_inject):
        """Test the of the hook inject events.

        Test whether the requests are intercepted correctly.

        Parameters
        ----------
        test_hook_types : pytest.fixture
            Fixture removing default hooks and installing HookTester.

        """
        query = PropertyIsEqualTo(propertyname='boornummer',
                                  literal='GEO-04/169-BNo-B1')

        boringsearch = BoringSearch()

        boringsearch.search(query=query)
        df = boringsearch.search(query=query)

        assert df.iloc[0].gemeente == 'Bevergem'
        assert df.iloc[0].boormethode == 'De Pypere 106 T'
예제 #11
0
    def test_wfs_and_xml_cache(self, test_hook_count, plaintext_cache):
        """Test the search method providing both a location and a query.

        Test whether a dataframe is returned.

        Parameters
        ----------
        test_hook_count : pytest.fixture
            Fixture removing default hooks and installing HookCounter.
        plaintext_cache : pytest.fixture
            Fixture temporarily setting up a testcache with max_age of 1
            second.

        """
        query = PropertyIsEqualTo(propertyname='boornummer',
                                  literal='GEO-04/169-BNo-B1')

        boringsearch = BoringSearch()
        boringsearch.search(query=query,
                            return_fields=('pkey_boring', 'mv_mtaw'))

        assert pydov.hooks[0].count_wfs_search_init == 1
        assert pydov.hooks[0].count_wfs_search_result == 1
        assert pydov.hooks[0].count_wfs_search_result_received == 1
        assert pydov.hooks[0].count_inject_wfs_getfeature_response == 1

        assert pydov.hooks[0].count_xml_received == 1
        assert pydov.hooks[0].count_inject_xml_response == 2
        assert pydov.hooks[0].count_xml_cache_hit == 0
        assert pydov.hooks[0].count_xml_downloaded == 1

        assert pydov.hooks[0].count_meta_received > 0
        assert pydov.hooks[0].count_inject_meta_response > 0

        boringsearch.search(query=query,
                            return_fields=('pkey_boring', 'mv_mtaw'))

        assert pydov.hooks[0].count_wfs_search_init == 2
        assert pydov.hooks[0].count_wfs_search_result == 2
        assert pydov.hooks[0].count_wfs_search_result_received == 2
        assert pydov.hooks[0].count_inject_wfs_getfeature_response == 2

        assert pydov.hooks[0].count_xml_received == 2
        assert pydov.hooks[0].count_inject_xml_response == 3
        assert pydov.hooks[0].count_xml_cache_hit == 1
        assert pydov.hooks[0].count_xml_downloaded == 1

        assert pydov.hooks[0].count_meta_received > 0
        assert pydov.hooks[0].count_inject_meta_response > 0
예제 #12
0
from pydov.search.boring import BoringSearch
from pydov.search.grondmonster import GrondmonsterSearch
from pydov.search.grondwaterfilter import GrondwaterFilterSearch
from pydov.search.grondwatermonster import GrondwaterMonsterSearch
from pydov.search.interpretaties import (
    FormeleStratigrafieSearch, GecodeerdeLithologieSearch,
    GeotechnischeCoderingSearch, HydrogeologischeStratigrafieSearch,
    InformeleHydrogeologischeStratigrafieSearch, InformeleStratigrafieSearch,
    LithologischeBeschrijvingenSearch, QuartairStratigrafieSearch)
from pydov.search.sondering import SonderingSearch
from pydov.util.errors import InvalidSearchParameterError
from pydov.util.location import Point, WithinDistance
from tests.abstract import service_ok

search_objects = [
    BoringSearch(),
    SonderingSearch(),
    GrondwaterFilterSearch(),
    GrondwaterMonsterSearch(),
    FormeleStratigrafieSearch(),
    InformeleHydrogeologischeStratigrafieSearch(),
    GeotechnischeCoderingSearch(),
    QuartairStratigrafieSearch(),
    InformeleStratigrafieSearch(),
    HydrogeologischeStratigrafieSearch(),
    GecodeerdeLithologieSearch(),
    LithologischeBeschrijvingenSearch(),
    GrondmonsterSearch()
]

예제 #13
0
from pydov.search.interpretaties import LithologischeBeschrijvingenSearch
from pydov.search.sondering import SonderingSearch
from pydov.search.grondmonster import GrondmonsterSearch

from pydov.util.dovutil import build_dov_url

from pydov.util.errors import (
    InvalidSearchParameterError,
)
from pydov.util.location import (
    WithinDistance,
    Point,
)
from tests.abstract import service_ok

search_objects = [BoringSearch(),
                  SonderingSearch(),
                  GrondwaterFilterSearch(),
                  GrondwaterMonsterSearch(),
                  FormeleStratigrafieSearch(),
                  InformeleHydrogeologischeStratigrafieSearch(),
                  GeotechnischeCoderingSearch(),
                  QuartairStratigrafieSearch(),
                  InformeleStratigrafieSearch(),
                  HydrogeologischeStratigrafieSearch(),
                  GecodeerdeLithologieSearch(),
                  LithologischeBeschrijvingenSearch(),
                  GrondmonsterSearch()]


@pytest.fixture(scope='module')
예제 #14
0
class TestBoringSearch(AbstractTestSearch):

    search_instance = BoringSearch()
    datatype_class = Boring

    valid_query_single = PropertyIsEqualTo(propertyname='boornummer',
                                           literal='GEO-04/169-BNo-B1')

    inexistent_field = 'onbestaand'
    wfs_field = 'boornummer'
    xml_field = 'boormethode'

    valid_returnfields = ('pkey_boring', 'boornummer', 'diepte_boring_tot',
                          'datum_aanvang')
    valid_returnfields_subtype = ('pkey_boring', 'boornummer',
                                  'diepte_methode_van', 'diepte_methode_tot')
    valid_returnfields_extra = ('pkey_boring', 'doel')

    df_default_columns = ['pkey_boring', 'boornummer', 'x', 'y', 'mv_mtaw',
                          'start_boring_mtaw', 'gemeente',
                          'diepte_boring_van', 'diepte_boring_tot',
                          'datum_aanvang', 'uitvoerder', 'boorgatmeting',
                          'diepte_methode_van', 'diepte_methode_tot',
                          'boormethode']

    def test_search_date(self, mp_wfs, mp_get_schema,
                         mp_remote_describefeaturetype, mp_remote_md,
                         mp_remote_fc, mp_remote_wfs_feature, mp_dov_xml):
        """Test the search method with only the query parameter.

        Test whether the result is correct.

        Parameters
        ----------
        mp_wfs : pytest.fixture
            Monkeypatch the call to the remote GetCapabilities request.
        mp_get_schema : pytest.fixture
            Monkeypatch the call to a remote OWSLib schema.
        mp_remote_describefeaturetype : pytest.fixture
            Monkeypatch the call to a remote DescribeFeatureType.
        mp_remote_md : pytest.fixture
            Monkeypatch the call to get the remote metadata.
        mp_remote_fc : pytest.fixture
            Monkeypatch the call to get the remote feature catalogue.
        mp_remote_wfs_feature : pytest.fixture
            Monkeypatch the call to get WFS features.
        mp_dov_xml : pytest.fixture
            Monkeypatch the call to get the remote XML data.

        """
        df = self.search_instance.search(
            query=self.valid_query_single)

        # specific test for the Zulu time wfs 1.1.0 issue
        assert df.datum_aanvang.unique()[0] == datetime.date(2004, 12, 20)

    def test_search_nan(self, mp_wfs, mp_get_schema,
                        mp_remote_describefeaturetype, mp_remote_md,
                        mp_remote_fc, mp_remote_wfs_feature, mp_dov_xml):
        """Test the search method with only the query parameter.

        Test whether the result is correct.

        Parameters
        ----------
        mp_wfs : pytest.fixture
            Monkeypatch the call to the remote GetCapabilities request.
        mp_get_schema : pytest.fixture
            Monkeypatch the call to a remote OWSLib schema.
        mp_remote_describefeaturetype : pytest.fixture
            Monkeypatch the call to a remote DescribeFeatureType.
        mp_remote_md : pytest.fixture
            Monkeypatch the call to get the remote metadata.
        mp_remote_fc : pytest.fixture
            Monkeypatch the call to get the remote feature catalogue.
        mp_remote_wfs_feature : pytest.fixture
            Monkeypatch the call to get WFS features.
        mp_dov_xml : pytest.fixture
            Monkeypatch the call to get the remote XML data.

        """
        df = self.search_instance.search(
            query=self.valid_query_single)

        assert df.mv_mtaw.hasnans

    def test_search_xmlresolving(self, mp_get_schema,
                                 mp_remote_describefeaturetype,
                                 mp_remote_wfs_feature, mp_dov_xml):
        """Test the search method with return fields from XML but not from a
        subtype.

        Test whether the output dataframe contains the resolved XML data.

        Parameters
        ----------
        mp_get_schema : pytest.fixture
            Monkeypatch the call to a remote OWSLib schema.
        mp_remote_describefeaturetype : pytest.fixture
            Monkeypatch the call to a remote DescribeFeatureType.
        mp_remote_wfs_feature : pytest.fixture
            Monkeypatch the call to get WFS features.
        mp_dov_xml : pytest.fixture
            Monkeypatch the call to get the remote XML data.

        """
        df = self.search_instance.search(
            query=self.valid_query_single,
            return_fields=('pkey_boring', 'boornummer', 'boorgatmeting'))

        assert not df.boorgatmeting[0]