Skip to content

Commit 6418662

Browse files
author
michael.yak
committed
Apend result of the two pytest runs into one coverage report
1 parent 57710e3 commit 6418662

File tree

4 files changed

+76
-55
lines changed

4 files changed

+76
-55
lines changed

.github/workflows/python_package_build.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,34 @@ jobs:
1212
container:
1313
image: matanrubin/python-poetry:3.7
1414

15+
env:
16+
TEST_REDIS_SERVER: True
17+
REDIS_HOST: redis
18+
19+
services:
20+
# User a redis container for testing the redis health-provider
21+
redis:
22+
image: redis:5.0.3
23+
1524
steps:
1625
- uses: actions/checkout@v2
1726
- run: make bootstrap
1827
- run: poetry build -vvv
28+
29+
# Install all dependencies except for psutil and run the tests with coverage - this tests handling missing psutil
1930
- run: poetry install --extras flask --extras fastapi --extras aiohttp --extras db --extras redis
2031
- run: make coverage
32+
33+
# Run pylint+mypy after installing psutil so they don't complain on missing dependencies
34+
- run: poetry install --extras psutil
35+
- run: make check
36+
37+
# Run tests with coverage again - this adds tests that require psutil
38+
- run: make coverage
39+
40+
# Upload coverage files to codecov
2141
- uses: actions/upload-artifact@v2
2242
with:
2343
name: htmlcov.zip
2444
path: htmlcov/
2545
- uses: codecov/codecov-action@v1
26-
27-
# Install the extra psutil module and run linting+tests in the "psutil enabled" env
28-
- run: poetry install --extras psutil
29-
- run: make check
30-
- run: make test

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test:
1919
poetry run pytest --log-cli-level=4 -vv tests
2020

2121
coverage:
22-
poetry run pytest --cov-report xml:./coverage.xml --cov-report html --cov-report term --cov=pyctuator --log-cli-level=4 -vv tests
22+
poetry run pytest --cov-append --cov-report xml:./coverage.xml --cov-report html --cov-report term --cov=pyctuator --log-cli-level=4 -vv tests
2323

2424
pylint:
2525
poetry run pylint --exit-zero pyctuator tests

poetry.lock

Lines changed: 48 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/health/test_redis_health_provider.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,26 @@ def require_redis_server() -> None:
1919
if not should_test_with_redis:
2020
pytest.skip("No Redis server (env TEST_REDIS_SERVER isn't True), skipping")
2121

22+
@pytest.fixture
23+
def redis_host() -> str:
24+
return os.getenv("REDIS_HOST", "localhost")
2225

2326
@pytest.mark.usefixtures("require_redis", "require_redis_server")
24-
def test_redis_health() -> None:
27+
def test_redis_health(redis_host: str) -> None:
2528
import redis
2629
from pyctuator.health.health_provider import Status
2730
from pyctuator.health.redis_health_provider import RedisHealthProvider, RedisHealthStatus, RedisHealthDetails
2831

29-
health = RedisHealthProvider(redis.Redis()).get_health()
32+
health = RedisHealthProvider(redis.Redis(host=redis_host)).get_health()
3033
assert health == RedisHealthStatus(Status.UP, RedisHealthDetails("5.0.3", "standalone"))
3134

3235

3336
@pytest.mark.usefixtures("require_redis", "require_redis_server")
34-
def test_redis_bad_password() -> None:
37+
def test_redis_bad_password(redis_host: str) -> None:
3538
import redis
3639
from pyctuator.health.health_provider import Status
3740
from pyctuator.health.redis_health_provider import RedisHealthProvider
3841

39-
health = RedisHealthProvider(redis.Redis(password="blabla")).get_health()
42+
health = RedisHealthProvider(redis.Redis(host=redis_host, password="blabla")).get_health()
4043
assert health.status == Status.DOWN
4144
assert "Client sent AUTH, but no password is set" in str(health.details.failure)

0 commit comments

Comments
 (0)