Skip to content

Fix python37 and ogc error #107

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions lib/bald/tests/integration/test_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ def test_invalid_uri(self):
validation = bald.validate_hdf5(tfile, cache=self.acache,
uris_resolve=True)
exns = validation.exceptions()
expected = ['https://www.opengis.net/def/binary-array-ld/turtle is not resolving as a resource (404).',
'https://www.opengis.net/def/binary-array-ld/walnut is not resolving as a resource (404).']
expected = ['https://www.opengis.net/def/binary-array-ld/ is not resolving as a resource (404).',
'https://www.opengis.net/def/binary-array-ld/turtle is not resolving as a resource (404).',
'https://www.opengis.net/def/binary-array-ld/walnut is not resolving as a resource (404).',
'https://www.opengis.net/def/binary-array-ld/ is not resolving as a resource (404).'
]

self.assertTrue((not validation.is_valid()) and exns == expected,
msg='{} != {}'.format(exns, expected))

Expand Down
27 changes: 14 additions & 13 deletions lib/bald/tests/integration/test_cdl_rdfgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def check_result(self, result, expected):
lb = [lbb, lbr, lbe]

self.assertTrue(rdflib.compare.isomorphic(result, expected),
''.join(list(itertools.chain(*zip(lb, [g.serialize(format='n3').decode("utf-8") for g in
''.join(list(itertools.chain(*zip(lb, [g.serialize(format='n3') for g in
rdflib.compare.graph_diff(result,
# expected)[1:]]))
expected)])))))
Expand All @@ -45,7 +45,8 @@ def test_array_reference(self):
cdl_file_uri = 'file://CDL/{}'.format(cdlname)
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri, cache=self.acache)
rdfgraph = root_container.rdfgraph()
ttl = rdfgraph.serialize(format='n3').decode("utf-8")
ttl = rdfgraph.serialize(format='n3')
#ttl = rdfgraph.serialize(format='n3').decode("utf-8")
if os.environ.get('bald_update_results') is not None:
with open(os.path.join(self.ttl_path, 'array_reference.ttl'), 'w') as sf:
sf.write(ttl)
Expand All @@ -60,7 +61,7 @@ def test_array_reference_with_baseuri(self):
subprocess.check_call(['ncgen', '-o', tfile, cdl_file])
root_container = bald.load_netcdf(tfile, baseuri='http://example.org/base', cache=self.acache)
rdfgraph = root_container.rdfgraph()
ttl = rdfgraph.serialize(format='n3').decode("utf-8")
ttl = rdfgraph.serialize(format='n3')
if os.environ.get('bald_update_results') is not None:
with open(os.path.join(self.ttl_path, 'array_reference_withbase.ttl'), 'w') as sf:
sf.write(ttl)
Expand All @@ -81,7 +82,7 @@ def test_array_reference_external_prefix_context(self):
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri, prefix_contexts=prefix_context,
cache=self.acache)
rdfgraph = root_container.rdfgraph()
ttl = rdfgraph.serialize(format='n3').decode("utf-8")
ttl = rdfgraph.serialize(format='n3')
if os.environ.get('bald_update_results') is not None:
with open(os.path.join(self.ttl_path, 'array_reference_external_prefix_context.ttl'), 'w') as sf:
sf.write(ttl)
Expand All @@ -98,7 +99,7 @@ def test_multi_array_reference(self):
cdl_file_uri = 'file://CDL/{}'.format(cdlname)
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri, cache=self.acache)
rdfgraph = root_container.rdfgraph()
ttl = rdfgraph.serialize(format='n3').decode("utf-8")
ttl = rdfgraph.serialize(format='n3')
if os.environ.get('bald_update_results') is not None:
with open(os.path.join(self.ttl_path, 'multi_array_reference.ttl'), 'w') as sf:
sf.write(ttl)
Expand All @@ -120,7 +121,7 @@ def test_point_template(self):
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri,
alias_dict=alias_dict, cache=self.acache)
rdfgraph = root_container.rdfgraph()
ttl = rdfgraph.serialize(format='n3').decode("utf-8")
ttl = rdfgraph.serialize(format='n3')
if os.environ.get('bald_update_results') is not None:
with open(os.path.join(self.ttl_path, 'point_template.ttl'), 'w') as sf:
sf.write(ttl)
Expand All @@ -142,7 +143,7 @@ def test_gems_co2(self):
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri,
alias_dict=alias_dict, cache=self.acache)
rdfgraph = root_container.rdfgraph()
ttl = rdfgraph.serialize(format='n3').decode("utf-8")
ttl = rdfgraph.serialize(format='n3')
if os.environ.get('bald_update_results') is not None:
with open(os.path.join(self.ttl_path, 'GEMS_CO2_Apr2006.ttl'), 'w') as sf:
sf.write(ttl)
Expand All @@ -163,7 +164,7 @@ def test_ProcessChain0300(self):
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri,
alias_dict=alias_dict, cache=self.acache)
rdfgraph = root_container.rdfgraph()
ttl = rdfgraph.serialize(format='n3').decode("utf-8")
ttl = rdfgraph.serialize(format='n3')
if os.environ.get('bald_update_results') is not None:
with open(os.path.join(self.ttl_path, '{}.ttl'.format(name)), 'w') as sf:
sf.write(ttl)
Expand All @@ -185,7 +186,7 @@ def test_ereefs(self):
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri,
alias_dict=alias_dict, cache=self.acache)
rdfgraph = root_container.rdfgraph()
ttl = rdfgraph.serialize(format='n3').decode("utf-8")
ttl = rdfgraph.serialize(format='n3')
if os.environ.get('bald_update_results') is not None:
with open(os.path.join(self.ttl_path, '{}.ttl'.format(name)), 'w') as sf:
sf.write(ttl)
Expand All @@ -208,7 +209,7 @@ def test_votemper(self):
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri,
alias_dict=alias_dict, cache=self.acache)
rdfgraph = root_container.rdfgraph()
ttl = rdfgraph.serialize(format='n3').decode("utf-8")
ttl = rdfgraph.serialize(format='n3')
if os.environ.get('bald_update_results') is not None:
with open(os.path.join(self.ttl_path, '{}.ttl'.format(name)), 'w') as sf:
sf.write(ttl)
Expand Down Expand Up @@ -237,7 +238,7 @@ def test_hgroups(self):
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri,
alias_dict=alias_dict, cache=self.acache, file_locator=hgurl)
rdfgraph = root_container.rdfgraph()
ttl = rdfgraph.serialize(format='n3').decode("utf-8")
ttl = rdfgraph.serialize(format='n3')
if os.environ.get('bald_update_results') is not None:
with open(os.path.join(self.ttl_path, '{}.ttl'.format(name)), 'w') as sf:
sf.write(ttl)
Expand Down Expand Up @@ -270,7 +271,7 @@ def test_hgroups_schema_dot_org(self):
rdfgraph = root_container.rdfgraph()
schema_org_inst = bald.schemaOrg(rdfgraph,hgurl,baseuri).getSchemaOrgGraph()
#rdfgraph = schema_org_inst.distribution(baseuri, rdfgraph, hgurl)
ttl = schema_org_inst.serialize(format='n3').decode("utf-8")
ttl = schema_org_inst.serialize(format='n3')
if os.environ.get('bald_update_results') is not None:
with open(os.path.join(self.ttl_path, '{}.ttl'.format(name)), 'w') as sf:
sf.write(ttl)
Expand Down Expand Up @@ -299,7 +300,7 @@ def test_group_array_geo(self):
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri,
alias_dict=alias_dict, cache=self.acache)
rdfgraph = root_container.rdfgraph()
ttl = rdfgraph.serialize(format='n3').decode("utf-8")
ttl = rdfgraph.serialize(format='n3')
if os.environ.get('bald_update_results') is not None:
with open(os.path.join(self.ttl_path, '{}.ttl'.format(name)), 'w') as sf:
sf.write(ttl)
Expand Down
2 changes: 1 addition & 1 deletion lib/bald/tests/integration/test_multi_array_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_turtle(self):
subprocess.check_call(['ncgen', '-o', tfile, cdl_file])
cdl_file_uri = 'file://CDL/{}'.format(cdlname)
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri, cache=self.acache)
ttl = root_container.rdfgraph().serialize(format='n3').decode("utf-8")
ttl = root_container.rdfgraph().serialize(format='n3')
if os.environ.get('bald_update_results') is not None:
with open(os.path.join(self.ttl_path, 'multi_array_reference.ttl'), 'w') as sf:
sf.write(ttl)
Expand Down
6 changes: 4 additions & 2 deletions lib/bald/tests/integration/test_netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ def test_invalid_uri(self):
validation = bald.validate_netcdf(tfile, cache=self.acache,
uris_resolve=True)
exns = validation.exceptions()
expected = ['https://www.opengis.net/def/binary-array-ld/turtle is not resolving as a resource (404).',
expected = ['https://www.opengis.net/def/binary-array-ld/ is not resolving as a resource (404).',
'https://www.opengis.net/def/binary-array-ld/turtle is not resolving as a resource (404).',
'https://www.opengis.net/def/binary-array-ld/walnut is not resolving as a resource (404).']
self.assertTrue((not validation.is_valid()) and exns == expected,

self.assertTrue((not validation.is_valid()) and list(set((exns)) == expected,
msg='{} != {}'.format(exns, expected))

class TestArrayReference(BaldTestCase):
Expand Down
7 changes: 5 additions & 2 deletions lib/bald/tests/integration/test_netcdf4_classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def test_valid_uri(self):
exns = validation.exceptions()
self.assertTrue(validation.is_valid(), msg='{} != []'.format(exns))


def test_invalid_uri(self):
with self.temp_filename('.nc') as tfile:
f = netCDF4.Dataset(tfile, "w", format="NETCDF4_CLASSIC")
Expand All @@ -50,9 +51,11 @@ def test_invalid_uri(self):
uris_resolve=True)
exns = validation.exceptions()

expected = ['https://www.opengis.net/def/binary-array-ld/turtle is not resolving as a resource (404).',
expected = ['https://www.opengis.net/def/binary-array-ld/ is not resolving as a resource (404).',
'https://www.opengis.net/def/binary-array-ld/turtle is not resolving as a resource (404).',
'https://www.opengis.net/def/binary-array-ld/walnut is not resolving as a resource (404).']
self.assertTrue((not validation.is_valid()) and exns == expected,

self.assertTrue((not validation.is_valid()) and list(set((exns))) == expected,
msg='{} != {}'.format(exns, expected))


Expand Down
3 changes: 1 addition & 2 deletions lib/bald/tests/integration/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ def test_invalid_uri(self):
validation = bald.validate_hdf5(tfile, cache=self.acache,
uris_resolve=True)
exns = validation.exceptions()
expected = ['https://www.opengis.net/def/binary-array-ld/turtle is not resolving as a resource (404).',
'https://www.opengis.net/def/binary-array-ld/walnut is not resolving as a resource (404).']
expected = ['https://www.opengis.net/def/binary-array-ld/ is not resolving as a resource (404).', 'https://www.opengis.net/def/binary-array-ld/turtle is not resolving as a resource (404).', 'https://www.opengis.net/def/binary-array-ld/walnut is not resolving as a resource (404).', 'https://www.opengis.net/def/binary-array-ld/ is not resolving as a resource (404).', 'https://www.opengis.net/def/binary-array-ld/ is not resolving as a resource (404).']
self.assertTrue((not validation.is_valid()) and exns == expected,
msg='{} != {}'.format(exns, expected))

Expand Down