def test_register_library_type(): class DummyType(object): pass register_library_type("new_dummy_type", DummyType) assert LIBRARY_TYPES['new_dummy_type'] == DummyType with pytest.raises(ArcticException) as e: register_library_type("new_dummy_type", DummyType) assert "ArcticException: Library new_dummy_type already registered" in str(e)
def _wrapper(cls): try: arctic.register_library_type(lib_type, cls) cls.lib_type = lib_type cls.factory = staticmethod( lambda name, **initkw: _cls(name, lib_type, **initkw)) return cls except exceptions.ArcticException as e: raise e
def test_register_library_type(): class DummyType(object): pass register_library_type("new_dummy_type", DummyType) assert LIBRARY_TYPES['new_dummy_type'] == DummyType with pytest.raises(ArcticException) as e: register_library_type("new_dummy_type", DummyType) assert "ArcticException: Library new_dummy_type already registered as <class 'tests.unit.test_arctic.DummyType'>" in str(e)
def test_register_library_type(): class DummyType(object): pass register_library_type("new_dummy_type", DummyType) assert LIBRARY_TYPES['new_dummy_type'] == DummyType with pytest.raises(ArcticException) as e: register_library_type("new_dummy_type", DummyType) assert "Library new_dummy_type already registered" in str(e.value)
def test_get_library(): self = create_autospec(Arctic) self._library_cache = {} library_type = Mock() register_library_type(sentinel.lib_type, library_type) with patch('arctic.arctic.ArcticLibraryBinding', autospec=True) as ML: ML.return_value.get_library_type.return_value = sentinel.lib_type library = Arctic.get_library(self, sentinel.lib_name) del LIBRARY_TYPES[sentinel.lib_type] assert ML.call_args_list == [call(self, sentinel.lib_name)] assert library_type.call_args_list == [call(ML.return_value)] assert library == library_type.return_value
def test_register_library_type(): class DummyType(object): pass register_library_type("new_dummy_type", DummyType) assert LIBRARY_TYPES["new_dummy_type"] == DummyType with pytest.raises(ArcticException) as e: register_library_type("new_dummy_type", DummyType) assert ( "ArcticException: Library new_dummy_type already registered as <class 'tests.unit.test_arctic.DummyType'>" in str(e) )