File: test_ticks.py

package info (click to toggle)
python-i3ipc 2.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 580 kB
  • sloc: python: 2,968; makefile: 222; sh: 4
file content (33 lines) | stat: -rw-r--r-- 842 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from .ipctest import IpcTest

import pytest
import asyncio


class TestTicks(IpcTest):
    events = []

    async def on_tick(self, i3, e):
        self.events.append(e)
        if len(self.events) == 3:
            i3.main_quit()

    @pytest.mark.asyncio
    async def test_tick_event(self, i3):
        i3.on('tick', self.on_tick)

        def send_ticks():
            asyncio.ensure_future(i3.send_tick())
            asyncio.ensure_future(i3.send_tick('hello world'))

        i3._loop.call_later(0.1, send_ticks)

        await i3.main()

        assert len(self.events) == 3
        assert self.events[0].first
        assert self.events[0].payload == ''
        assert not self.events[1].first
        assert self.events[1].payload == ''
        assert not self.events[2].first
        assert self.events[2].payload == 'hello world'