From f081cfe3b21bbe7f7163177c0544bfc1c1d1964e Mon Sep 17 00:00:00 2001 From: Cyrill Raccaud Date: Sat, 4 Jan 2025 14:08:10 +0100 Subject: [PATCH] Update smoke test for multiple countries and token endpoints (#34) update smoke test for multiple countries --- .github/workflows/smoke-test-pr.yml | 16 ++++++++++++++-- .github/workflows/smoke-test.yaml | 13 +++++++++++-- CHANGELOG.md | 4 ++++ cookidoo_api/__init__.py | 2 +- smoke_test/conftest.py | 26 ++++++++++++++++++++++++-- smoke_test/test_2_methods.py | 6 +++++- 6 files changed, 59 insertions(+), 8 deletions(-) diff --git a/.github/workflows/smoke-test-pr.yml b/.github/workflows/smoke-test-pr.yml index c1b680f..6ebbd78 100644 --- a/.github/workflows/smoke-test-pr.yml +++ b/.github/workflows/smoke-test-pr.yml @@ -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 @@ -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 @@ -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: \ No newline at end of file diff --git a/.github/workflows/smoke-test.yaml b/.github/workflows/smoke-test.yaml index 1308d5a..62c8bcb 100644 --- a/.github/workflows/smoke-test.yaml +++ b/.github/workflows/smoke-test.yaml @@ -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 @@ -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 }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f58857..64e0a46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/cookidoo_api/__init__.py b/cookidoo_api/__init__.py index 1fd5740..6b581a0 100644 --- a/cookidoo_api/__init__.py +++ b/cookidoo_api/__init__.py @@ -1,6 +1,6 @@ """Cookidoo API package.""" -__version__ = "0.11.0" +__version__ = "0.11.1" from .cookidoo import Cookidoo from .exceptions import ( diff --git a/smoke_test/conftest.py b/smoke_test/conftest.py index 3a0d563..67bd438 100644 --- a/smoke_test/conftest.py +++ b/smoke_test/conftest.py @@ -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() @@ -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 @@ -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 diff --git a/smoke_test/test_2_methods.py b/smoke_test/test_2_methods.py index d44d242..78200b0 100644 --- a/smoke_test/test_2_methods.py +++ b/smoke_test/test_2_methods.py @@ -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."""