Skip to content

Commit

Permalink
ci: Run scheduled tests through ci (#330)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
germainlefebvre4 committed May 13, 2024
1 parent 2e3fb7f commit 60238be
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 31 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Scheduled tests
on:
schedule:
- cron: '0 0 1 * *'

jobs:
pytest:
uses: ./.github/workflows/template_test.yml
secrets: inherit
28 changes: 28 additions & 0 deletions .github/workflows/template_test.yml
Original file line number Diff line number Diff line change
@@ -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 }}
28 changes: 2 additions & 26 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ celerybeat-schedule
# virtualenv
venv/
ENV/
.venv/

# Spyder project settings
.spyderproject
Expand All @@ -96,3 +97,6 @@ gitchangelog.py

# Mkdocs
output/

# VSCode
.vscode/
6 changes: 1 addition & 5 deletions tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 60238be

Please sign in to comment.