def test_search(self, mp_wfs, mp_remote_describefeaturetype, mp_remote_md, mp_remote_fc, mp_remote_wfs_feature, mp_dov_xml): """Test the search method. Test whether a RuntimeError is raised. Parameters ---------- mp_wfs : pytest.fixture Monkeypatch the call to the remote GetCapabilities request. 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. """ fs = GrondwaterFilterSearch(objecttype=MyWrongGrondwaterFilter) with pytest.raises(RuntimeError): fs.search(query=PropertyIsEqualTo( propertyname='filterfiche', literal='https://www.dov.vlaanderen.be/data/' 'filter/2003-004471'))
def test_search(self, mp_wfs, mp_remote_describefeaturetype, mp_remote_md, mp_remote_fc, mp_remote_wfs_feature, mp_dov_xml): """Test the search method. Test whether the extra fields from the custom type are resolved into data in the result dataframe. Parameters ---------- mp_wfs : pytest.fixture Monkeypatch the call to the remote GetCapabilities request. 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. """ fs = GrondwaterFilterSearch(objecttype=MyGrondwaterFilter) df = fs.search(query=PropertyIsEqualTo( propertyname='filterfiche', literal='https://www.dov.vlaanderen.be/data/filter/2003-004471')) assert 'grondwatersysteem' in df assert df.iloc[0].grondwatersysteem == 'Centraal Vlaams Systeem'
def test_get_fields(self): """Test the get_fields method. Test whether a RuntimeError is raised. """ fs = GrondwaterFilterSearch(objecttype=MyWrongGrondwaterFilter) with pytest.raises(RuntimeError): fs.get_fields()
def test_get_fields(self): """Test the get_fields method. Test whether the extra field is available in the output of the get_fields metadata. """ fs = GrondwaterFilterSearch(objecttype=MyGrondwaterFilter) fields = fs.get_fields() assert 'grondwatersysteem' in fields
def test_get_fields(self): """Test the get_fields method. Test whether the extra field is available in the output of the get_fields metadata. """ fs = GrondwaterFilterSearch(objecttype=MyGrondwaterFilterOpbouw) fields = fs.get_fields() assert 'datum' not in fields assert 'peil_mtaw' not in fields assert 'opbouw_van' in fields assert 'opbouw_tot' in fields assert 'opbouw_element' in fields
def get_search_object(self): """Get an instance of the search object for this type. Returns ------- pydov.search.grondwaterfilter.GrondwaterFilterSearch Instance of GrondwaterFilterSearch used for searching. """ return GrondwaterFilterSearch()
def test_search(self, mp_wfs, mp_remote_describefeaturetype, mp_remote_md, mp_remote_fc, mp_remote_wfs_feature, mp_dov_xml): """Test the search method. Test whether the extra fields from the custom type are resolved into data in the result dataframe. Parameters ---------- mp_wfs : pytest.fixture Monkeypatch the call to the remote GetCapabilities request. 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. """ fs = GrondwaterFilterSearch(objecttype=MyGrondwaterFilterOpbouw) df = fs.search(query=PropertyIsEqualTo(propertyname='filterfiche', literal=build_dov_url( 'data/filter/2003-004471'))) assert 'opbouw_van' in df assert 'opbouw_tot' in df assert 'opbouw_element' in df assert df.iloc[-1].opbouw_van == 2.5 assert df.iloc[-1].opbouw_tot == 2.7 assert df.iloc[-1].opbouw_element == 'zandvang'
def test_search_nosubtype(self, mp_wfs, mp_remote_md, mp_remote_fc, mp_get_schema, mp_remote_describefeaturetype, mp_remote_wfs_feature, mp_remote_xsd, mp_dov_xml): """Test the search method with a result containing no elements from the subtype. Test whether the output dataframe contains the results, with the columns of the subtype set to NaN. 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_remote_xsd : pytest.fixture Monkeypatch the call to get XSD schemas. mp_dov_xml : pytest.fixture Monkeypatch the call to get the remote XML data. """ df = GrondwaterFilterSearch().search( query=PropertyIsEqualTo( 'pkey_filter', build_dov_url('data/filter/2007-011302.xml') ) ) assert len(df.pkey_filter) == 1 assert df.datum.hasnans assert df.tijdstip.hasnans assert df.peil_mtaw.hasnans assert df.betrouwbaarheid.hasnans
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() ] @pytest.mark.parametrize("objectsearch", search_objects) def test_get_description(mp_wfs, objectsearch):
class TestGrondwaterfilterSearch(AbstractTestSearch): search_instance = GrondwaterFilterSearch() datatype_class = GrondwaterFilter valid_query_single = PropertyIsEqualTo( propertyname='filterfiche', literal=build_dov_url('data/filter/2003-004471')) inexistent_field = 'onbestaand' wfs_field = 'filternummer' xml_field = 'peil_mtaw' valid_returnfields = ('pkey_filter', 'filternummer') valid_returnfields_subtype = ('pkey_filter', 'filternummer', 'peil_mtaw') valid_returnfields_extra = ('pkey_filter', 'beheerder') df_default_columns = [ 'pkey_filter', 'pkey_grondwaterlocatie', 'gw_id', 'filternummer', 'filtertype', 'x', 'y', 'start_grondwaterlocatie_mtaw', 'mv_mtaw', 'gemeente', 'meetnet_code', 'aquifer_code', 'grondwaterlichaam_code', 'regime', 'diepte_onderkant_filter', 'lengte_filter', 'datum', 'tijdstip', 'peil_mtaw', 'betrouwbaarheid', 'methode', 'filterstatus', 'filtertoestand' ] 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.sort_values()[0] == datetime.date(2004, 4, 7) 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_filter', 'gw_id', 'filternummer', 'meetnet_code')) assert df.meetnet_code[0] == '8'