testing and polishing
This commit is contained in:
parent
a5bd0958a1
commit
72a0b1fae5
|
@ -36,7 +36,7 @@ class Result:
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
fname : str
|
fname : str
|
||||||
name of the DADF5 file to be openend.
|
name of the DADF5 file to be opened.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
with h5py.File(fname,'r') as f:
|
with h5py.File(fname,'r') as f:
|
||||||
|
@ -173,7 +173,7 @@ class Result:
|
||||||
util.bcolors().ENDC)
|
util.bcolors().ENDC)
|
||||||
self._allow_modification = True
|
self._allow_modification = True
|
||||||
|
|
||||||
def forbid_modification(self):
|
def disallow_modification(self):
|
||||||
self._allow_modification = False
|
self._allow_modification = False
|
||||||
|
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ class Result:
|
||||||
f[path_new].attrs['Renamed'] = 'Original name: {}'.encode()
|
f[path_new].attrs['Renamed'] = 'Original name: {}'.encode()
|
||||||
del f[path_old]
|
del f[path_old]
|
||||||
else:
|
else:
|
||||||
print('Rename operation not permitted')
|
raise PermissionError('Rename operation not permitted')
|
||||||
|
|
||||||
|
|
||||||
# def datamerger(regular expression to filter groups into one copy)
|
# def datamerger(regular expression to filter groups into one copy)
|
||||||
|
|
|
@ -281,15 +281,14 @@ class TestResult:
|
||||||
|
|
||||||
default.add_Cauchy()
|
default.add_Cauchy()
|
||||||
loc = default.get_dataset_location('sigma')
|
loc = default.get_dataset_location('sigma')
|
||||||
print(loc)
|
|
||||||
with h5py.File(default.fname,'r') as f:
|
with h5py.File(default.fname,'r') as f:
|
||||||
created_first = f[loc[0]].attrs['Created'].decode()
|
created_first = f[loc[0]].attrs['Created'].decode()
|
||||||
created_first = datetime.strptime(created_first,'%Y-%m-%d %H:%M:%S%z')
|
created_first = datetime.strptime(created_first,'%Y-%m-%d %H:%M:%S%z')
|
||||||
|
|
||||||
if overwrite == 'on':
|
if overwrite == 'on':
|
||||||
default.enable_overwrite()
|
default.allow_modification()
|
||||||
else:
|
else:
|
||||||
default.disable_overwrite()
|
default.disallow_modification()
|
||||||
|
|
||||||
time.sleep(2.)
|
time.sleep(2.)
|
||||||
default.add_calculation('sigma','#sigma#*0.0+311.','not the Cauchy stress')
|
default.add_calculation('sigma','#sigma#*0.0+311.','not the Cauchy stress')
|
||||||
|
@ -301,6 +300,18 @@ class TestResult:
|
||||||
else:
|
else:
|
||||||
assert created_first == created_second and not np.allclose(default.read_dataset(loc),311.)
|
assert created_first == created_second and not np.allclose(default.read_dataset(loc),311.)
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('allowed',['off','on'])
|
||||||
|
def test_rename(self,default,allowed):
|
||||||
|
F = default.read_dataset(default.get_dataset_location('F'))
|
||||||
|
if allowed == 'on':
|
||||||
|
default.allow_modification()
|
||||||
|
default.rename('F','new_name')
|
||||||
|
assert np.all(F == default.read_dataset(default.get_dataset_location('new_name')))
|
||||||
|
default.disallow_modification()
|
||||||
|
|
||||||
|
with pytest.raises(PermissionError):
|
||||||
|
default.rename('P','another_new_name')
|
||||||
|
|
||||||
@pytest.mark.parametrize('output',['F',[],['F','P']])
|
@pytest.mark.parametrize('output',['F',[],['F','P']])
|
||||||
def test_vtk(self,tmp_path,default,output):
|
def test_vtk(self,tmp_path,default,output):
|
||||||
os.chdir(tmp_path)
|
os.chdir(tmp_path)
|
||||||
|
|
Loading…
Reference in New Issue