-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This provides a common place for any pytest fixtures to be added.
- Loading branch information
Showing
4 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from aiohttp import web | ||
|
||
|
||
def add_file_system_routes(app, fixtures_root, fixture_name): | ||
fixture_path = fixtures_root / fixture_name | ||
new_routes = [web.static("/", fixture_path.absolute(), show_index=True)] | ||
app.add_routes(new_routes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import asyncio | ||
|
||
import pytest | ||
|
||
from pulp_smash.api import _get_sleep_time | ||
from pulp_smash.config import get_config | ||
from pulp_smash.pulp3.bindings import delete_orphans | ||
|
||
from pulpcore.client.pulpcore import ApiClient, TasksApi | ||
|
||
|
||
cfg = get_config() | ||
SLEEP_TIME = _get_sleep_time(cfg) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def pulpcore_client(): | ||
configuration = cfg.get_bindings_config() | ||
return ApiClient(configuration) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def tasks_api_client(pulpcore_client): | ||
return TasksApi(pulpcore_client) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def async_monitor_task(tasks_api_client): | ||
async def _async_monitor_task(task_href): | ||
completed = ["completed", "failed", "canceled"] | ||
task = tasks_api_client.read(task_href) | ||
while task.state not in completed: | ||
await asyncio.sleep(SLEEP_TIME) | ||
task = tasks_api_client.read(task_href) | ||
return task | ||
|
||
return _async_monitor_task | ||
|
||
|
||
@pytest.fixture | ||
def delete_orphans_pre(): | ||
delete_orphans() | ||
yield | ||
|
||
|
||
@pytest.fixture | ||
def delete_orphans_post(): | ||
yield | ||
delete_orphans() | ||
|
||
|
||
@pytest.fixture | ||
def delete_orphans_pre_post(delete_orphans_pre, delete_orphans_post): | ||
yield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters