|
1 | 1 | import os |
2 | 2 | import uuid |
3 | 3 | from pathlib import Path |
| 4 | +from unittest.mock import patch |
4 | 5 |
|
5 | 6 | import pytest |
6 | 7 | import ujson |
7 | 8 | from infrahub_sdk import Config, InfrahubClient |
8 | 9 | from pytest_httpx import HTTPXMock |
9 | 10 |
|
10 | 11 | from infrahub.database import InfrahubDatabase |
11 | | -from infrahub.graphql.models import RequestGraphQLQueryGroupUpdate |
12 | | -from infrahub.graphql.tasks import request_graphql_query_group_update |
13 | | -from infrahub.services import InfrahubServices |
| 12 | +from infrahub.groups.models import RequestGraphQLQueryGroupUpdate |
| 13 | +from infrahub.groups.tasks import update_graphql_query_group |
| 14 | +from tests.helpers.utils import init_service_with_client |
14 | 15 |
|
15 | 16 |
|
16 | 17 | @pytest.fixture |
@@ -44,23 +45,26 @@ async def test_graphql_group_update(db: InfrahubDatabase, httpx_mock: HTTPXMock, |
44 | 45 | client = InfrahubClient( |
45 | 46 | config=config, |
46 | 47 | ) |
47 | | - service = InfrahubServices(client=client) |
48 | 48 |
|
49 | | - response1 = { |
50 | | - "data": {"CoreGraphQLQueryGroupUpsert": {"ok": True, "object": {"id": "957aea37-4510-4386-916f-3febd6665ae6"}}} |
51 | | - } |
| 49 | + with init_service_with_client(client=client), patch("infrahub.groups.tasks.add_branch_tag"): |
| 50 | + # add_branch_tag requires a prefect client, ie it does not work with WorkflowLocal |
| 51 | + response1 = { |
| 52 | + "data": { |
| 53 | + "CoreGraphQLQueryGroupUpsert": {"ok": True, "object": {"id": "957aea37-4510-4386-916f-3febd6665ae6"}} |
| 54 | + } |
| 55 | + } |
52 | 56 |
|
53 | | - httpx_mock.add_response( |
54 | | - method="POST", |
55 | | - json=response1, |
56 | | - match_headers={"X-Infrahub-Tracker": "mutation-coregraphqlquerygroup-upsert"}, |
57 | | - ) |
| 57 | + httpx_mock.add_response( |
| 58 | + method="POST", |
| 59 | + json=response1, |
| 60 | + match_headers={"X-Infrahub-Tracker": "mutation-coregraphqlquerygroup-upsert"}, |
| 61 | + ) |
58 | 62 |
|
59 | | - response2 = {"data": {"RelationshipAdd": {"ok": True}}} |
60 | | - httpx_mock.add_response( |
61 | | - method="POST", |
62 | | - json=response2, |
63 | | - match_headers={"X-Infrahub-Tracker": "mutation-relationshipadd"}, |
64 | | - ) |
| 63 | + response2 = {"data": {"RelationshipAdd": {"ok": True}}} |
| 64 | + httpx_mock.add_response( |
| 65 | + method="POST", |
| 66 | + json=response2, |
| 67 | + match_headers={"X-Infrahub-Tracker": "mutation-relationshipadd"}, |
| 68 | + ) |
65 | 69 |
|
66 | | - await request_graphql_query_group_update.fn(message=model, service=service) |
| 70 | + await update_graphql_query_group(model=model) |
0 commit comments