diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2019-06-17 15:35:51 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2019-06-17 15:35:51 +0200 |
commit | c33431e6c5ccf5c0b274e2ed9c21ddf776759b67 (patch) | |
tree | 75e9507bfab368611a1fab98a61616adc28de2f8 /crocoite | |
parent | 23b3fed7b44e4059901ea2d09c866d385fa05bfc (diff) | |
download | crocoite-c33431e6c5ccf5c0b274e2ed9c21ddf776759b67.tar.gz crocoite-c33431e6c5ccf5c0b274e2ed9c21ddf776759b67.tar.bz2 crocoite-c33431e6c5ccf5c0b274e2ed9c21ddf776759b67.zip |
devtools: Fix testcase
The body is only available after receiving the loadingFinished event.
Diffstat (limited to 'crocoite')
-rw-r--r-- | crocoite/test_devtools.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/crocoite/test_devtools.py b/crocoite/test_devtools.py index 3993edd..56fc42a 100644 --- a/crocoite/test_devtools.py +++ b/crocoite/test_devtools.py @@ -39,8 +39,9 @@ async def tab (browser): # make sure there are no transactions left over (i.e. no unawaited requests) assert not tab.transactions +docBody = "<html><body><p>Hello, world</p></body></html>" async def hello(request): - return web.Response(text="Hello, world") + return web.Response(text=docBody, content_type='text/html') @pytest.fixture async def server (): @@ -112,14 +113,28 @@ async def test_tab_crash (tab): async def test_load (tab, server): await tab.Network.enable () await tab.Page.navigate (url='http://localhost:8080') + method, req = await tab.get () assert method == tab.Network.requestWillBeSent + method, resp = await tab.get () assert method == tab.Network.responseReceived - assert tab.pending == 0 + assert resp['requestId'] == req['requestId'] + + method, dataRecv = await tab.get () + assert method == tab.Network.dataReceived + assert dataRecv['dataLength'] == len (docBody) + assert dataRecv['requestId'] == req['requestId'] + + method, finish = await tab.get () + assert method == tab.Network.loadingFinished + assert finish['requestId'] == req['requestId'] + body = await tab.Network.getResponseBody (requestId=req['requestId']) - assert body['body'] == "Hello, world" + assert body['body'] == docBody + await tab.Network.disable () + assert tab.pending == 0 @pytest.mark.asyncio async def test_recv_failure(browser): |