-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtest_schema.py
More file actions
69 lines (63 loc) · 2.91 KB
/
test_schema.py
File metadata and controls
69 lines (63 loc) · 2.91 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import pytest
from infrahub_sdk import InfrahubClient
from infrahub_sdk.exceptions import BranchNotFoundError
from infrahub_sdk.testing.docker import TestInfrahubDockerClient
# from infrahub.core.schema import core_models
# from infrahub.server import app
#
# from infrahub_sdk.schema import NodeSchemaAPI
#
# from .conftest import InfrahubTestClient
#
#
#
class TestInfrahubSchema(TestInfrahubDockerClient):
async def test_query_schema_for_branch_not_found(self, client: InfrahubClient) -> None:
with pytest.raises(BranchNotFoundError) as exc:
await client.all(kind="BuiltinTag", branch="I-do-not-exist")
assert str(exc.value) == "The requested branch was not found on the server [I-do-not-exist]"
# class TestInfrahubSchema:
# @pytest.fixture(scope="class")
# async def client(self):
# return InfrahubTestClient(app)
#
# async def test_schema_all(self, client, init_db_base):
# config = Config(requester=client.async_request)
# ifc = InfrahubClient(config=config)
# schema_nodes = await ifc.schema.all()
#
# nodes = [node for node in core_models["nodes"] if node["namespace"] != "Internal"]
# generics = [node for node in core_models["generics"] if node["namespace"] != "Internal"]
#
# profiles = [node for node in schema_nodes.values() if node.namespace == "Profile"]
# assert profiles
#
# assert len(schema_nodes) == len(nodes) + len(generics) + len(profiles)
# assert "BuiltinTag" in schema_nodes
# assert isinstance(schema_nodes["BuiltinTag"], NodeSchemaAPI)
#
# async def test_schema_get(self, client, init_db_base):
# config = Config(username="admin", password="infrahub", requester=client.async_request)
# ifc = InfrahubClient(config=config)
# schema_node = await ifc.schema.get(kind="BuiltinTag")
#
# assert isinstance(schema_node, NodeSchemaAPI)
# assert ifc.default_branch in ifc.schema.cache
# nodes = [node for node in core_models["nodes"] if node["namespace"] != "Internal"]
# generics = [node for node in core_models["generics"] if node["namespace"] != "Internal"]
#
# schema_without_profiles = [
# node for node in ifc.schema.cache[ifc.default_branch].values() if node.namespace != "Profile"
# ]
# assert len(schema_without_profiles) == len(nodes) + len(generics)
#
# async def test_schema_load_many(self, client, init_db_base, schema_extension_01, schema_extension_02):
# config = Config(username="admin", password="infrahub", requester=client.async_request)
# ifc = InfrahubClient(config=config)
# response = await ifc.schema.load(schemas=[schema_extension_01, schema_extension_02])
#
# assert response.schema_updated
#
# schema_nodes = await ifc.schema.all(refresh=True)
# assert "InfraRack" in schema_nodes.keys()
# assert "ProcurementContract" in schema_nodes.keys()