Пример #1
0
 def test_label_not_in_namespace(self, h5preserve_experiment_repr,
                                 no_loader_experiment_registry):
     registries = RegistryContainer(no_loader_experiment_registry)
     with pytest.raises(RuntimeError) as excinfo:
         registries.load(h5preserve_experiment_repr)
     assert ("Label Experiment not in namespace experiment." == str(
         excinfo.value))
Пример #2
0
 def test_invalid_dumper(self, invalid_dumper_experiment_registry,
                         experiment_data):
     registries = RegistryContainer(invalid_dumper_experiment_registry)
     with pytest.raises(TypeError) as excinfo:
         registries._obj_to_h5preserve(experiment_data)
     assert ("Dumper for Experiment with version 1 returned incorrect type."
             == str(excinfo.value))
Пример #3
0
 def test_not_loadable(self, experiment_data):
     registries = RegistryContainer()
     with pytest.raises(TypeError) as excinfo:
         registries.load(experiment_data)
     assert (
         "<class 'conftest.Experiment'> is not something that can be loaded." == str(excinfo.value)
     )
Пример #4
0
 def test_not_loadable(self, experiment_data):
     registries = RegistryContainer()
     with pytest.raises(TypeError) as excinfo:
         registries.load(experiment_data)
     assert (
         "<class 'conftest.Experiment'> is not something that can be loaded."
         == str(excinfo.value))
Пример #5
0
 def test_not_dumpable(self, empty_registry, experiment_data):
     registries = RegistryContainer(empty_registry)
     with pytest.raises(TypeError) as excinfo:
         registries._obj_to_h5preserve(experiment_data)
     assert (
         "<class 'conftest.Experiment'> is not something that can be dumped."
         == str(excinfo.value))
Пример #6
0
 def test_label_not_in_namespace(
     self, h5preserve_experiment_repr, no_loader_experiment_registry
     ):
     registries = RegistryContainer(no_loader_experiment_registry)
     with pytest.raises(RuntimeError) as excinfo:
         registries.load(h5preserve_experiment_repr)
     assert (
         "Label Experiment not in namespace experiment." == str(excinfo.value)
     )
Пример #7
0
 def test_no_version(self, experiment_registry, experiment_data):
     registries = RegistryContainer(experiment_registry)
     registries.lock_version(type(experiment_data), 10)
     with pytest.raises(RuntimeError) as excinfo:
         registries._obj_to_h5preserve(experiment_data)
     assert (
         "<class 'conftest.Experiment'> does not have version 10." == str(
             excinfo.value))
Пример #8
0
 def test_ndarray(self, empty_registry):
     registries = RegistryContainer(empty_registry)
     ndarray = np.random.rand(1000)
     assert all(ndarray == registries.dump(ndarray))
Пример #9
0
 def test_h5py_external_link(self, empty_registry):
     registries = RegistryContainer(empty_registry)
     external_link = ExternalLink("example.hdf5", "/example")
     assert external_link == registries.dump(external_link)
Пример #10
0
 def test_h5py_soft_link(self, empty_registry):
     registries = RegistryContainer(empty_registry)
     soft_link = SoftLink("/example")
     assert soft_link == registries.dump(soft_link)
Пример #11
0
 def test_h5py_dataset(self, empty_registry, h5py_file_with_dataset):
     registries = RegistryContainer(empty_registry)
     dataset = h5py_file_with_dataset["example"]
     assert dataset == registries.dump(dataset)
Пример #12
0
 def test_h5py_group(self, empty_registry, h5py_file_with_group):
     registries = RegistryContainer(empty_registry)
     group = h5py_file_with_group["example"]
     assert group == registries.dump(group)
Пример #13
0
 def test_h5py_dataset(self, empty_registry, h5py_file_with_dataset):
     registries = RegistryContainer(empty_registry)
     dataset = h5py_file_with_dataset["example"]
     assert dataset == registries.dump(dataset)
Пример #14
0
 def test_h5py_external_link(self, empty_registry):
     registries = RegistryContainer(empty_registry)
     external_link = ExternalLink("example.hdf5", "/example")
     assert external_link == registries.dump(external_link)
Пример #15
0
 def test_version(self, experiment_registry, experiment_data):
     registries = RegistryContainer(experiment_registry)
     registries.lock_version(type(experiment_data), 1)
     assert registries._obj_to_h5preserve(experiment_data)._version == 1
Пример #16
0
 def test_none(self, None_version_experiment_registry, experiment_data):
     registries = RegistryContainer(None_version_experiment_registry)
     assert registries._obj_to_h5preserve(experiment_data)._version == None
Пример #17
0
 def test_version(self, experiment_registry, experiment_data):
     registries = RegistryContainer(experiment_registry)
     registries.lock_version(type(experiment_data), 1)
     assert registries._obj_to_h5preserve(experiment_data)._version == 1
Пример #18
0
 def test_ndarray(self, empty_registry):
     registries = RegistryContainer(empty_registry)
     ndarray = np.random.rand(1000)
     assert all(ndarray == registries.dump(ndarray))
Пример #19
0
 def test_not_dumpable(self, empty_registry, experiment_data):
     registries = RegistryContainer(empty_registry)
     with pytest.raises(TypeError) as excinfo:
         registries._obj_to_h5preserve(experiment_data)
     assert "<class 'conftest.Experiment'> is not something that can be dumped." == str(excinfo.value)
Пример #20
0
 def test_invalid_dumper(self, invalid_dumper_experiment_registry, experiment_data):
     registries = RegistryContainer(invalid_dumper_experiment_registry)
     with pytest.raises(TypeError) as excinfo:
         registries._obj_to_h5preserve(experiment_data)
     assert "Dumper for Experiment with version 1 returned incorrect type." == str(excinfo.value)
Пример #21
0
 def test_no_version(self, experiment_registry, experiment_data):
     registries = RegistryContainer(experiment_registry)
     registries.lock_version(type(experiment_data), 10)
     with pytest.raises(RuntimeError) as excinfo:
         registries._obj_to_h5preserve(experiment_data)
     assert "<class 'conftest.Experiment'> does not have version 10." == str(excinfo.value)
Пример #22
0
 def test_h5py_soft_link(self, empty_registry):
     registries = RegistryContainer(empty_registry)
     soft_link = SoftLink("/example")
     assert soft_link == registries.dump(soft_link)
Пример #23
0
 def test_none(self, None_version_experiment_registry, experiment_data):
     registries = RegistryContainer(None_version_experiment_registry)
     assert registries._obj_to_h5preserve(experiment_data)._version == None
Пример #24
0
 def test_hardlink(self, empty_registry):
     registries = RegistryContainer(empty_registry)
     hard_link = HardLink("/example")
     assert hard_link == registries.dump(hard_link)
Пример #25
0
def obj_registry(request):
    return {
        "registries": RegistryContainer(request.param[0]),
        "dumpable_object": request.param[1]
    }
Пример #26
0
 def test_h5py_group(self, empty_registry, h5py_file_with_group):
     registries = RegistryContainer(empty_registry)
     group = h5py_file_with_group["example"]
     assert group == registries.dump(group)
Пример #27
0
 def obj_registry_with_none(request):
     return {
         "registries": RegistryContainer(request.param[0]),
         "dumpable_object": get_fixture_val(request.param[1], request)
     }
Пример #28
0
 def test_hardlink(self, empty_registry):
     registries = RegistryContainer(empty_registry)
     hard_link = HardLink("/example")
     assert hard_link == registries.dump(hard_link)