File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ pytest_plugins = ["jupyter_server.pytest_plugin" ]
4+
5+
6+ @pytest .fixture
7+ def jp_server_config (jp_server_config ):
8+ return {"ServerApp" : {"jpserver_extensions" : {"mamba_gator" : True }}}
Original file line number Diff line number Diff line change 1+ import asyncio
2+ import datetime
3+ import logging
4+ import re
5+ from unittest .mock import patch
6+
7+ import pytest
8+ import tornado
9+ from mamba_gator .handlers import NS
10+
11+ TIMEOUT = 150
12+ SLEEP = 1
13+
14+
15+ @pytest .fixture
16+ def wait_task (jp_fetch ):
17+ async def foo (endpoint : str ):
18+ start_time = datetime .datetime .now ()
19+
20+ while (datetime .datetime .now () - start_time ).total_seconds () < TIMEOUT :
21+ await asyncio .sleep (SLEEP )
22+ response = await jp_fetch (endpoint .lstrip ("/" ), method = "GET" )
23+ if not (200 <= response .code < 300 ):
24+ raise tornado .web .HTTPError (response .code , str (response ))
25+ elif response .code != 202 :
26+ return response
27+
28+ raise RuntimeError ("Request {} timed out." .format (endpoint ))
29+
30+ return foo
31+
32+
33+ @pytest .fixture
34+ def wait_for_task (wait_task , jp_fetch ):
35+ async def foo (* args , ** kwargs ):
36+ r = await jp_fetch (* args , ** kwargs )
37+ assert r .code == 202
38+ location = r .headers ["Location" ]
39+ assert re .match (r"^/conda/tasks/\d+$" , location ) is not None
40+ return await wait_task (location )
41+
42+ return foo
You can’t perform that action at this time.
0 commit comments