Commit 463be454 authored by Luc Yriarte's avatar Luc Yriarte
Browse files

slb code push #4 / unit tests fixes

parent b6ffa9ec
Pipeline #31697 failed with stages
in 10 minutes and 32 seconds
......@@ -43,7 +43,6 @@ def gcp_config_fixture(monkeypatch):
environment_dict = os.environ.copy()
environment_dict[ConfigurationContainer.cloud_provider.key] = provider_name
environment_dict['SERVICE_HOST_ENTITLEMENTS'] = 'https://test-endpoint/api/entitlements'
environment_dict['SERVICE_HOST_STORAGE'] = 'https://test-endpoint/api/storage'
environment_dict['SERVICE_HOST_SEARCH'] = 'https://test-endpoint/api/search'
......@@ -64,7 +63,6 @@ def azure_config_fixture(monkeypatch):
environment_dict = os.environ.copy()
environment_dict[ConfigurationContainer.cloud_provider.key] = provider_name
environment_dict['AZ_AI_INSTRUMENTATION_KEY'] = 'ffffffff-1111-2222-aaaa-ffffffffffff'
environment_dict['SERVICE_HOST_ENTITLEMENTS'] = 'https://test-endpoint/api/entitlements'
environment_dict['SERVICE_HOST_STORAGE'] = 'https://test-endpoint/api/storage'
environment_dict['SERVICE_HOST_SEARCH'] = 'https://test-endpoint/api/search'
environment_dict['USE_PARTITION_SERVICE'] = 'disabled'
......
......@@ -19,15 +19,13 @@ import httpx
from app.clients import (
make_storage_record_client,
make_search_client,
make_entitlements_auth_client,
StorageRecordServiceClient,
SearchServiceClient,
EntitlementsAuthServiceClient)
SearchServiceClient)
from app.utils import get_or_create_ctx
from tests.unit.test_utils import make_record
import odes_storage.exceptions
import odes_search.exceptions
import odes_entitlements.exceptions
from tests.unit.test_utils import ctx_fixture as test_context
......@@ -66,20 +64,3 @@ async def test_make_search_client(httpx_mock: HTTPXMock, test_context):
with pytest.raises(odes_search.exceptions.UnexpectedResponse):
await client.get_index_schema(kind='kind', data_partition_id="dp")
@pytest.mark.asyncio
async def test_make_entitlement_client(httpx_mock: HTTPXMock, test_context):
host = 'http://my_host:81234'
async with make_entitlements_auth_client(host) as client:
assert isinstance(client, EntitlementsAuthServiceClient)
# ensure host
assert client.api_client.host == host
assert client.api_client._async_client.timeout == httpx.Timeout(timeout=45)
get_or_create_ctx()
httpx_mock.add_response(status_code=500)
# expect the correct exception - ie. composition do not mix several clients
with pytest.raises(odes_entitlements.exceptions.UnexpectedResponse):
await client.auth()
......@@ -92,7 +92,7 @@ def test_storage_client_raise_api_exception(client):
response = client.delete("/ddms/v2/logsets/123456")
json_res = response.json()
assert json_res['origin'] == 'osdu-data-ecosystem-storage'
assert json_res['errors'][0] == "An unexpected response"
assert json_res['errors'][0] == {'error': {'code': 401, 'message': 'Not authorized'}}
assert response.status_code == status.HTTP_401_UNAUTHORIZED
......
......@@ -15,8 +15,8 @@
import time
import mock
import pytest
import starlette.status as status
from fastapi import Header
from fastapi import Header, status
from fastapi.testclient import TestClient
from odes_storage import models as m
from odes_storage.exceptions import UnexpectedResponse
......@@ -353,13 +353,13 @@ def test_swagger_generation():
"summary"] == 'Upload user-defined catalog with family assignment rules'
assert swagger_dict["paths"]["/log-recognition/upload-catalog"]["put"]["description"] == """Upload user-defined catalog with family assignment rules for specific partition ID.
If there is an existing catalog, it will be replaced. It takes maximum of 5 mins to replace the existing catalog.
Hence, any call to retrieve the family should be made after 5 mins of uploading the catalog"""
Hence, any call to retrieve the family should be made after 5 mins of uploading the catalog. <p>Required roles: 'users.datalake.editors' or 'users.datalake.admins'.</p>"""
assert \
swagger_dict["paths"]["/log-recognition/upload-catalog"]["put"]["requestBody"]["content"]["application/json"][
"schema"][
"$ref"] == '#/components/schemas/CatalogRecord'
assert swagger_dict["components"]["schemas"]["CatalogRecord"]["example"] == {
'acl': {'viewers': ['abc@example.com, cde@example.com'], 'owners': ['abc@example.com, cde@example.com']},
'acl': {'viewers': ['abc@slb.com, cde@slb.com'], 'owners': ['abc@slb.com, cde@slb.com']},
'legal': {'legaltags': ['opendes-public-usa-dataset-1'], 'otherRelevantDataCountries': ['US']},
'data': {'family_catalog': [{'unit': 'ohm.m', 'family': 'Medium Resistivity', 'rule': 'MEDR'}],
'main_family_catalog': [
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment