def mock_server(mocker, request_mocker): app = create_app() mock = utils.RequestsMock(app.test_client(), {}) mocker.patch("gql.transport.requests.requests", mock) mocker.patch("wandb.apis.file_stream.requests", mock) mocker.patch("wandb.apis.internal.requests", mock) return mock
def live_mock_server(request): if request.node.get_closest_marker('port'): port = request.node.get_closest_marker('port').args[0] else: port = 8765 app = create_app() server = Process(target=app.run, kwargs={ "port": port, "debug": True, "use_reloader": False }) server.start() for i in range(5): try: time.sleep(1) res = requests.get("http://localhost:%s/storage" % port, timeout=1) if res.status_code == 200: break print("Attempting to connect but got: %s", res) except requests.exceptions.RequestException: print("timed out") yield server server.terminate() server.join()
def mock_server(mocker): ctx = default_ctx() app = create_app(ctx) mock = utils.RequestsMock(app, ctx) mocker.patch("gql.transport.requests.requests", mock) mocker.patch("wandb.apis.file_stream.requests", mock) mocker.patch("wandb.apis.internal.requests", mock) mocker.patch("wandb.apis.public.requests", mock) mocker.patch("wandb.util.requests", mock) mocker.patch("wandb.artifacts.requests", mock) return mock
def live_mock_server(request): if request.node.get_closest_marker('port'): port = request.node.get_closest_marker('port').args[0] else: port = 8765 app = create_app() server = Process(target=app.run, kwargs={"port": port, "debug": True, "use_reloader": False}) server.start() yield server server.terminate() server.join()