def atest(self): with self.temp_filename('.nc') as tfile: subprocess.check_call(['ncgen', '-o', tfile, cdlfile]) validation = bald.validate_netcdf(tfile, cache=self.acache) exns = validation.exceptions() self.assertTrue(validation.is_valid(), msg='{} != []'.format(exns))
def test_process_chain(self): with self.temp_filename('.nc') as tfile: cdl_file = os.path.join(self.cdl_path, 'ProcessChain0300.cdl') subprocess.check_call(['ncgen', '-o', tfile, cdl_file]) validation = bald.validate_netcdf(tfile) exns = validation.exceptions() self.assertTrue(validation.is_valid(), msg='{} != []'.format(exns))
def test_mismatch_zeroth(self): with self.temp_filename('.nc') as tfile: f = netCDF4.Dataset(tfile, "w", format="NETCDF4") f = _fattrs(f) f = _create_parent_child(f, (11, 17), (11, 13)) f.close() validation = bald.validate_netcdf(tfile) self.assertFalse(validation.is_valid())
def test_valid_uri(self): with self.temp_filename('.nc') as tfile: f = netCDF4.Dataset(tfile, "w", format="NETCDF4") f = _fattrs(f) f.close() validation = bald.validate_netcdf(tfile) self.assertTrue(validation.is_valid())
def test_validate_multi_array_reference(self): cdlfile = os.path.join(self.cdl_path, 'multi_array_reference.cdl') with self.temp_filename('.nc') as tfile: subprocess.check_call(['ncgen', '-o', tfile, cdlfile]) validation = bald.validate_netcdf(tfile, cache=self.acache) exns = validation.exceptions() self.assertTrue(validation.is_valid(), msg='{} != []'.format(exns))
def test_match(self): with self.temp_filename('.nc') as tfile: f = netCDF4.Dataset(tfile, "w", format="NETCDF4") f = _fattrs(f) f = _create_parent_child(f, (11, 17), (11, 17)) f.close() validation = bald.validate_netcdf(tfile) 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") f = _fattrs(f) setattr(f, 'bald__turtle', 'bald__walnut') f.close() validation = bald.validate_netcdf(tfile) self.assertFalse(validation.is_valid())
def test_valid_uri(self): with self.temp_filename('.nc') as tfile: f = netCDF4.Dataset(tfile, "w", format="NETCDF4_CLASSIC") f = _fattrs(f) f.close() validation = bald.validate_netcdf(tfile, cache=self.acache) exns = validation.exceptions() self.assertTrue(validation.is_valid(), msg='{} != []'.format(exns))
def test_match(self): with self.temp_filename('.nc') as tfile: f = netCDF4.Dataset(tfile, "w", format="NETCDF4") f = _fattrs(f) f = _create_parent_child(f, (11, 17), (11, 17)) f.close() validation = bald.validate_netcdf(tfile, cache=self.acache) exns = validation.exceptions() self.assertTrue(validation.is_valid(), msg='{} != []'.format(exns))
def test_valid_uri(self): with self.temp_filename('.nc') as tfile: f = netCDF4.Dataset(tfile, "w", format="NETCDF4") f = _fattrs(f) f.close() validation = bald.validate_netcdf(tfile, cache=self.acache) exns = validation.exceptions() self.assertTrue(validation.is_valid(), msg='{} != []'.format(exns))
def test_mismatch_zeroth(self): with self.temp_filename('.nc') as tfile: f = netCDF4.Dataset(tfile, "w", format="NETCDF4") f = _fattrs(f) f = _create_parent_child(f, (11, 17), (11, 13)) f.close() validation = bald.validate_netcdf(tfile) exns = validation.exceptions() expected = ['p declares a child of c but the arrays do not conform to the bald array reference rules'] self.assertTrue((not validation.is_valid()) and exns == expected, msg='{} != {}'.format(exns, expected))
def test_invalid_uri(self): with self.temp_filename('.nc') as tfile: f = netCDF4.Dataset(tfile, "w", format="NETCDF4") f = _fattrs(f) setattr(f, 'bald__turtle', 'bald__walnut') f.close() validation = bald.validate_netcdf(tfile) exns = validation.exceptions() expected = ['http://binary-array-ld.net/latest/turtle is not resolving as a resource (404).', 'http://binary-array-ld.net/latest/walnut is not resolving as a resource (404).'] self.assertTrue((not validation.is_valid()) and exns == expected, msg='{} != {}'.format(exns, expected))
def test_invalid_uri(self): with self.temp_filename('.nc') as tfile: f = netCDF4.Dataset(tfile, "w", format="NETCDF4") f = _fattrs(f) setattr(f, 'bald__turtle', 'bald__walnut') f.close() validation = bald.validate_netcdf(tfile, cache=self.acache) exns = validation.exceptions() expected = ['http://binary-array-ld.net/latest/turtle is not resolving as a resource (404).', 'http://binary-array-ld.net/latest/walnut is not resolving as a resource (404).'] self.assertTrue((not validation.is_valid()) and exns == expected, msg='{} != {}'.format(exns, expected))
def test_grid_OISST_GHRSST(self): """Override grid OISST GHRSST test with currently accepted failures""" with self.temp_filename('.nc') as tfile: cdl_file = os.path.join(self.cdl_path, 'grid_OISST_GHRSST.cdl') subprocess.check_call(['ncgen', '-o', tfile, cdl_file]) validation = bald.validate_netcdf(tfile, cache=self.acache) exns = validation.exceptions() exns.sort() expected = ['http://www.ncdc.noaa.gov/sst is not resolving as a resource (404).', 'http://www.ncdc.noaa.gov/sst/ is not resolving as a resource (404).'] expected.sort() self.assertTrue(not validation.is_valid() and exns == expected, msg='{} \n!= \n{}'.format(exns, expected))
def test_grid_OISST_GHRSST(self): """Override grid OISST GHRSST test with currently accepted failures""" with self.temp_filename('.nc') as tfile: cdl_file = os.path.join(self.cdl_path, 'grid_OISST_GHRSST.cdl') subprocess.check_call(['ncgen', '-o', tfile, cdl_file]) validation = bald.validate_netcdf(tfile) exns = validation.exceptions() exns.sort() expected = ['http://www.ncdc.noaa.gov/sst is not resolving as a resource (404).', 'http://www.ncdc.noaa.gov/sst/ is not resolving as a resource (404).'] expected.sort() self.assertTrue(not validation.is_valid() and exns == expected, msg='{} \n!= \n{}'.format(exns, expected))
def test_mismatch_zeroth(self): with self.temp_filename('.nc') as tfile: f = netCDF4.Dataset(tfile, "w", format="NETCDF4") f = _fattrs(f) f = _create_parent_child(f, (11, 17), (11, 13)) f.close() validation = bald.validate_netcdf(tfile, cache=self.acache) exns = validation.exceptions() expected = [('file://{t}/source_variable declares a target of ' 'file://{t}/target_variable but the arrays do not ' 'conform to the bald array reference rules' '').format(t=tfile)] self.assertTrue((not validation.is_valid()) and exns == expected, msg='{} != {}'.format(exns, expected))
def test_mismatch_zeroth(self): with self.temp_filename('.nc') as tfile: f = netCDF4.Dataset(tfile, "w", format="NETCDF4") f = _fattrs(f) f = _create_parent_child(f, (11, 17), (11, 13)) f.close() validation = bald.validate_netcdf(tfile, cache=self.acache) exns = validation.exceptions() expected = [('file://{t}/parent_variable declares a child of ' 'file://{t}/child_variable but the arrays do not ' 'conform to the bald array reference rules' '').format(t=tfile)] self.assertTrue((not validation.is_valid()) and exns == expected, msg='{} != {}'.format(exns, expected))
def test_ereefs_gbr4_ncld(self): """Override ereefs test with currently accepted failures""" with self.temp_filename('.nc') as tfile: cdl_file = os.path.join(self.cdl_path, 'ereefs_gbr4_ncld.cdl') subprocess.check_call(['ncgen', '-o', tfile, cdl_file]) validation = bald.validate_netcdf(tfile, cache=self.acache) exns = validation.exceptions() exns.sort() expected = ['http://qudt.org/vocab/unit#Meter is not resolving as a resource (404).', 'http://qudt.org/vocab/unit#MeterPerSecond is not resolving as a resource (404).', 'http://qudt.org/vocab/unit#MeterPerSecond is not resolving as a resource (404).', 'http://qudt.org/vocab/unit#DegreeCelsius is not resolving as a resource (404).'] expected.sort() self.assertTrue(not validation.is_valid() and exns == expected, msg='{} \n!= \n{}'.format(exns, expected))
def test_ereefs_gbr4_ncld(self): """Override ereefs test with currently accepted failures""" with self.temp_filename('.nc') as tfile: cdl_file = os.path.join(self.cdl_path, 'ereefs_gbr4_ncld.cdl') subprocess.check_call(['ncgen', '-o', tfile, cdl_file]) validation = bald.validate_netcdf(tfile) exns = validation.exceptions() exns.sort() expected = ['http://qudt.org/vocab/unit#Meter is not resolving as a resource (404).', 'http://qudt.org/vocab/unit#MeterPerSecond is not resolving as a resource (404).', 'http://qudt.org/vocab/unit#MeterPerSecond is not resolving as a resource (404).', 'http://qudt.org/vocab/unit#DegreeCelsius is not resolving as a resource (404).'] expected.sort() self.assertTrue(not validation.is_valid() and exns == expected, msg='{} \n!= \n{}'.format(exns, expected))
def atest(self): with self.temp_filename('.nc') as tfile: subprocess.check_call(['ncgen', '-o', tfile, cdlfile]) validation = bald.validate_netcdf(tfile, cache=self.acache) exns = validation.exceptions() self.assertTrue(validation.is_valid(), msg='{} != []'.format(exns))