diff --git a/lib/bald/tests/integration/CDL/ogcClassA.cdl b/lib/bald/tests/integration/CDL/ogcClassA.cdl
deleted file mode 100644
index a2c668b..0000000
--- a/lib/bald/tests/integration/CDL/ogcClassA.cdl
+++ /dev/null
@@ -1,10 +0,0 @@
-netcdf ogcClassA {
-dimensions:
- d0 = 1 ;
- d1 = 1 ;
-variables:
- int var0 ;
- int var1 ;
-
-data:
-}
\ No newline at end of file
diff --git a/lib/bald/tests/integration/CDL/ogcClassB.cdl b/lib/bald/tests/integration/CDL/ogcClassB.cdl
deleted file mode 100644
index 339f206..0000000
--- a/lib/bald/tests/integration/CDL/ogcClassB.cdl
+++ /dev/null
@@ -1,16 +0,0 @@
-netcdf ogcClassB {
-dimensions:
- d0 = 1 ;
- d1 = 1 ;
-variables:
- int var0 ;
- var0:rdfs__label = "rdfs__label" ;
- int var1 ;
- var1:rdfs__label = "rdfs__label" ;
- int prefix_list ;
- prefix_list:bald__ = "http://binary-array-ld.net/latest/" ;
- prefix_list:rdf__ = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ;
- prefix_list:rdfs__ = "http://www.w3.org/2000/01/rdf-schema#" ;
- :bald__isPrefixedBy = "prefix_list" ;
-data:
-}
\ No newline at end of file
diff --git a/lib/bald/tests/integration/CDL/ogcClassC.cdl b/lib/bald/tests/integration/CDL/ogcClassC.cdl
deleted file mode 100644
index 67c4a78..0000000
--- a/lib/bald/tests/integration/CDL/ogcClassC.cdl
+++ /dev/null
@@ -1,10 +0,0 @@
-netcdf ogcClassC {
-dimensions:
- d0 = 1 ;
- d1 = 1 ;
-variables:
- int var0 ;
- int var1 ;
-:title = "Sample netCDF file definition with alias terms from the netCDF user guide" ;
-data:
-}
\ No newline at end of file
diff --git a/lib/bald/tests/integration/CDL/ogcClassD.cdl b/lib/bald/tests/integration/CDL/ogcClassD.cdl
deleted file mode 100644
index 53e03fd..0000000
--- a/lib/bald/tests/integration/CDL/ogcClassD.cdl
+++ /dev/null
@@ -1,17 +0,0 @@
-netcdf ogcClassD {
-dimensions:
- d0 = 1 ;
- d1 = 1 ;
-variables:
- int var0 ;
- var0:rdfs__label = "rdfs__label" ;
- int var1 ;
- var1:rdfs__label = "rdfs__label" ;
- int prefix_list ;
- prefix_list:bald__ = "http://binary-array-ld.net/latest/" ;
- prefix_list:rdf__ = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ;
- prefix_list:rdfs__ = "http://www.w3.org/2000/01/rdf-schema#" ;
- :bald__isPrefixedBy = "prefix_list" ;
- :title = "Sample netCDF file definition with alias terms from the netCDF user guide" ;
-data:
-}
\ No newline at end of file
diff --git a/lib/bald/tests/integration/TTL/ogcClassA.ttl b/lib/bald/tests/integration/TTL/ogcClassA.ttl
deleted file mode 100644
index b55d0ca..0000000
--- a/lib/bald/tests/integration/TTL/ogcClassA.ttl
+++ /dev/null
@@ -1,22 +0,0 @@
-@prefix bald: .
-@prefix dcat: .
-@prefix dct: .
-@prefix rdf: .
-@prefix rdfs: .
-@prefix this: .
-@prefix xml: .
-@prefix xsd: .
-
-this: a bald:Container ;
- dct:format [ a dct:MediaType ;
- dct:identifier ] ;
- dcat:distribution [ a dcat:Distribution ;
- dcat:mediaType [ a dcat:MediaType ;
- dct:identifier "application/x-netcdf" ] ] ;
- bald:contains this:var0,
- this:var1 .
-
-this:var0 a bald:Resource .
-
-this:var1 a bald:Resource .
-
diff --git a/lib/bald/tests/integration/TTL/ogcClassB.ttl b/lib/bald/tests/integration/TTL/ogcClassB.ttl
deleted file mode 100644
index 220c6c3..0000000
--- a/lib/bald/tests/integration/TTL/ogcClassB.ttl
+++ /dev/null
@@ -1,25 +0,0 @@
-@prefix bald: .
-@prefix dcat: .
-@prefix dct: .
-@prefix rdf: .
-@prefix rdfs: .
-@prefix this: .
-@prefix xml: .
-@prefix xsd: .
-
-this: a bald:Container ;
- dct:format [ a dct:MediaType ;
- dct:identifier ] ;
- dcat:distribution [ a dcat:Distribution ;
- dcat:mediaType [ a dcat:MediaType ;
- dct:identifier "application/x-netcdf" ] ] ;
- bald:contains this:var0,
- this:var1 ;
- bald:isPrefixedBy "prefix_list" .
-
-this:var0 a bald:Resource ;
- this:rdfs__label "rdfs__label" .
-
-this:var1 a bald:Resource ;
- this:rdfs__label "rdfs__label" .
-
diff --git a/lib/bald/tests/integration/TTL/ogcClassC.ttl b/lib/bald/tests/integration/TTL/ogcClassC.ttl
deleted file mode 100644
index 176b011..0000000
--- a/lib/bald/tests/integration/TTL/ogcClassC.ttl
+++ /dev/null
@@ -1,24 +0,0 @@
-@prefix NetCDF: .
-@prefix bald: .
-@prefix dcat: .
-@prefix dct: .
-@prefix rdf: .
-@prefix rdfs: .
-@prefix this: .
-@prefix xml: .
-@prefix xsd: .
-
-this: a bald:Container ;
- NetCDF:title "Sample netCDF file definition with alias terms from the netCDF user guide" ;
- dct:format [ a dct:MediaType ;
- dct:identifier ] ;
- dcat:distribution [ a dcat:Distribution ;
- dcat:mediaType [ a dcat:MediaType ;
- dct:identifier "application/x-netcdf" ] ] ;
- bald:contains this:var0,
- this:var1 .
-
-this:var0 a bald:Resource .
-
-this:var1 a bald:Resource .
-
diff --git a/lib/bald/tests/integration/TTL/ogcClassD.ttl b/lib/bald/tests/integration/TTL/ogcClassD.ttl
deleted file mode 100644
index 2b1f6e9..0000000
--- a/lib/bald/tests/integration/TTL/ogcClassD.ttl
+++ /dev/null
@@ -1,27 +0,0 @@
-@prefix NetCDF: .
-@prefix bald: .
-@prefix dcat: .
-@prefix dct: .
-@prefix rdf: .
-@prefix rdfs: .
-@prefix this: .
-@prefix xml: .
-@prefix xsd: .
-
-this: a bald:Container ;
- NetCDF:title "Sample netCDF file definition with alias terms from the netCDF user guide" ;
- dct:format [ a dct:MediaType ;
- dct:identifier ] ;
- dcat:distribution [ a dcat:Distribution ;
- dcat:mediaType [ a dcat:MediaType ;
- dct:identifier "application/x-netcdf" ] ] ;
- bald:contains this:var0,
- this:var1 ;
- bald:isPrefixedBy "prefix_list" .
-
-this:var0 a bald:Resource ;
- this:rdfs__label "rdfs__label" .
-
-this:var1 a bald:Resource ;
- this:rdfs__label "rdfs__label" .
-
diff --git a/lib/bald/tests/integration/test_ogc_conformance.py b/lib/bald/tests/integration/test_ogc_conformance.py
index 5951831..0006a8b 100644
--- a/lib/bald/tests/integration/test_ogc_conformance.py
+++ b/lib/bald/tests/integration/test_ogc_conformance.py
@@ -4,10 +4,14 @@
import netCDF4
import numpy as np
+import requests
import bald
from bald.tests import BaldTestCase
+OGCFiles = ('https://raw.githubusercontent.com/opengeospatial/netcdf-ld/'
+ 'master/standard/abstract_tests/')
+
class Test(BaldTestCase):
def setUp(self):
self.cdl_path = os.path.join(os.path.dirname(__file__), 'CDL')
@@ -18,62 +22,110 @@ def test_conformance_a(self):
with self.temp_filename('.nc') as tfile:
cdlname = 'ogcClassA.cdl'
cdl_file = os.path.join(self.cdl_path, cdlname)
+ with open(cdl_file, 'w') as cdlf:
+ cdluri = '{}CDL/ogcClassA.cdl'.format(OGCFiles)
+ r = requests.get(cdluri)
+ if r.status_code != 200:
+ raise ValueError('CDL download failed for {}'.format(cdluri))
+ cdlf.write(r.text)
subprocess.check_call(['ncgen', '-o', tfile, cdl_file])
cdl_file_uri = 'http://secret.binary-array-ld.net/identity.nc'
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri, cache=self.acache)
ttl = root_container.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, 'ogcClassA.ttl'), 'w') as sf:
- sf.write(ttl)
- with open(os.path.join(self.ttl_path, 'ogcClassA.ttl'), 'r') as sf:
+ ttl_file = os.path.join(self.ttl_path, 'ogcClassA.ttl')
+ with open(ttl_file, 'w') as ttlf:
+ ttluri = '{}TTL/ogcClassA.ttl'.format(OGCFiles)
+ r = requests.get(ttluri)
+ if r.status_code != 200:
+ raise ValueError('TTL download failed for {}'.format(ttluri))
+ ttlf.write(r.text)
+ with open(ttl_file, 'r') as sf:
expected_ttl = sf.read()
+ os.remove(ttl_file)
+ os.remove(cdl_file)
self.assertEqual(expected_ttl, ttl)
def test_conformance_b(self):
with self.temp_filename('.nc') as tfile:
cdlname = 'ogcClassB.cdl'
cdl_file = os.path.join(self.cdl_path, cdlname)
+ with open(cdl_file, 'w') as cdlf:
+ cdluri = '{}CDL/ogcClassB.cdl'.format(OGCFiles)
+ r = requests.get(cdluri)
+ if r.status_code != 200:
+ raise ValueError('CDL download failed for {}'.format(cdluri))
+ cdlf.write(r.text)
subprocess.check_call(['ncgen', '-o', tfile, cdl_file])
cdl_file_uri = 'http://secret.binary-array-ld.net/prefix.nc'
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri, cache=self.acache)
ttl = root_container.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, 'ogcClassB.ttl'), 'w') as sf:
- sf.write(ttl)
- with open(os.path.join(self.ttl_path, 'ogcClassB.ttl'), 'r') as sf:
+ ttl_file = os.path.join(self.ttl_path, 'ogcClassA.ttl')
+ with open(ttl_file, 'w') as ttlf:
+ ttluri = '{}TTL/ogcClassB.ttl'.format(OGCFiles)
+ r = requests.get(ttluri)
+ if r.status_code != 200:
+ raise ValueError('TTL download failed for {}'.format(ttluri))
+ ttlf.write(r.text)
+ with open(ttl_file, 'r') as sf:
expected_ttl = sf.read()
+ os.remove(ttl_file)
+ os.remove(cdl_file)
self.assertEqual(expected_ttl, ttl)
def test_conformance_c(self):
with self.temp_filename('.nc') as tfile:
cdlname = 'ogcClassC.cdl'
cdl_file = os.path.join(self.cdl_path, cdlname)
+ with open(cdl_file, 'w') as cdlf:
+ cdluri = '{}CDL/ogcClassC.cdl'.format(OGCFiles)
+ r = requests.get(cdluri)
+ if r.status_code != 200:
+ raise ValueError('CDL download failed for {}'.format(cdluri))
+ cdlf.write(r.text)
subprocess.check_call(['ncgen', '-o', tfile, cdl_file])
cdl_file_uri = 'http://secret.binary-array-ld.net/alias.nc'
alias_dict = {'NetCDF': 'http://def.scitools.org.uk/NetCDF'}
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri,
alias_dict=alias_dict, cache=self.acache)
ttl = root_container.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, 'ogcClassC.ttl'), 'w') as sf:
- sf.write(ttl)
- with open(os.path.join(self.ttl_path, 'ogcClassC.ttl'), 'r') as sf:
+ ttl_file = os.path.join(self.ttl_path, 'ogcClassA.ttl')
+ with open(ttl_file, 'w') as ttlf:
+ ttluri = '{}TTL/ogcClassC.ttl'.format(OGCFiles)
+ r = requests.get(ttluri)
+ if r.status_code != 200:
+ raise ValueError('TTL download failed for {}'.format(ttluri))
+ ttlf.write(r.text)
+ with open(ttl_file, 'r') as sf:
expected_ttl = sf.read()
+ os.remove(ttl_file)
+ os.remove(cdl_file)
self.assertEqual(expected_ttl, ttl)
def test_conformance_d(self):
with self.temp_filename('.nc') as tfile:
cdlname = 'ogcClassD.cdl'
cdl_file = os.path.join(self.cdl_path, cdlname)
+ with open(cdl_file, 'w') as cdlf:
+ cdluri = '{}CDL/ogcClassD.cdl'.format(OGCFiles)
+ r = requests.get(cdluri)
+ if r.status_code != 200:
+ raise ValueError('CDL download failed for {}'.format(cdluri))
+ cdlf.write(r.text)
subprocess.check_call(['ncgen', '-o', tfile, cdl_file])
cdl_file_uri = 'http://secret.binary-array-ld.net/attributes.nc'
alias_dict = {'NetCDF': 'http://def.scitools.org.uk/NetCDF'}
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri,
alias_dict=alias_dict, cache=self.acache)
ttl = root_container.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, 'ogcClassD.ttl'), 'w') as sf:
- sf.write(ttl)
- with open(os.path.join(self.ttl_path, 'ogcClassD.ttl'), 'r') as sf:
+ ttl_file = os.path.join(self.ttl_path, 'ogcClassA.ttl')
+ with open(ttl_file, 'w') as ttlf:
+ ttluri = '{}TTL/ogcClassD.ttl'.format(OGCFiles)
+ r = requests.get(ttluri)
+ if r.status_code != 200:
+ raise ValueError('TTL download failed for {}'.format(ttluri))
+ ttlf.write(r.text)
+ with open(ttl_file, 'r') as sf:
expected_ttl = sf.read()
+ os.remove(ttl_file)
+ os.remove(cdl_file)
self.assertEqual(expected_ttl, ttl)