コード例 #1
0
async def test_sleep_between_send(monitor):
    monitor.start(interval=5)

    await until(lambda: monitor.send_call_count == 1)
    assert math.isclose(total_sleep_time(), 5)
    monitor.next_lap()

    await until(lambda: monitor.send_call_count == 2)
    assert math.isclose(total_sleep_time(), 10)
コード例 #2
0
async def test_no_sleep_for_first_retry(monitor):
    monitor.make_send_fail = True
    monitor.start(retries=1, interval=5)

    await until(lambda: monitor.send_call_count == 2)
    monitor.next_lap()
    await until(lambda: monitor.failure_called)
    assert math.isclose(total_sleep_time(), 5)
コード例 #3
0
ファイル: test_protocol.py プロジェクト: postlund/pyatv
async def test_heartbeat_fail_closes_connection(stub_sleep):
    protocol = MagicMock()
    protocol.send_and_receive.side_effect = Exception()

    await heartbeat_loop(protocol)
    assert protocol.send_and_receive.call_count == 1 + HEARTBEAT_RETRIES
    assert total_sleep_time() == HEARTBEAT_INTERVAL

    protocol.connection.close.assert_called_once()
コード例 #4
0
async def test_play_video(airplay_usecase, airplay_player, airplay_state):
    airplay_usecase.airplay_playback_idle()
    airplay_usecase.airplay_playback_playing()
    airplay_usecase.airplay_playback_idle()

    await airplay_player.play_url(STREAM, position=START_POSITION)

    assert airplay_state.last_airplay_url == STREAM
    assert airplay_state.last_airplay_start == START_POSITION
    assert airplay_state.last_airplay_uuid is not None
    assert math.isclose(total_sleep_time(), 2.0)