-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathtest_entity_context.py
More file actions
35 lines (24 loc) · 1.1 KB
/
test_entity_context.py
File metadata and controls
35 lines (24 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import random
import string
import typing as t
import pytest
from pulp_glue.common import load_plugins, loaded_plugins
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_plugin_loading() -> None:
load_plugins()
assert "core" in loaded_plugins
def test_type_registry() -> None:
assert "file:file" in PulpRepositoryContext.TYPE_REGISTRY
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"]