コード例 #1
0
ファイル: test_arctic.py プロジェクト: manahl/arctic
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)
コード例 #2
0
ファイル: libs.py プロジェクト: davidduenas3/binarctic
 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
コード例 #3
0
ファイル: test_arctic.py プロジェクト: gitter-badger/arctic
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)
コード例 #4
0
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)
コード例 #5
0
ファイル: test_arctic.py プロジェクト: manahl/arctic
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
コード例 #6
0
ファイル: test_arctic.py プロジェクト: wremin/arctic
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
コード例 #7
0
ファイル: test_arctic.py プロジェクト: keepsimpler/arctic
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)
    )