def test_mismatch_oneth(self): with self.temp_filename('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) f = _create_parent_child(f, (11, 17), (13, 17)) f.close() validation = bald.validate_hdf5(tfile) self.assertFalse(validation.is_valid())
def test_match(self): with self.temp_filename('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) f = _create_parent_child(f, (11, 17), (11, 17)) f.close() validation = bald.validate_hdf5(tfile, cache=self.acache) exns = validation.exceptions() self.assertTrue(validation.is_valid(), msg='{} != []'.format(exns))
def test_match_clead_dim(self): with self.temp_filename('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) # child has leading dimension wrt parent f = _create_parent_child(f, (13, 17), (7, 13, 17)) f.close() validation = bald.validate_hdf5(tfile) self.assertTrue(validation.is_valid())
def test_invalid_uri(self): with self.temp_filename('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) f = _create_parent_child(f, (11, 17), (11, 17)) f.attrs['bald__turtle'] = 'bald__walnut' f.close() validation = bald.validate_hdf5(tfile) self.assertFalse(validation.is_valid())
def test_mismatch_pdisjc_trail_dim(self): with self.temp_filename('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) # child and parent have disjoint trailing dimensions f = _create_parent_child(f, (13, 17, 2), (13, 17, 9)) f.close() validation = bald.validate_hdf5(tfile) self.assertFalse(validation.is_valid())
def test_match(self): with self.temp_filename('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) f = _create_parent_child(f, (11, 17), (11, 17)) f.close() validation = bald.validate_hdf5(tfile) exns = validation.exceptions() self.assertTrue(validation.is_valid(), msg='{} != []'.format(exns))
def test_match_clead_dim(self): with self.temp_filename('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) # child has leading dimension wrt parent f = _create_parent_child(f, (13, 17), (7, 13, 17)) f.close() validation = bald.validate_hdf5(tfile, cache=self.acache) exs = validation.exceptions() self.assertTrue(validation.is_valid(), msg='{} != []'.format(exs))
def test_valid_uri(self): with self.temp_filename('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) group_alias = f.create_group('bald__alias_list') f.attrs['bald__isAliasedBy'] = group_alias.ref group_alias.attrs['skosPrefLabel'] = 'http://www.w3.org/2004/02/skos/core#prefLabel' dsetp = f.create_dataset("parent_dataset", (11, 17), dtype='i') dsetp.attrs['skosPrefLabel'] = 'alabel' f.close() validation = bald.validate_hdf5(tfile, cache=self.acache) exns = validation.exceptions() self.assertTrue(validation.is_valid(), msg='{} != []'.format(exns))
def test_valid_uri(self): with self.temp_filename('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) group_alias = f.create_group('bald__alias_list') f.attrs['bald__isAliasedBy'] = group_alias.ref group_alias.attrs['skosPrefLabel'] = 'http://www.w3.org/2004/02/skos/core#prefLabel' dsetp = f.create_dataset("parent_dataset", (11, 17), dtype='i') dsetp.attrs['skosPrefLabel'] = 'alabel' f.close() validation = bald.validate_hdf5(tfile) exns = validation.exceptions() self.assertTrue(validation.is_valid(), msg='{} != []'.format(exns))
def test_mismatch_oneth(self): with self.temp_filename('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) f = _create_parent_child(f, (11, 17), (13, 17)) f.close() validation = bald.validate_hdf5(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('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) f.attrs['bald__turtle'] = 'bald__walnut' group_alias = f.create_group('bald__alias_list') f.attrs['bald__isAliasedBy'] = group_alias.ref group_alias.attrs[ 'skosPrefLabel'] = 'http://www.w3.org/2004/02/skos/core#notThisPrefLabel' dsetp = f.create_dataset("parent_dataset", (11, 17), dtype='i') dsetp.attrs['skosPrefLabel'] = 'alabel' f.close() validation = bald.validate_hdf5(tfile) self.assertFalse(validation.is_valid())
def test_mismatch_pdisjc_trail_dim(self): with self.temp_filename('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) # child and parent have disjoint trailing dimensions f = _create_parent_child(f, (13, 17, 2), (13, 17, 9)) f.close() validation = bald.validate_hdf5(tfile) exns = validation.exceptions() expected = [ 'parent_dataset declares a child of child_dataset 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('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) f = _create_parent_child(f, (11, 17), (11, 17)) f.attrs['bald__turtle'] = 'bald__walnut' f.close() validation = bald.validate_hdf5(tfile, cache=self.acache, uris_resolve=True) 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('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) f = _create_parent_child(f, (11, 17), (11, 17)) f.attrs['bald__turtle'] = 'bald__walnut' f.close() validation = bald.validate_hdf5(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('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) f.attrs['bald__turtle'] = 'bald__walnut' group_alias = f.create_group('bald__alias_list') f.attrs['bald__isAliasedBy'] = group_alias.ref group_alias.attrs['skosPrefLabel'] = 'http://www.w3.org/2004/02/skos/core#notThisPrefLabel' dsetp = f.create_dataset("parent_dataset", (11, 17), dtype='i') dsetp.attrs['skosPrefLabel'] = 'alabel' f.close() validation = bald.validate_hdf5(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('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) f.attrs['bald__turtle'] = 'bald__walnut' group_alias = f.create_group('bald__alias_list') f.attrs['bald__isAliasedBy'] = group_alias.ref group_alias.attrs['skosPrefLabel'] = 'http://www.w3.org/2004/02/skos/core#notThisPrefLabel' dsetp = f.create_dataset("parent_dataset", (11, 17), dtype='i') dsetp.attrs['skosPrefLabel'] = 'alabel' f.close() validation = bald.validate_hdf5(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_mismatch_oneth(self): with self.temp_filename('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) f = _create_parent_child(f, (11, 17), (13, 17)) f.close() fname = ('file:///tests/integration/test_validation/Test/' 'test_mismatch_oneth.hdf') validation = bald.validate_hdf5(tfile, baseuri=fname, cache=self.acache) exns = validation.exceptions() expected = ['file:///tests/integration/test_validation/Test/' 'test_mismatch_oneth.hdf/parent_dataset declares a ' 'child of file:///tests/integration/test_validation/' 'Test/test_mismatch_oneth.hdf/child_dataset 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_mismatch_pdisjc_trail_dim(self): with self.temp_filename('.hdf') as tfile: f = h5py.File(tfile, "w") f = _fattrs(f) # child and parent have disjoint trailing dimensions f = _create_parent_child(f, (13, 17, 2), (13, 17, 9)) f.close() fname = ('file:///tests/integration/test_validation/Test/' 'test_mismatch_pdisjc_trail_dim.hdf') validation = bald.validate_hdf5(tfile, baseuri=fname, cache=self.acache) exns = validation.exceptions() expected = ['file:///tests/integration/test_validation/Test/' 'test_mismatch_pdisjc_trail_dim.hdf/parent_dataset' ' declares a child of file:///tests/integration/' 'test_validation/Test/test_mismatch_pdisjc_trail_dim' '.hdf/child_dataset 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))