Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 260 #271

Merged
merged 2 commits into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 44 additions & 44 deletions tests/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,57 +243,57 @@ def test_get_fields(self, mp_wfs, mp_get_schema,
"""
fields = self.get_search_object().get_fields()

assert type(fields) is dict
assert isinstance(fields, dict)

for field in fields:
assert type(field) is str
assert isinstance(field, str)

f = fields[field]
assert type(f) is dict
assert isinstance(f, dict)

assert 'name' in f
assert type(f['name']) is str
assert isinstance(f['name'],str)
assert f['name'] == field

assert 'definition' in f
assert type(f['name']) is str
assert isinstance(f['name'], str)

assert 'type' in f
assert type(f['type']) is str
assert isinstance(f['type'], str)
assert f['type'] in ['string', 'float', 'integer', 'date',
'datetime', 'boolean']

assert 'notnull' in f
assert type(f['notnull']) is bool
assert isinstance(f['notnull'], bool)

assert 'query' in f
assert type(f['query']) is bool
assert isinstance(f['query'], bool)

assert 'cost' in f
assert type(f['cost']) is int
assert isinstance(f['cost'], int)
assert f['cost'] > 0

if 'values' in f:
assert sorted(f.keys()) == [
'cost', 'definition', 'name', 'notnull', 'query', 'type',
'values']

assert type(f['values']) is dict
assert isinstance(f['values'], dict)

for v in f['values'].keys():
assert type(f['values'][v]) is str or f[
assert isinstance(f['values'][v], str) or f[
'values'][v] is None

if f['type'] == 'string':
assert type(v) is str
assert isinstance(v, str)
elif f['type'] == 'float':
assert type(v) is float
assert isinstance(v, float)
elif f['type'] == 'integer':
assert type(v) is int
assert isinstance(v, int)
elif f['type'] == 'date':
assert type(v) is datetime.date
assert isinstance(v, datetime.date)
elif f['type'] == 'boolean':
assert type(v) is bool
assert isinstance(v, bool)
else:
assert sorted(f.keys()) == ['cost', 'definition', 'name',
'notnull', 'query', 'type']
Expand All @@ -320,7 +320,7 @@ def test_search_both_location_query(self, mp_get_schema,
query=self.get_valid_query_single(),
return_fields=self.get_valid_returnfields())

assert type(df) is DataFrame
assert isinstance(df, DataFrame)

def test_search(self, mp_wfs, mp_get_schema, mp_remote_describefeaturetype,
mp_remote_md, mp_remote_fc, mp_remote_wfs_feature,
Expand Down Expand Up @@ -350,7 +350,7 @@ def test_search(self, mp_wfs, mp_get_schema, mp_remote_describefeaturetype,
df = self.get_search_object().search(
query=self.get_valid_query_single())

assert type(df) is DataFrame
assert isinstance(df, DataFrame)

assert list(df) == self.get_df_default_columns()

Expand Down Expand Up @@ -410,7 +410,7 @@ def test_search_returnfields(self, mp_remote_wfs_feature):
query=self.get_valid_query_single(),
return_fields=self.get_valid_returnfields())

assert type(df) is DataFrame
assert isinstance(df, DataFrame)

assert list(df) == list(self.get_valid_returnfields())

Expand All @@ -431,7 +431,7 @@ def test_search_returnfields_subtype(self, mp_remote_wfs_feature):
query=self.get_valid_query_single(),
return_fields=self.get_valid_returnfields_subtype())

assert type(df) is DataFrame
assert isinstance(df, DataFrame)

assert list(df) == list(self.get_valid_returnfields_subtype())

Expand All @@ -457,7 +457,7 @@ def test_search_returnfields_order(self, mp_remote_wfs_feature):
query=self.get_valid_query_single(),
return_fields=rf)

assert type(df) is DataFrame
assert isinstance(df, DataFrame)
assert list(df) == rf

def test_search_wrongreturnfields(self):
Expand Down Expand Up @@ -536,7 +536,7 @@ def test_search_extrareturnfields(self, mp_get_schema,
query=self.get_valid_query_single(),
return_fields=self.get_valid_returnfields_extra())

assert type(df) is DataFrame
assert isinstance(df, DataFrame)

assert list(df) == list(self.get_valid_returnfields_extra())

Expand Down Expand Up @@ -565,7 +565,7 @@ def test_search_sortby_valid(self, mp_get_schema,
sort_by=SortBy([SortProperty(
self.get_valid_returnfields_extra()[0])]))

assert type(df) is DataFrame
assert isinstance(df, DataFrame)

def test_search_sortby_invalid(self, mp_get_schema,
mp_remote_describefeaturetype,
Expand Down Expand Up @@ -678,7 +678,7 @@ def test_get_fields_xsd_values(self, mp_remote_xsd):
for f in xml_fields.values():
if 'xsd_type' in f:
assert 'values' in fields[f['name']]
assert type(fields[f['name']]['values']) is dict
assert isinstance(fields[f['name']]['values'], dict)

def test_get_fields_no_xsd(self):
"""Test whether no XML fields have an XSD type when no XSD schemas
Expand Down Expand Up @@ -922,24 +922,24 @@ def test_get_fields(self):
assert isinstance(fields, OrderedDict)

for f in fields.keys():
assert type(f) is str
assert isinstance(f, str)

field = fields[f]
assert isinstance(field, AbstractField)

assert 'name' in field
assert type(field['name']) is str
assert isinstance(field['name'], str)
assert field['name'] == f

assert 'source' in field
assert type(field['source']) is str
assert isinstance(field['source'], str)
assert field['source'] in ('wfs', 'xml')

assert 'sourcefield' in field
assert type(field['sourcefield']) is str
assert isinstance(field['sourcefield'],str)

assert 'type' in field
assert type(field['type']) is str
assert isinstance(field['type'], str)
assert field['type'] in ['string', 'float', 'integer', 'date',
'datetime', 'boolean']

Expand All @@ -953,10 +953,10 @@ def test_get_fields(self):
'name', 'source', 'sourcefield', 'type']
elif field['source'] == 'xml':
assert 'definition' in field
assert type(field['definition']) is str
assert isinstance(field['definition'], str)

assert 'notnull' in field
assert type(field['notnull']) is bool
assert isinstance(field['notnull'], bool)

if 'xsd_type' in field:
assert sorted(field.keys()) == [
Expand Down Expand Up @@ -992,15 +992,15 @@ def test_from_wfs_element(self, wfs_feature):
feature = self.get_type().from_wfs_element(
wfs_feature, self.get_namespace())

assert type(feature) is self.get_type()
assert isinstance(feature, self.get_type())

assert feature.pkey.startswith(self.get_pkey_base())

assert feature.pkey.startswith(
build_dov_url('data/{}/'.format(feature.typename)))

assert type(feature.data) is dict
assert type(feature.subdata) is dict
assert isinstance(feature.data, dict)
assert isinstance(feature.subdata, dict)

def test_get_df_array(self, wfs_feature, mp_dov_xml):
"""Test the get_df_array method.
Expand All @@ -1025,22 +1025,22 @@ def test_get_df_array(self, wfs_feature, mp_dov_xml):

df_array = feature.get_df_array()

assert type(df_array) is list
assert isinstance(df_array, list)

for record in df_array:
assert len(record) == len(fields)

for value, field in zip(record, fields):
if field['type'] == 'string':
assert type(value) is str or np.isnan(value)
assert isinstance(value, str) or np.isnan(value)
elif field['type'] == 'float':
assert type(value) is float or np.isnan(value)
assert isinstance(value, float) or np.isnan(value)
elif field['type'] == 'integer':
assert type(value) is int or np.isnan(value)
assert isinstance(value, int) or np.isnan(value)
elif field['type'] == 'date':
assert type(value) is datetime.date or np.isnan(value)
assert isinstance(value, datetime.date) or np.isnan(value)
elif field['type'] == 'boolean':
assert type(value) is bool or np.isnan(value)
assert isinstance(value, bool) or np.isnan(value)

if field['name'].startswith('pkey') and not pd.isnull(value):
assert value.startswith(build_dov_url('data/'))
Expand Down Expand Up @@ -1078,7 +1078,7 @@ def test_from_wfs_str(self, wfs_getfeature):
self.get_namespace())

for feature in features:
assert type(feature) is self.get_type()
assert isinstance(feature, self.get_type())

def test_from_wfs_bytes(self, wfs_getfeature):
"""Test the from_wfs method to construct objects from a WFS response,
Expand All @@ -1094,7 +1094,7 @@ def test_from_wfs_bytes(self, wfs_getfeature):
self.get_namespace())

for feature in features:
assert type(feature) is self.get_type()
assert isinstance(feature, self.get_type())

def test_from_wfs_tree(self, wfs_getfeature):
"""Test the from_wfs method to construct objects from a WFS response,
Expand All @@ -1110,7 +1110,7 @@ def test_from_wfs_tree(self, wfs_getfeature):
features = self.get_type().from_wfs(tree, self.get_namespace())

for feature in features:
assert type(feature) is self.get_type()
assert isinstance(feature, self.get_type())

def test_from_wfs_list(self, wfs_getfeature):
"""Test the from_wfs method to construct objects from a WFS response,
Expand All @@ -1132,7 +1132,7 @@ def test_from_wfs_list(self, wfs_getfeature):
features = self.get_type().from_wfs(fts, self.get_namespace())

for feature in features:
assert type(feature) is self.get_type()
assert isinstance(feature, self.get_type())

def test_missing_pkey(self):
"""Test initialising an object type with a pkey of 'None'.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def test_get_description(mp_wfs, objectsearch):
"""
description = objectsearch.get_description()

assert type(description) is str
assert isinstance(description, str)
assert len(description) > 0


Expand Down
2 changes: 1 addition & 1 deletion tests/test_search_itp_formelestratigrafie.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def test_search_customreturnfields(self, mp_get_schema,
return_fields=('pkey_interpretatie', 'pkey_boring',
'pkey_sondering'))

assert type(df) is DataFrame
assert isinstance(df, DataFrame)

assert list(df) == ['pkey_interpretatie', 'pkey_boring',
'pkey_sondering']
Expand Down
2 changes: 1 addition & 1 deletion tests/test_search_itp_gecodeerdelithologie.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def test_search_customreturnfields(self, mp_get_schema,
query=self.get_valid_query_single(),
return_fields=('pkey_interpretatie', 'pkey_boring'))

assert type(df) is DataFrame
assert isinstance(df, DataFrame)

assert list(df) == ['pkey_interpretatie', 'pkey_boring']

Expand Down
2 changes: 1 addition & 1 deletion tests/test_search_itp_geotechnischecodering.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def test_search_customreturnfields(self, mp_get_schema,
query=self.get_valid_query_single(),
return_fields=('pkey_interpretatie', 'pkey_boring'))

assert type(df) is DataFrame
assert isinstance(df, DataFrame)

assert list(df) == ['pkey_interpretatie', 'pkey_boring']

Expand Down
2 changes: 1 addition & 1 deletion tests/test_search_itp_hydrogeologischestratigrafie.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def test_search_customreturnfields(self, mp_get_schema,
query=self.get_valid_query_single(),
return_fields=('pkey_interpretatie', 'pkey_boring'))

assert type(df) is DataFrame
assert isinstance(df, DataFrame)

assert list(df) == ['pkey_interpretatie', 'pkey_boring']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def test_search_customreturnfields(self, mp_get_schema,
return_fields=('pkey_interpretatie', 'pkey_boring',
'gemeente'))

assert type(df) is DataFrame
assert isinstance(df, DataFrame)

assert list(df) == ['pkey_interpretatie', 'pkey_boring',
'gemeente']
Expand Down
2 changes: 1 addition & 1 deletion tests/test_search_itp_informelestratigrafie.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def test_search_customreturnfields(self, mp_get_schema,
return_fields=('pkey_interpretatie', 'pkey_boring',
'pkey_sondering'))

assert type(df) is DataFrame
assert isinstance(df, DataFrame)

assert list(df) == ['pkey_interpretatie', 'pkey_boring',
'pkey_sondering']
Expand Down
2 changes: 1 addition & 1 deletion tests/test_search_itp_quartairstratigrafie.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def test_search_customreturnfields(self, mp_get_schema,
return_fields=('pkey_interpretatie', 'pkey_boring',
))

assert type(df) is DataFrame
assert isinstance(df, DataFrame)

assert list(df) == ['pkey_interpretatie', 'pkey_boring',
]
Expand Down
8 changes: 4 additions & 4 deletions tests/test_util_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,13 @@ def test_return_type(self, plaintext_cache, mp_remote_xml):

ref_data = plaintext_cache.get(
build_dov_url('data/boring/2004-103984.xml'))
assert type(ref_data) is bytes
assert isinstance(ref_data, bytes)

assert os.path.exists(cached_file)

cached_data = plaintext_cache.get(
build_dov_url('data/boring/2004-103984.xml'))
assert type(cached_data) is bytes
assert isinstance(cached_data, bytes)


class TestGzipTextFileCacheCache(object):
Expand Down Expand Up @@ -664,10 +664,10 @@ def test_return_type(self, gziptext_cache, mp_remote_xml):

ref_data = gziptext_cache.get(
build_dov_url('data/boring/2004-103984.xml'))
assert type(ref_data) is bytes
assert isinstance(ref_data, bytes)

assert os.path.exists(cached_file)

cached_data = gziptext_cache.get(
build_dov_url('data/boring/2004-103984.xml'))
assert type(cached_data) is bytes
assert isinstance(cached_data, bytes)
Loading