Skip to content

Commit

Permalink
Update smoke test for multiple countries and token endpoints (#34)
Browse files Browse the repository at this point in the history
update smoke test for multiple countries
  • Loading branch information
miaucl authored Jan 4, 2025
1 parent 95e5310 commit f081cfe
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 8 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/smoke-test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ jobs:
smoke_test_pr:
runs-on: ubuntu-latest
if: ${{ github.event.label.name == 'run smoke test' }}
strategy:
matrix:
country:
- ch
- de
- pl
steps:
- name: Get User Permission
id: checkAccess
Expand Down Expand Up @@ -56,7 +62,10 @@ jobs:
- name: Prepare cookies with pytest
run: pytest smoke_test/test_1_setup_token.py -v -x
env:
EMAIL: ${{ vars.EMAIL }}
COUNTRY: ${{ matrix.country }}
EMAIL_CH: ${{ vars.EMAIL_CH }}
EMAIL_DE: ${{ vars.EMAIL_DE }}
EMAIL_PL: ${{ vars.EMAIL_PL }}
PASSWORD: ${{ secrets.PASSWORD }}
# !!!!!!!!!!!!!!!!!!!!
# From here on, we run new code which does not have access to the password, only the token
Expand All @@ -69,6 +78,9 @@ jobs:
- name: Test with pytest
run: pytest smoke_test/test_2_methods.py -v -x
env:
EMAIL: ${{ vars.EMAIL }}
COUNTRY: ${{ matrix.country }}
EMAIL_CH: ${{ vars.EMAIL_CH }}
EMAIL_DE: ${{ vars.EMAIL_DE }}
EMAIL_PL: ${{ vars.EMAIL_PL }}
PASSWORD: <redacted>

13 changes: 11 additions & 2 deletions .github/workflows/smoke-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ concurrency:
jobs:
smoke_test:
runs-on: ubuntu-latest
strategy:
matrix:
country:
- ch
- de
- pl
steps:
- name: Get User Permission
id: checkAccess
Expand Down Expand Up @@ -58,5 +64,8 @@ jobs:
- name: Test with pytest
run: pytest smoke_test -v -x
env:
EMAIL: ${{ vars.EMAIL }}
PASSWORD: ${{ secrets.PASSWORD }}
COUNTRY: ${{ matrix.country }}
EMAIL_CH: ${{ vars.EMAIL_CH }}
EMAIL_DE: ${{ vars.EMAIL_DE }}
EMAIL_PL: ${{ vars.EMAIL_PL }}
PASSWORD: ${{ secrets.PASSWORD }}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.11.1

- Extend smoke tests to multiple accounts with different countries

## 0.11.0

- Align token endpoint with new way of auth for cookidoo app
Expand Down
2 changes: 1 addition & 1 deletion cookidoo_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Cookidoo API package."""

__version__ = "0.11.0"
__version__ = "0.11.1"

from .cookidoo import Cookidoo
from .exceptions import (
Expand Down
26 changes: 24 additions & 2 deletions smoke_test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pytest

from cookidoo_api.cookidoo import Cookidoo
from cookidoo_api.helpers import get_localization_options
from cookidoo_api.types import CookidooAuthResponse, CookidooConfig

load_dotenv()
Expand Down Expand Up @@ -46,9 +47,16 @@ async def aiohttp_client_session() -> AsyncGenerator[ClientSession]:
async def cookidoo_api_client_no_auth(session: ClientSession) -> Cookidoo:
"""Create Cookidoo instance."""

country = os.environ["COUNTRY"]
localizations = await get_localization_options(country=country)

cookidoo = Cookidoo(
session,
cfg=CookidooConfig(email=os.environ["EMAIL"], password=os.environ["PASSWORD"]),
cfg=CookidooConfig(
email=os.environ[f"EMAIL_{country.upper()}"],
password=os.environ["PASSWORD"],
localization=localizations[0],
),
)
return cookidoo

Expand All @@ -59,9 +67,23 @@ async def cookidoo_authenticated_api_client(
) -> Cookidoo:
"""Create authenticated Cookidoo instance."""

country = os.environ["COUNTRY"]
localizations = await get_localization_options(country=country)

print(
CookidooConfig(
email=os.environ[f"EMAIL_{country.upper()}"],
password=os.environ["PASSWORD"],
localization=localizations[0],
)
)
cookidoo = Cookidoo(
session,
cfg=CookidooConfig(email=os.environ["EMAIL"], password=os.environ["PASSWORD"]),
cfg=CookidooConfig(
email=os.environ[f"EMAIL_{country.upper()}"],
password=os.environ["PASSWORD"],
localization=localizations[0],
),
)

# Restore auth data from saved token
Expand Down
6 changes: 5 additions & 1 deletion smoke_test/test_2_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ async def test_cookidoo_get_user_info(self, cookidoo: Cookidoo) -> None:
async def test_cookidoo_get_active_subscription(self, cookidoo: Cookidoo) -> None:
"""Test cookidoo get active subscription."""
sub = await cookidoo.get_active_subscription()
assert sub is None # Test account uses the free plan
if sub is not None: # Test account uses the free plan or a trial
assert sub.status == "ACTIVE"
assert sub.type == "TRIAL"
else:
assert sub is None

async def test_cookidoo_recipe_details(self, cookidoo: Cookidoo) -> None:
"""Test cookidoo recipe details."""
Expand Down

0 comments on commit f081cfe

Please sign in to comment.