Пример #1
0
    async def test__populate_signals(self, *, livecheck, execution):
        events = Mock()
        signal = SignalEvent(
            signal_name='foo',
            case_name=execution.case_name,
            key=b'k',
            value=b'v',
        )
        signal2 = SignalEvent(
            signal_name='foo',
            case_name='bar',
            key=b'k2',
            value=b'v2',
        )
        case = livecheck.cases[execution.case_name] = Mock(
            resolve_signal=AsyncMock(), )
        livecheck.cases.pop('bar', None)  # make sure 'bar' is missing

        async def iterate_events():
            yield execution.id, signal
            yield execution.id, signal2

        events.items.side_effect = iterate_events

        await livecheck._populate_signals(events)
        case.resolve_signal.assert_called_once_with(execution.id, signal)
Пример #2
0
 async def test_send__no_test_force(self, *, signal):
     signal.case = Mock(app=Mock(bus=Mock(send=AsyncMock())))
     await signal.send('value', key='k', force=True)
     signal.case.app.bus.send.coro.assert_called_once_with(
         key='k',
         value=SignalEvent(
             signal_name=signal.name,
             case_name=signal.case.name,
             key='k',
             value='value',
         ),
     )
Пример #3
0
 async def test_send(self, *, signal, execution):
     with current_test_stack.push(execution):
         signal.case = Mock(app=Mock(bus=Mock(send=AsyncMock())))
         await signal.send('value', key=None, force=True)
         signal.case.app.bus.send.coro.assert_called_once_with(
             key=execution.id,
             value=SignalEvent(
                 signal_name=signal.name,
                 case_name=signal.case.name,
                 key=execution.id,
                 value='value',
             ),
         )