Skip to content

Commit

Permalink
Added CBOR fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
jtc42 committed May 2, 2020
1 parent 783e4e5 commit c6cccdd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ def open(self, *args, **kwargs):
return super().open(*args, **kwargs)


class CborClient(FlaskClient):
def open(self, *args, **kwargs):
kwargs.setdefault(
"headers",
{"Content-Type": "application/json", "Accept": "application/cbor"},
)
kwargs.setdefault("content_type", "application/json")
return super().open(*args, **kwargs)


class SocketClient(FlaskClient):
def __init__(self, app, response_wrapper, *args, **kwargs):
super().__init__(app, response_wrapper, *args, **kwargs)
Expand Down Expand Up @@ -236,6 +246,17 @@ def client(app):
return app.test_client()


@pytest.fixture
def cbor_client(app):
app.test_client_class = CborClient
return app.test_client()


@pytest.fixture
def text_client(app):
return app.test_client()


@pytest.fixture
def ws_client(app):
app.test_client_class = SocketClient
Expand Down

0 comments on commit c6cccdd

Please sign in to comment.