Ejemplo n.º 1
0
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'
Ejemplo n.º 2
0
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'
Ejemplo n.º 3
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
Ejemplo n.º 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
Ejemplo n.º 5
0
def test_must_call_prepare_before_get_instance():

    TChannel.reset()

    with pytest.raises(SingletonNotPreparedError):
        TChannel.get_instance()
Ejemplo n.º 6
0
def test_get_instance_is_singleton():

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

    assert TChannel.get_instance() is TChannel.get_instance()
Ejemplo n.º 7
0
def test_must_call_prepare_before_get_instance():

    TChannel.reset()

    with pytest.raises(SingletonNotPreparedError):
        TChannel.get_instance()
Ejemplo n.º 8
0
def test_get_instance_is_singleton():

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

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