Skip to content
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
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ unit-tests:

## integration-tests: Run integration tests.
.PHONY: integration-tests
integration-tests: export CACHE_URL = redis://localhost:6379
integration-tests: test_path = tests/integration
integration-tests:
@coverage run -m pytest $(test_path)
@CACHE_URL=redis://localhost:6379 \
PROVIDER='' \
TEST_DATASET='' \
API_ROOT_URL=https://platform.localhost.ai \
DATA_API_ROOT_URL=https://data.localhost.ai \
TEST_API_KEY='' \
TEST_BEARER_TOKEN='' \
coverage run -m pytest --vcr-record=none $(test_path)

## coverage: Display code coverage in the console.
.PHONY: coverage
Expand Down
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ freezegun==1.0.0
pytest==7.1.2
pytest-httpx==0.20.0
pytest-mock==3.3.1
pytest-vcr~=1.0.2
requests-mock==1.8.0
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ parallel = True

[coverage:report]
precision = 2
fail_under = 98.09
fail_under = 98.44
skip_covered = True
show_missing = True
exclude_lines =
Expand Down
15 changes: 8 additions & 7 deletions src/corva/api_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import functools
import json
import logging
import posixpath
from typing import Callable, List, Optional

import httpx
Expand Down Expand Up @@ -154,14 +153,16 @@ class DataApiVersions:
class UserApiSdk:
def __init__(
self,
platform_api_url: str,
platform_v1_url: str,
platform_v2_url: str,
data_api_url: str,
api_key: str,
app_key: str,
logger: logging.Logger,
logger: logging.Logger = logging.getLogger(),
timeout: int = 30,
):
self._platform_api_url = platform_api_url
self._platform_v1_url = platform_v1_url
self._platform_v2_url = platform_v2_url
self._data_api_url = data_api_url
self._headers = {
"Authorization": f"API {api_key}",
Expand All @@ -172,17 +173,17 @@ def __init__(

def __enter__(self):
data_cli = httpx.Client(
base_url=posixpath.join(self._data_api_url, "api/v1"),
base_url=self._data_api_url,
headers=self._headers,
timeout=self._timeout,
)
platform_v1_cli = httpx.Client(
base_url=posixpath.join(self._platform_api_url, "v1"),
base_url=self._platform_v1_url,
headers=self._headers,
timeout=self._timeout,
)
platform_v2_cli = httpx.Client(
base_url=posixpath.join(self._platform_api_url, "v2"),
base_url=self._platform_v2_url,
headers=self._headers,
timeout=self._timeout,
)
Expand Down
19 changes: 19 additions & 0 deletions src/corva/configuration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import os

import pydantic

Expand All @@ -25,3 +26,21 @@ class Settings(pydantic.BaseSettings):


SETTINGS = Settings()


def get_test_api_key() -> str:
"""Api key for testing"""

return os.environ['TEST_API_KEY']


def get_test_bearer() -> str:
"""Bearer token for testing"""

return os.environ['TEST_BEARER_TOKEN']


def get_test_dataset() -> str:
"""Dataset for testing"""

return os.environ['TEST_DATASET']
Loading