From 60238be6ee834805900bf9a28870de2972ae61a0 Mon Sep 17 00:00:00 2001 From: Germain Lefebvre <7525033+germainlefebvre4@users.noreply.github.com> Date: Mon, 13 May 2024 23:11:07 +0200 Subject: [PATCH] ci: Run scheduled tests through ci (#330) * ci: Run scheduled tests through ci * ci: pytest jobs as reusable workflow for pr and schedule * ci: Add python 3.11 in python version matrix * chore: Update .gitignore * test: Update get_report response structure --- .github/workflows/scheduled.yml | 10 ++++++++++ .github/workflows/template_test.yml | 28 ++++++++++++++++++++++++++++ .github/workflows/test.yml | 28 ++-------------------------- .gitignore | 4 ++++ tests/api/test_api.py | 6 +----- 5 files changed, 45 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/scheduled.yml create mode 100644 .github/workflows/template_test.yml diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml new file mode 100644 index 0000000..8946f44 --- /dev/null +++ b/.github/workflows/scheduled.yml @@ -0,0 +1,10 @@ +--- +name: Scheduled tests +on: + schedule: + - cron: '0 0 1 * *' + +jobs: + pytest: + uses: ./.github/workflows/template_test.yml + secrets: inherit diff --git a/.github/workflows/template_test.yml b/.github/workflows/template_test.yml new file mode 100644 index 0000000..3087871 --- /dev/null +++ b/.github/workflows/template_test.yml @@ -0,0 +1,28 @@ +--- +on: workflow_call + +jobs: + pytest: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest pytest-dotenv + - name: Test with pytest + run: | + pytest -sv tests/ + env: + TADO_USERNAME: ${{ secrets.TADO_USERNAME }} + TADO_PASSWORD: ${{ secrets.TADO_PASSWORD }} + TADO_CLIENT_SECRET: ${{ secrets.TADO_CLIENT_SECRET }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 130fb2d..f3c5141 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,29 +5,5 @@ on: jobs: pytest: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10"] - - steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install pytest pytest-dotenv - - name: Set .env.test file - run: | - cat << EOF > .env.test - TADO_USERNAME=${{ secrets.TADO_USERNAME }} - TADO_PASSWORD=${{ secrets.TADO_PASSWORD }} - TADO_CLIENT_SECRET=${{ secrets.TADO_CLIENT_SECRET }} - EOF - - name: Test with pytest - run: | - pytest -sv tests/ + uses: ./.github/workflows/template_test.yml + secrets: inherit diff --git a/.gitignore b/.gitignore index b25166b..24321c3 100644 --- a/.gitignore +++ b/.gitignore @@ -82,6 +82,7 @@ celerybeat-schedule # virtualenv venv/ ENV/ +.venv/ # Spyder project settings .spyderproject @@ -96,3 +97,6 @@ gitchangelog.py # Mkdocs output/ + +# VSCode +.vscode/ diff --git a/tests/api/test_api.py b/tests/api/test_api.py index 4d98ef0..4810a36 100644 --- a/tests/api/test_api.py +++ b/tests/api/test_api.py @@ -265,12 +265,8 @@ def test_get_report(self): assert all(name in response["stripes"] for name in KEYS) KEYS = ["from", "to", "value"] assert all(name in response["stripes"]["dataIntervals"][0] for name in KEYS) - KEYS = ["stripeType", "setting"] + KEYS = ["stripeType"] assert all(name in response["stripes"]["dataIntervals"][0]["value"] for name in KEYS) - KEYS = ["type", "power", "temperature"] - assert all(name in response["stripes"]["dataIntervals"][0]["value"]["setting"] for name in KEYS) - KEYS = ["celsius", "fahrenheit"] - assert all(name in response["stripes"]["dataIntervals"][0]["value"]["setting"]["temperature"] for name in KEYS) KEYS = ["timeSeriesType", "valueType", "dataIntervals"] assert all(name in response["settings"] for name in KEYS)