Esempio n. 1
0
def test_delitem(app):
    signal = Signal(app)
    m1 = mock.Mock()
    signal.append(m1)
    assert len(signal) == 1
    del signal[0]
    assert len(signal) == 0
Esempio n. 2
0
def function2805(function1121):
    var1658 = Signal(function1121)
    var921 = mock.Mock()
    var1658.append(var921)
    assert (len(var1658) == 1)
    del var1658[0]
    assert (len(var1658) == 0)
Esempio n. 3
0
def test_delitem(app):
    signal = Signal(app)
    m1 = mock.Mock()
    signal.append(m1)
    assert len(signal) == 1
    del signal[0]
    assert len(signal) == 0
Esempio n. 4
0
def function2296(function1121):
    var2457 = Signal(function1121)
    var2367 = mock.Mock()
    var2457.append(var2367)
    var2457.freeze()
    with pytest.raises(RuntimeError):
        del var2457[0]
    assert (list(var2457) == [var2367])
Esempio n. 5
0
def test_setitem(app):
    signal = Signal(app)
    m1 = mock.Mock()
    signal.append(m1)
    assert signal[0] is m1
    m2 = mock.Mock()
    signal[0] = m2
    assert signal[0] is m2
Esempio n. 6
0
def function1396(function1121):
    var3642 = Signal(function1121)
    var1856 = mock.Mock()
    var3642.append(var1856)
    assert (var3642[0] is var1856)
    var259 = mock.Mock()
    var3642[0] = var259
    assert (var3642[0] is var259)
Esempio n. 7
0
def test_setitem(app):
    signal = Signal(app)
    m1 = mock.Mock()
    signal.append(m1)
    assert signal[0] is m1
    m2 = mock.Mock()
    signal[0] = m2
    assert signal[0] is m2
Esempio n. 8
0
async def test_repr(app: Any) -> None:
    signal = Signal(app)

    callback = make_mocked_coro()

    signal.append(callback)

    assert Matches(r"<Signal owner=<Application .+>, frozen=False, "
                   r"\[<Mock id='\d+'>\]>") == repr(signal)
Esempio n. 9
0
def test_cannot_delitem_in_frozen_signal(app):
    signal = Signal(app)
    m1 = mock.Mock()
    signal.append(m1)
    signal.freeze()
    with pytest.raises(RuntimeError):
        del signal[0]

    assert list(signal) == [m1]
Esempio n. 10
0
def function2559(function1121):
    var98 = Signal(function1121)
    var2142 = mock.Mock()
    var516 = mock.Mock()
    var98.append(var2142)
    var98.freeze()
    with pytest.raises(RuntimeError):
        var98[0] = var516
    assert (list(var98) == [var2142])
Esempio n. 11
0
def function2183(function1121):
    var4737 = Signal(function1121)
    var805 = mock.Mock()
    var3494 = mock.Mock()
    var4737.append(var805)
    var4737.freeze()
    with pytest.raises(RuntimeError):
        var4737.append(var3494)
    assert (list(var4737) == [var805])
Esempio n. 12
0
def test_cannot_delitem_in_frozen_signal(app):
    signal = Signal(app)
    m1 = mock.Mock()
    signal.append(m1)
    signal.freeze()
    with pytest.raises(RuntimeError):
        del signal[0]

    assert list(signal) == [m1]
Esempio n. 13
0
async def test_repr(app) -> None:
    signal = Signal(app)

    callback = make_mocked_coro()

    signal.append(callback)

    assert re.match(r"<Signal owner=<Application .+>, frozen=False, "
                    r"\[<Mock id='\d+'>\]>",
                    repr(signal))
Esempio n. 14
0
def test_cannot_setitem_in_frozen_signal(app) -> None:
    signal = Signal(app)
    m1 = mock.Mock()
    m2 = mock.Mock()
    signal.append(m1)
    signal.freeze()
    with pytest.raises(RuntimeError):
        signal[0] = m2

    assert list(signal) == [m1]
Esempio n. 15
0
def test_cannot_append_to_frozen_signal(app):
    signal = Signal(app)
    m1 = mock.Mock()
    m2 = mock.Mock()
    signal.append(m1)
    signal.freeze()
    with pytest.raises(RuntimeError):
        signal.append(m2)

    assert list(signal) == [m1]
Esempio n. 16
0
def function1362(function1121):
    var676 = Signal(function1121)
    var2961 = {
        'foo': 1,
        'bar': 2,
    }
    function382 = mock.Mock()
    var676.append(function382)
    yield from var676.send(None=var2961)
    function382.assert_called_once_with(None=var2961)
Esempio n. 17
0
async def test_non_coroutine(app):
    signal = Signal(app)
    kwargs = {'foo': 1, 'bar': 2}

    callback = mock.Mock()

    signal.append(callback)

    await signal.send(**kwargs)
    callback.assert_called_once_with(**kwargs)
Esempio n. 18
0
def test_cannot_setitem_in_frozen_signal(app: Any) -> None:
    signal = Signal(app)
    m1 = mock.Mock()
    m2 = mock.Mock()
    signal.append(m1)
    signal.freeze()
    with pytest.raises(RuntimeError):
        signal[0] = m2

    assert list(signal) == [m1]
Esempio n. 19
0
def test_cannot_append_to_frozen_signal(app):
    signal = Signal(app)
    m1 = mock.Mock()
    m2 = mock.Mock()
    signal.append(m1)
    signal.freeze()
    with pytest.raises(RuntimeError):
        signal.append(m2)

    assert list(signal) == [m1]
Esempio n. 20
0
def test_non_coroutine(app):
    signal = Signal(app)
    kwargs = {'foo': 1, 'bar': 2}

    callback = mock.Mock()

    signal.append(callback)

    yield from signal.send(**kwargs)
    callback.assert_called_once_with(**kwargs)
Esempio n. 21
0
def test_non_coroutine(loop, app):
    signal = Signal(app)
    kwargs = {'foo': 1, 'bar': 2}

    callback = mock.Mock()

    signal.append(callback)

    loop.run_until_complete(signal.send(**kwargs))
    callback.assert_called_once_with(**kwargs)
Esempio n. 22
0
async def test_repr(app):
    signal = Signal(app)

    callback = make_mocked_coro()

    signal.append(callback)

    assert re.match(
        r"<Signal owner=<Application .+>, frozen=False, "
        r"\[<Mock id='\d+'>\]>", repr(signal))
Esempio n. 23
0
async def test_cannot_send_non_frozen_signal(app):
    signal = Signal(app)

    callback = make_mocked_coro()

    signal.append(callback)

    with pytest.raises(RuntimeError):
        await signal.send()

    assert not callback.called
Esempio n. 24
0
async def test_non_coroutine(app: Any) -> None:
    signal = Signal(app)
    kwargs = {"foo": 1, "bar": 2}

    callback = mock.Mock()

    signal.append(callback)
    signal.freeze()

    with pytest.raises(TypeError):
        await signal.send(**kwargs)
Esempio n. 25
0
async def test_non_coroutine(app):
    signal = Signal(app)
    kwargs = {'foo': 1, 'bar': 2}

    callback = mock.Mock()

    signal.append(callback)
    signal.freeze()

    with pytest.raises(TypeError):
        await signal.send(**kwargs)
Esempio n. 26
0
async def test_cannot_send_non_frozen_signal(app) -> None:
    signal = Signal(app)

    callback = make_mocked_coro()

    signal.append(callback)

    with pytest.raises(RuntimeError):
        await signal.send()

    assert not callback.called
Esempio n. 27
0
async def test_non_coroutine(app) -> None:
    signal = Signal(app)
    kwargs = {'foo': 1, 'bar': 2}

    callback = mock.Mock()

    signal.append(callback)
    signal.freeze()

    with pytest.raises(TypeError):
        await signal.send(**kwargs)
Esempio n. 28
0
def function1281(function2688):
    assert function2688.debug, 'Should be True'
    var3888 = Signal(function2688)
    function382 = mock.Mock()
    var3839 = mock.Mock()
    var835 = mock.Mock()
    var3888.append(function382)
    function2688.on_pre_signal.append(var3839)
    function2688.on_post_signal.append(var835)
    yield from var3888.send(1, a=2)
    function382.assert_called_once_with(1, a=2)
    var3839.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2)
    var835.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2)
Esempio n. 29
0
async def test_function_signal_dispatch(app):
    signal = Signal(app)
    kwargs = {'foo': 1, 'bar': 2}

    callback_mock = mock.Mock()

    async def callback(**kwargs):
        callback_mock(**kwargs)

    signal.append(callback)

    await signal.send(**kwargs)
    callback_mock.assert_called_once_with(**kwargs)
Esempio n. 30
0
async def test_function_signal_dispatch(app) -> None:
    signal = Signal(app)
    kwargs = {'foo': 1, 'bar': 2}

    callback_mock = mock.Mock()

    async def callback(**kwargs):
        callback_mock(**kwargs)

    signal.append(callback)
    signal.freeze()

    await signal.send(**kwargs)
    callback_mock.assert_called_once_with(**kwargs)
Esempio n. 31
0
def test_function_signal_dispatch(loop, app):
    signal = Signal(app)
    kwargs = {'foo': 1, 'bar': 2}

    callback_mock = mock.Mock()

    @asyncio.coroutine
    def callback(**kwargs):
        callback_mock(**kwargs)

    signal.append(callback)

    loop.run_until_complete(signal.send(**kwargs))
    callback_mock.assert_called_once_with(**kwargs)
Esempio n. 32
0
async def test_function_signal_dispatch(app: Any) -> None:
    signal = Signal(app)
    kwargs = {"foo": 1, "bar": 2}

    callback_mock = mock.Mock()

    async def callback(**kwargs):
        callback_mock(**kwargs)

    signal.append(callback)
    signal.freeze()

    await signal.send(**kwargs)
    callback_mock.assert_called_once_with(**kwargs)
Esempio n. 33
0
def test_function_signal_dispatch(app):
    signal = Signal(app)
    kwargs = {'foo': 1, 'bar': 2}

    callback_mock = mock.Mock()

    @asyncio.coroutine
    def callback(**kwargs):
        callback_mock(**kwargs)

    signal.append(callback)

    yield from signal.send(**kwargs)
    callback_mock.assert_called_once_with(**kwargs)
Esempio n. 34
0
def test_function_signal_dispatch2(loop, app):
    signal = Signal(app)
    args = {"a", "b"}
    kwargs = {"foo": 1, "bar": 2}

    callback_mock = mock.Mock()

    @asyncio.coroutine
    def callback(*args, **kwargs):
        callback_mock(*args, **kwargs)

    signal.append(callback)

    loop.run_until_complete(signal.send(*args, **kwargs))
    callback_mock.assert_called_once_with(*args, **kwargs)
Esempio n. 35
0
def function105(function1121):
    var3164 = Signal(function1121)
    var96 = {
        'foo': 1,
        'bar': 2,
    }
    var2570 = mock.Mock()

    @asyncio.coroutine
    def function382(**kwargs):
        var2570(None=var96)

    var3164.append(function382)
    yield from var3164.send(None=var96)
    var2570.assert_called_once_with(None=var96)
Esempio n. 36
0
async def test_function_signal_dispatch2(app) -> None:
    signal = Signal(app)
    args = {'a', 'b'}
    kwargs = {'foo': 1, 'bar': 2}

    callback_mock = mock.Mock()

    async def callback(*args, **kwargs):
        callback_mock(*args, **kwargs)

    signal.append(callback)
    signal.freeze()

    await signal.send(*args, **kwargs)
    callback_mock.assert_called_once_with(*args, **kwargs)
Esempio n. 37
0
def function590(function1121):
    var906 = Signal(function1121)
    var730 = {'a', 'b'}
    var1090 = {
        'foo': 1,
        'bar': 2,
    }
    var852 = mock.Mock()

    @asyncio.coroutine
    def function382(*args, **kwargs):
        var852(*var730, None=var1090)

    var906.append(function382)
    yield from var906.send(*var730, None=var1090)
    var852.assert_called_once_with(*var730, None=var1090)
Esempio n. 38
0
def test_debug_signal(loop, debug_app):
    assert debug_app.debug, "Should be True"
    signal = Signal(debug_app)

    callback = mock.Mock()
    pre = mock.Mock()
    post = mock.Mock()

    signal.append(callback)
    debug_app.on_pre_signal.append(pre)
    debug_app.on_post_signal.append(post)

    loop.run_until_complete(signal.send(1, a=2))
    callback.assert_called_once_with(1, a=2)
    pre.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2)
    post.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2)
Esempio n. 39
0
async def test_debug_signal(debug_app):
    assert debug_app.debug, "Should be True"
    signal = Signal(debug_app)

    callback = mock.Mock()
    pre = mock.Mock()
    post = mock.Mock()

    signal.append(callback)
    debug_app.on_pre_signal.append(pre)
    debug_app.on_post_signal.append(post)

    await signal.send(1, a=2)
    callback.assert_called_once_with(1, a=2)
    pre.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2)
    post.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2)
Esempio n. 40
0
def test_debug_signal(debug_app):
    assert debug_app.debug, "Should be True"
    signal = Signal(debug_app)

    callback = mock.Mock()
    pre = mock.Mock()
    post = mock.Mock()

    signal.append(callback)
    debug_app.on_pre_signal.append(pre)
    debug_app.on_post_signal.append(post)

    yield from signal.send(1, a=2)
    callback.assert_called_once_with(1, a=2)
    pre.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2)
    post.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2)