(handler_class)
| 16 | |
| 17 | @contextmanager |
| 18 | def create_test_server(handler_class): |
| 19 | hostname = 'localhost' |
| 20 | port = 8080 |
| 21 | addr = f"http://{hostname}:{port}" |
| 22 | |
| 23 | # Simulates we are inside a Kaggle environment. |
| 24 | env = EnvironmentVarGuard() |
| 25 | env.set('KAGGLE_KERNEL_RUN_TYPE', 'Interactive') |
| 26 | env.set('KAGGLE_USER_SECRETS_TOKEN', 'foo jwt token') |
| 27 | env.set('KAGGLE_DATA_PROXY_TOKEN', 'foo proxy token') |
| 28 | env.set('KAGGLE_DATA_PROXY_URL', addr) |
| 29 | |
| 30 | with env: |
| 31 | with HTTPServer((hostname, port), handler_class) as test_server: |
| 32 | threading.Thread(target=test_server.serve_forever).start() |
| 33 | |
| 34 | try: |
| 35 | yield addr |
| 36 | finally: |
| 37 | test_server.shutdown() |
| 38 | |
| 39 | class HubHTTPHandler(BaseHTTPRequestHandler): |
| 40 | def do_GET(self): |
no outgoing calls
no test coverage detected