Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated API call "get:schema/" from SDK #3841

Merged
merged 3 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2562,7 +2562,7 @@ async def read_only_repos_in_main(db: InfrahubDatabase, register_core_models_sch
@pytest.fixture
async def mock_core_schema_01(helper, httpx_mock: HTTPXMock) -> HTTPXMock:
response_text = helper.schema_file(file_name="core_schema_01.json")
httpx_mock.add_response(method="GET", url="http://mock/api/schema/?branch=main", json=response_text)
httpx_mock.add_response(method="GET", url="http://mock/api/schema?branch=main", json=response_text)
return httpx_mock


Expand Down
4 changes: 2 additions & 2 deletions backend/tests/unit/git/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ async def mock_schema_query_01(helper, httpx_mock: HTTPXMock) -> HTTPXMock:
encoding="UTF-8"
)

httpx_mock.add_response(method="GET", url="http://mock/api/schema/?branch=main", json=ujson.loads(response_text))
httpx_mock.add_response(method="GET", url="http://mock/api/schema?branch=main", json=ujson.loads(response_text))
return httpx_mock


Expand All @@ -649,7 +649,7 @@ async def mock_schema_query_02(helper, httpx_mock: HTTPXMock) -> HTTPXMock:
encoding="UTF-8"
)

httpx_mock.add_response(method="GET", url="http://mock/api/schema/?branch=main", json=ujson.loads(response_text))
httpx_mock.add_response(method="GET", url="http://mock/api/schema?branch=main", json=ujson.loads(response_text))
return httpx_mock


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def mock_schema_query_02(helper, httpx_mock: HTTPXMock) -> HTTPXMock:
encoding="UTF-8"
)

httpx_mock.add_response(method="GET", url="http://mock/api/schema/?branch=main", json=ujson.loads(response_text))
httpx_mock.add_response(method="GET", url="http://mock/api/schema?branch=main", json=ujson.loads(response_text))
return httpx_mock


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def mock_schema_query_02(helper, httpx_mock: HTTPXMock) -> HTTPXMock:
encoding="UTF-8"
)

httpx_mock.add_response(method="GET", url="http://mock/api/schema/?branch=main", json=ujson.loads(response_text))
httpx_mock.add_response(method="GET", url="http://mock/api/schema?branch=main", json=ujson.loads(response_text))
return httpx_mock


Expand Down
4 changes: 2 additions & 2 deletions python_sdk/infrahub_sdk/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ async def fetch(self, branch: str, namespaces: Optional[list[str]] = None) -> Mu
if namespaces:
url_parts.extend([("namespaces", ns) for ns in namespaces])
query_params = urlencode(url_parts)
url = f"{self.client.address}/api/schema/?{query_params}"
url = f"{self.client.address}/api/schema?{query_params}"

response = await self.client._get(url=url)
response.raise_for_status()
Expand Down Expand Up @@ -880,7 +880,7 @@ def fetch(self, branch: str, namespaces: Optional[list[str]] = None) -> MutableM
if namespaces:
url_parts.extend([("namespaces", ns) for ns in namespaces])
query_params = urlencode(url_parts)
url = f"{self.client.address}/api/schema/?{query_params}"
url = f"{self.client.address}/api/schema?{query_params}"

response = self.client._get(url=url)
response.raise_for_status()
Expand Down
10 changes: 5 additions & 5 deletions python_sdk/tests/unit/sdk/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ async def mock_schema_query_01(httpx_mock: HTTPXMock) -> HTTPXMock:

httpx_mock.add_response(
method="GET",
url="http://mock/api/schema/?branch=main",
url="http://mock/api/schema?branch=main",
json=ujson.loads(response_text),
)
return httpx_mock
Expand All @@ -1662,7 +1662,7 @@ async def mock_schema_query_02(httpx_mock: HTTPXMock) -> HTTPXMock:

httpx_mock.add_response(
method="GET",
url="http://mock/api/schema/?branch=main",
url="http://mock/api/schema?branch=main",
json=ujson.loads(response_text),
)
return httpx_mock
Expand All @@ -1680,7 +1680,7 @@ async def mock_rest_api_artifact_fetch(httpx_mock: HTTPXMock) -> HTTPXMock:

httpx_mock.add_response(
method="GET",
url="http://mock/api/schema/?branch=main",
url="http://mock/api/schema?branch=main",
json=ujson.loads(schema_response),
)

Expand Down Expand Up @@ -1772,7 +1772,7 @@ async def mock_rest_api_artifact_generate(httpx_mock: HTTPXMock) -> HTTPXMock:

httpx_mock.add_response(
method="GET",
url="http://mock/api/schema/?branch=main",
url="http://mock/api/schema?branch=main",
json=ujson.loads(schema_response),
)

Expand Down Expand Up @@ -2330,5 +2330,5 @@ def query_introspection() -> str:
async def mock_schema_query_ipam(httpx_mock: HTTPXMock) -> HTTPXMock:
response_text = (get_fixtures_dir() / "schema_ipam.json").read_text(encoding="UTF-8")

httpx_mock.add_response(method="GET", url="http://mock/api/schema/?branch=main", json=ujson.loads(response_text))
httpx_mock.add_response(method="GET", url="http://mock/api/schema?branch=main", json=ujson.loads(response_text))
return httpx_mock
Loading