diff --git a/lib/bald/tests/integration/CDL/ogcClassA.cdl b/lib/bald/tests/integration/CDL/ogcClassA.cdl
new file mode 100644
index 0000000..a2c668b
--- /dev/null
+++ b/lib/bald/tests/integration/CDL/ogcClassA.cdl
@@ -0,0 +1,10 @@
+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
new file mode 100644
index 0000000..339f206
--- /dev/null
+++ b/lib/bald/tests/integration/CDL/ogcClassB.cdl
@@ -0,0 +1,16 @@
+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
new file mode 100644
index 0000000..67c4a78
--- /dev/null
+++ b/lib/bald/tests/integration/CDL/ogcClassC.cdl
@@ -0,0 +1,10 @@
+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
new file mode 100644
index 0000000..53e03fd
--- /dev/null
+++ b/lib/bald/tests/integration/CDL/ogcClassD.cdl
@@ -0,0 +1,17 @@
+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
new file mode 100644
index 0000000..bb8f317
--- /dev/null
+++ b/lib/bald/tests/integration/TTL/ogcClassA.ttl
@@ -0,0 +1,15 @@
+@prefix bald: .
+@prefix rdf: .
+@prefix rdfs: .
+@prefix this: .
+@prefix xml: .
+@prefix xsd: .
+
+ a bald:Container ;
+ bald:contains this:var0,
+ this:var1 .
+
+this:var0 a bald:Subject .
+
+this:var1 a bald:Subject .
+
diff --git a/lib/bald/tests/integration/TTL/ogcClassB.ttl b/lib/bald/tests/integration/TTL/ogcClassB.ttl
new file mode 100644
index 0000000..c8bdca3
--- /dev/null
+++ b/lib/bald/tests/integration/TTL/ogcClassB.ttl
@@ -0,0 +1,18 @@
+@prefix bald: .
+@prefix rdf: .
+@prefix rdfs: .
+@prefix this: .
+@prefix xml: .
+@prefix xsd: .
+
+ a bald:Container ;
+ bald:contains this:var0,
+ this:var1 ;
+ bald:isPrefixedBy "prefix_list" .
+
+this:var0 a bald:Subject ;
+ rdfs:label rdfs:label .
+
+this:var1 a bald:Subject ;
+ rdfs:label rdfs:label .
+
diff --git a/lib/bald/tests/integration/TTL/ogcClassC.ttl b/lib/bald/tests/integration/TTL/ogcClassC.ttl
new file mode 100644
index 0000000..2f3be44
--- /dev/null
+++ b/lib/bald/tests/integration/TTL/ogcClassC.ttl
@@ -0,0 +1,17 @@
+@prefix NetCDF: .
+@prefix bald: .
+@prefix rdf: .
+@prefix rdfs: .
+@prefix this: .
+@prefix xml: .
+@prefix xsd: .
+
+ a bald:Container ;
+ bald:contains this:var0,
+ this:var1 ;
+ NetCDF:title "Sample netCDF file definition with alias terms from the netCDF user guide" .
+
+this:var0 a bald:Subject .
+
+this:var1 a bald:Subject .
+
diff --git a/lib/bald/tests/integration/TTL/ogcClassD.ttl b/lib/bald/tests/integration/TTL/ogcClassD.ttl
new file mode 100644
index 0000000..a13c69a
--- /dev/null
+++ b/lib/bald/tests/integration/TTL/ogcClassD.ttl
@@ -0,0 +1,20 @@
+@prefix NetCDF: .
+@prefix bald: .
+@prefix rdf: .
+@prefix rdfs: .
+@prefix this: .
+@prefix xml: .
+@prefix xsd: .
+
+ a bald:Container ;
+ bald:contains this:var0,
+ this:var1 ;
+ bald:isPrefixedBy "prefix_list" ;
+ NetCDF:title "Sample netCDF file definition with alias terms from the netCDF user guide" .
+
+this:var0 a bald:Subject ;
+ rdfs:label rdfs:label .
+
+this:var1 a bald:Subject ;
+ rdfs:label rdfs:label .
+
diff --git a/lib/bald/tests/integration/test_ogc_conformance.py b/lib/bald/tests/integration/test_ogc_conformance.py
new file mode 100644
index 0000000..5951831
--- /dev/null
+++ b/lib/bald/tests/integration/test_ogc_conformance.py
@@ -0,0 +1,79 @@
+import os
+import subprocess
+import unittest
+
+import netCDF4
+import numpy as np
+
+import bald
+from bald.tests import BaldTestCase
+
+class Test(BaldTestCase):
+ def setUp(self):
+ self.cdl_path = os.path.join(os.path.dirname(__file__), 'CDL')
+ self.ttl_path = os.path.join(os.path.dirname(__file__), 'TTL')
+ self.maxDiff = None
+
+ def test_conformance_a(self):
+ with self.temp_filename('.nc') as tfile:
+ cdlname = 'ogcClassA.cdl'
+ cdl_file = os.path.join(self.cdl_path, cdlname)
+ 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:
+ expected_ttl = sf.read()
+ 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)
+ 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:
+ expected_ttl = sf.read()
+ 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)
+ 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:
+ expected_ttl = sf.read()
+ 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)
+ 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:
+ expected_ttl = sf.read()
+ self.assertEqual(expected_ttl, ttl)