Skip to content

Commit

Permalink
Merge branch 'ip-tools:main' into docstr1
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkeanny authored Jan 28, 2024
2 parents 61536a1 + 6f058d7 commit 04bf1b9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ format: ## Run code formatting
black .

test: clean ## Run tests with virtualenv Python
py.test -s -v --lf --cov epo_ops tests --cov-report term-missing --cov-report xml
pytest --lf

test-ci: clean ## Run tests in CI environment with virtualenv Python
py.test -v --cov epo_ops tests --cov-report term-missing --cov-report xml
pytest

coverage: clean ## Check code coverage locally
py.test -s -v --cov epo_ops tests --cov-report term-missing --cov-report xml --cov-report html
coverage: clean test-ci ## Check code coverage locally
coverage html
open htmlcov/index.html

release: clean # Package and upload a release to PyPI
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ Currently the Client knows how to issue request for the following services:
| `published_data_search(cql, range_begin=1, range_end=25, constituents=None)` | published-data/search | search |
| `register(reference_type, input, constituents=['biblio'])` | register | other |
| `register_search(cql, range_begin=1, range_end=25)` | register/search | other |
| `register_search(cql, range_begin=1, range_end=25)` | register/search | other |

Bulk operations can be achieved by passing a list of valid models to the
published_data input field.
Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ requires = [
]
build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
minversion = "2.0"
addopts = """
-rsfEX -p pytester --strict-markers --verbosity=3
--cov=epo_ops tests --cov-report=term-missing --cov-report=xml
"""
log_level = "DEBUG"
log_cli_level = "DEBUG"
testpaths = ["tests"]
xfail_strict = true
markers = [
]

[tool.ruff]
line-length = 80
Expand Down
13 changes: 9 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from .helpers import mkcache, mksqlite, mkthrottler
from .secrets import OPS_KEY, OPS_SECRET
from .secrets import get_secrets_or_skip_tests


@pytest.fixture
Expand All @@ -13,8 +13,9 @@ def storage(request):
def reset_cached_client(request):
from epo_ops import Client

ops_key, ops_secret = get_secrets_or_skip_tests()
return Client(
OPS_KEY, OPS_SECRET, middlewares=[mkcache(request), mkthrottler(request)]
ops_key, ops_secret, middlewares=[mkcache(request), mkthrottler(request)]
)


Expand All @@ -32,14 +33,18 @@ def module_cache(request):
def default_client(request):
from epo_ops import Client

return Client(OPS_KEY, OPS_SECRET, middlewares=[mkthrottler(request)])
ops_key, ops_secret = get_secrets_or_skip_tests()

return Client(ops_key, ops_secret, middlewares=[mkthrottler(request)])


@pytest.fixture(scope="module")
def cached_client(request, module_cache):
from epo_ops import Client

return Client(OPS_KEY, OPS_SECRET, middlewares=[module_cache, mkthrottler(request)])
ops_key, ops_secret = get_secrets_or_skip_tests()

return Client(ops_key, ops_secret, middlewares=[module_cache, mkthrottler(request)])


@pytest.fixture(scope="module", params=["cached_client", "default_client"])
Expand Down
12 changes: 10 additions & 2 deletions tests/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os
from os.path import abspath, dirname, join

import pytest
from dotenv import load_dotenv

# Prune environment variables.
Expand All @@ -20,6 +21,13 @@
dotenv_path = abspath(join(dirname(__file__), "../.env"))
load_dotenv(dotenv_path)


# Set environment variables as constants.
OPS_KEY = os.environ["OPS_KEY"]
OPS_SECRET = os.environ["OPS_SECRET"]
def get_secrets_or_skip_tests():
try:
ops_key = os.environ["OPS_KEY"]
ops_secret = os.environ["OPS_SECRET"]
except KeyError as ex:
raise pytest.skip("No OPS credentials configured") from ex

return ops_key, ops_secret

0 comments on commit 04bf1b9

Please sign in to comment.