def test_get_instance_returns_configured_tchannel():

    TChannel.reset()
    TChannel.prepare('my-app')

    tchannel = TChannel.get_instance()

    assert isinstance(tchannel, AsyncTChannel)
    assert tchannel.name == 'my-app'
def test_get_instance_returns_configured_tchannel():

    TChannel.reset()
    TChannel.prepare('my-app')

    tchannel = TChannel.get_instance()

    assert isinstance(tchannel, AsyncTChannel)
    assert tchannel.name == 'my-app'
def test_stored_seperately_from_async_singleton():

    TChannel.reset()
    AsyncSingleton.reset()

    AsyncSingleton.prepare('async-app')

    with pytest.raises(SingletonNotPreparedError):
        TChannel.get_instance()

    TChannel.prepare('sync-app')

    instance = TChannel.get_instance()

    assert isinstance(instance,  SyncTChannel)
    assert AsyncSingleton.get_instance() is not instance
示例#4
0
def test_stored_seperately_from_async_singleton():

    TChannel.reset()
    AsyncSingleton.reset()

    AsyncSingleton.prepare('async-app')

    with pytest.raises(SingletonNotPreparedError):
        TChannel.get_instance()

    TChannel.prepare('sync-app')

    instance = TChannel.get_instance()

    assert isinstance(instance,  SyncTChannel)
    assert AsyncSingleton.get_instance() is not instance
def test_must_call_prepare_before_get_instance():

    TChannel.reset()

    with pytest.raises(SingletonNotPreparedError):
        TChannel.get_instance()
def test_get_instance_is_singleton():

    TChannel.reset()
    TChannel.prepare('my-app')

    assert TChannel.get_instance() is TChannel.get_instance()
def test_must_call_prepare_before_get_instance():

    TChannel.reset()

    with pytest.raises(SingletonNotPreparedError):
        TChannel.get_instance()
def test_get_instance_is_singleton():

    TChannel.reset()
    TChannel.prepare('my-app')

    assert TChannel.get_instance() is TChannel.get_instance()