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))
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))
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) )
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))
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))
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) )
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))
def test_ndarray(self, empty_registry): registries = RegistryContainer(empty_registry) ndarray = np.random.rand(1000) assert all(ndarray == registries.dump(ndarray))
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)
def test_h5py_soft_link(self, empty_registry): registries = RegistryContainer(empty_registry) soft_link = SoftLink("/example") assert soft_link == registries.dump(soft_link)
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)
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)
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
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
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)
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)
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)
def test_hardlink(self, empty_registry): registries = RegistryContainer(empty_registry) hard_link = HardLink("/example") assert hard_link == registries.dump(hard_link)
def obj_registry(request): return { "registries": RegistryContainer(request.param[0]), "dumpable_object": request.param[1] }
def obj_registry_with_none(request): return { "registries": RegistryContainer(request.param[0]), "dumpable_object": get_fixture_val(request.param[1], request) }