11import asyncio
22import time
33
4+ import docker .models .containers
5+
46import enapter
57
68
79class TestClient :
810
9- async def test_sanity (self , enapter_mqtt_client ) :
11+ async def test_sanity (self , enapter_mqtt_client : enapter . mqtt . Client ) -> None :
1012 async with asyncio .TaskGroup () as tg :
1113 async with HeartbitSender (tg , enapter_mqtt_client ) as heartbit_sender :
1214 async with enapter_mqtt_client .subscribe (
@@ -15,7 +17,9 @@ async def test_sanity(self, enapter_mqtt_client):
1517 msg = await messages .__anext__ ()
1618 assert int (msg .payload ) <= time .time ()
1719
18- async def test_consume_after_another_subscriber_left (self , enapter_mqtt_client ):
20+ async def test_consume_after_another_subscriber_left (
21+ self , enapter_mqtt_client : enapter .mqtt .Client
22+ ) -> None :
1923 async with asyncio .TaskGroup () as tg :
2024 async with HeartbitSender (tg , enapter_mqtt_client ) as heartbit_sender :
2125 async with enapter_mqtt_client .subscribe (
@@ -31,7 +35,9 @@ async def test_consume_after_another_subscriber_left(self, enapter_mqtt_client):
3135 msg = await messages_1 .__anext__ ()
3236 assert int (msg .payload ) <= time .time ()
3337
34- async def test_two_subscriptions (self , enapter_mqtt_client ):
38+ async def test_two_subscriptions (
39+ self , enapter_mqtt_client : enapter .mqtt .Client
40+ ) -> None :
3541 async with asyncio .TaskGroup () as tg :
3642 async with HeartbitSender (tg , enapter_mqtt_client ) as heartbit_sender :
3743 for i in range (2 ):
@@ -41,7 +47,9 @@ async def test_two_subscriptions(self, enapter_mqtt_client):
4147 msg = await messages .__anext__ ()
4248 assert int (msg .payload ) <= time .time ()
4349
44- async def test_two_subscribers (self , enapter_mqtt_client ):
50+ async def test_two_subscribers (
51+ self , enapter_mqtt_client : enapter .mqtt .Client
52+ ) -> None :
4553 async with asyncio .TaskGroup () as tg :
4654 async with HeartbitSender (tg , enapter_mqtt_client ) as heartbit_sender :
4755 async with enapter_mqtt_client .subscribe (
@@ -54,7 +62,11 @@ async def test_two_subscribers(self, enapter_mqtt_client):
5462 msg = await messages .__anext__ ()
5563 assert int (msg .payload ) <= time .time ()
5664
57- async def test_broker_restart (self , mosquitto_container , enapter_mqtt_client ):
65+ async def test_broker_restart (
66+ self ,
67+ mosquitto_container : docker .models .containers .Container ,
68+ enapter_mqtt_client : enapter .mqtt .Client ,
69+ ) -> None :
5870 async with asyncio .TaskGroup () as tg :
5971 async with HeartbitSender (tg , enapter_mqtt_client ) as heartbit_sender :
6072 async with enapter_mqtt_client .subscribe (
@@ -72,16 +84,16 @@ class HeartbitSender(enapter.async_.Routine):
7284 def __init__ (
7385 self ,
7486 task_group : asyncio .TaskGroup ,
75- enapter_mqtt_client ,
76- topic = "heartbits" ,
77- interval = 0.5 ,
78- ):
87+ enapter_mqtt_client : enapter . mqtt . Client ,
88+ topic : str = "heartbits" ,
89+ interval : float = 0.5 ,
90+ ) -> None :
7991 super ().__init__ (task_group = task_group )
8092 self .enapter_mqtt_client = enapter_mqtt_client
8193 self .topic = topic
8294 self .interval = interval
8395
84- async def _run (self ):
96+ async def _run (self ) -> None :
8597 while True :
8698 payload = str (int (time .time ()))
8799 try :
0 commit comments