Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Test refactor #310

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pytest-xdist = "^1.15"
respx = "^0.17.1"
asynctest = "^0.13"
importlib-metadata = "^4.12"
pytest-asyncio = "^0.19"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
40 changes: 40 additions & 0 deletions test/ably/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio

import pytest
import pytest_asyncio
from test.ably.restsetup import RestSetup


Expand All @@ -10,3 +11,42 @@ def event_loop():
loop.run_until_complete(RestSetup.get_test_vars())
yield loop
loop.run_until_complete(RestSetup.clear_test_vars())


@pytest_asyncio.fixture(params=["json", "msgpack"])
async def rest(request):
protocol = request.param
use_binary_protocol = protocol == "msgpack"
ably = await RestSetup.get_ably_rest(use_binary_protocol=use_binary_protocol)
yield ably
await ably.close()


@pytest_asyncio.fixture(name="new_rest")
async def new_rest_fixture():
async def rest_factory(**kwargs):
ably = await RestSetup.get_ably_rest(**kwargs)
return ably

yield rest_factory


@pytest_asyncio.fixture(scope='session')
async def test_vars():
result = await RestSetup.get_test_vars()
yield result
await RestSetup.clear_test_vars()


@pytest_asyncio.fixture(name="json_rest")
async def json_rest_fixture(new_rest):
ably = await new_rest(use_binary_protocol=False)
yield ably
await ably.close()


@pytest_asyncio.fixture(name="msgpack_rest")
async def msgpack_rest_fixture(new_rest):
ably = await new_rest(use_binary_protocol=True)
yield ably
await ably.close()
Loading