MCPcopy
hub / github.com/zauberzeug/nicegui / test_async_connect_handler

Function test_async_connect_handler

tests/test_lifecycle.py:29–54  ·  view source on GitHub ↗
(screen: Screen)

Source from the content-addressed store, hash-verified

27
28
29def test_async_connect_handler(screen: Screen):
30 connections = {'count': 0}
31
32 @app.on_connect
33 async def handle_connect():
34 await asyncio.sleep(0.1)
35 connections.update(count=connections['count'] + 1)
36
37 @ui.page('/')
38 def page():
39 ui.label('Hello')
40
41 screen.open('/')
42 screen.should_contain('Hello')
43 screen.wait(0.5)
44 assert connections['count'] == 1
45
46 screen.open('/')
47 screen.should_contain('Hello')
48 screen.wait(0.5)
49 assert connections['count'] == 2
50
51 screen.open('/')
52 screen.should_contain('Hello')
53 screen.wait(0.5)
54 assert connections['count'] == 3
55
56
57def test_connect_disconnect_is_called_for_each_client(screen: Screen):

Callers

nothing calls this directly

Calls 3

should_containMethod · 0.80
waitMethod · 0.80
openMethod · 0.45

Tested by

no test coverage detected