Skip to content

Commit

Permalink
clean up - 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ric-evans committed Apr 12, 2024
1 parent 898a4e2 commit e75b84c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 31 deletions.
2 changes: 2 additions & 0 deletions rest_tools/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ async def request_and_validate(
"""Make request and validate the response against a given OpenAPI spec.
Useful for testing and debugging.
NOTE: this essentially mimics RestClient.request() with added features.
"""
url, kwargs = rc._prepare(method, path, args=args)

Expand Down
31 changes: 0 additions & 31 deletions tests/integrate_openapi/conftest.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
"""Integration test fixtures."""

import socket
from typing import AsyncIterator, Callable

import pytest
import pytest_asyncio
import tornado

from rest_tools.client import RestClient
from rest_tools.server import RestServer, RestHandler


@pytest.fixture
Expand All @@ -21,28 +15,3 @@ def port() -> int:
ephemeral_port = addr[1]
s.close()
return ephemeral_port


@pytest_asyncio.fixture
async def server(port: int) -> AsyncIterator[Callable[[], RestClient]]:
"""Start up REST server and attach handlers."""
rs = RestServer(debug=True)

class TestHandler(RestHandler):
ROUTE = "/echo/this"

async def post(self) -> None:
if self.get_argument("raise", None):
raise tornado.web.HTTPError(400, self.get_argument("raise"))
self.write(self.get_argument("echo", {}))

rs.add_route(TestHandler.ROUTE, TestHandler)
rs.startup(address="localhost", port=port)

def client() -> RestClient:
return RestClient(f"http://localhost:{port}", retries=0)

try:
yield client
finally:
await rs.stop()

0 comments on commit e75b84c

Please sign in to comment.