-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add detail_context and PulpMasterContext
[noissue]
- Loading branch information
Showing
8 changed files
with
117 additions
and
73 deletions.
There are no files selected for viewing
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 @@ | ||
Added `detail_context` to master-detail contexts. |
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
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
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,26 @@ | ||
import typing as t | ||
|
||
import pytest | ||
|
||
from pulp_glue.common.context import PulpContext | ||
from pulp_glue.common.openapi import BasicAuthProvider | ||
|
||
|
||
class PulpTestContext(PulpContext): | ||
# TODO check if we can just make the base class ignore echo. | ||
def echo(*args, **kwargs) -> None: | ||
return | ||
|
||
|
||
@pytest.fixture | ||
def pulp_ctx(pulp_cli_settings: t.Dict[str, t.Dict[str, t.Any]]) -> PulpContext: | ||
settings = pulp_cli_settings["cli"] | ||
return PulpTestContext( | ||
api_kwargs={ | ||
"base_url": settings["base_url"], | ||
"auth_provider": BasicAuthProvider(settings.get("username"), settings.get("password")), | ||
}, | ||
api_root=settings.get("api_root", "pulp/"), | ||
background_tasks=False, | ||
timeout=settings.get("timeout", 120), | ||
) |
17 changes: 4 additions & 13 deletions
17
tests/test_api_quirks.py → pulp-glue/tests/test_api_quirks.py
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
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,25 @@ | ||
import random | ||
import string | ||
import typing as t | ||
|
||
import pytest | ||
|
||
from pulp_glue.common.context import PulpContext, PulpRepositoryContext | ||
from pulp_glue.file.context import PulpFileRepositoryContext | ||
|
||
pytestmark = pytest.mark.glue | ||
|
||
|
||
@pytest.fixture | ||
def file_repository(pulp_ctx: PulpContext) -> t.Dict[str, t.Any]: | ||
name = "".join(random.choices(string.ascii_letters, k=8)) | ||
file_repository_ctx = PulpFileRepositoryContext(pulp_ctx) | ||
yield file_repository_ctx.create(body={"name": name}) | ||
file_repository_ctx.delete() | ||
|
||
|
||
def test_detail_context(pulp_ctx: PulpContext, file_repository: t.Dict[str, t.Any]) -> None: | ||
master_ctx = PulpRepositoryContext(pulp_ctx) | ||
detail_ctx = master_ctx.detail_context(pulp_href=file_repository["pulp_href"]) | ||
assert isinstance(detail_ctx, PulpFileRepositoryContext) | ||
assert detail_ctx.entity["name"] == file_repository["name"] |
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
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