From 93aadfb6f2fc9f678547ffb88e517a17ddc573d0 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Mon, 25 Apr 2022 22:49:29 +0200 Subject: [PATCH] ci: fix test --- .github/workflows/test.yml | 7 ++++--- docs/Develop.md | 6 +++--- tests/__init__.py | 0 tests/data/config.ini | 9 +++++++++ tests/data/config.json | 15 +++++++++++++++ tests/test_chargecontrol.py | 8 +++++--- 6 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/data/config.ini create mode 100644 tests/data/config.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 648a09c..f327c19 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,6 @@ jobs: test: runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@v2 - name: Set up python id: setup-python uses: actions/setup-python@v2 @@ -21,6 +20,7 @@ jobs: uses: snok/install-poetry@v1 with: virtualenvs-in-project: true + - uses: actions/checkout@v2 - name: Load cached venv id: cached-poetry-dependencies uses: actions/cache@v2 @@ -40,6 +40,7 @@ jobs: run: | echo Test source .venv/bin/activate - coverage run -m unittest || exit 1 + coverage run -m unittest || exit 11 + coverage combine coverage report - [ -n "$CODACY_PROJECT_TOKEN" ] && coverage combine && coverage xml -o cobertura.xml && bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r cobertura.xml + [ -n "$CODACY_PROJECT_TOKEN" ] && coverage xml -o cobertura.xml && bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r cobertura.xml diff --git a/docs/Develop.md b/docs/Develop.md index 1834870..ece1f23 100644 --- a/docs/Develop.md +++ b/docs/Develop.md @@ -1,11 +1,11 @@ # Developer Information -## Contributing + ## Contributing -Before create a pull request check your code with Prospector. +Before creating a pull request check your code with Prospector. You can install it with ``` -poetry install --no-root``` +poetry install --no-root #Then in the root of the git project: prospector ``` diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/data/config.ini b/tests/data/config.ini new file mode 100644 index 0000000..537e577 --- /dev/null +++ b/tests/data/config.ini @@ -0,0 +1,9 @@ +[General] +currency = € + +[Electricity config] +day price = 0.1853 +night price = 0.1353 +night hour start = 22h30 +night hour end = 6h00 + diff --git a/tests/data/config.json b/tests/data/config.json new file mode 100644 index 0000000..127e047 --- /dev/null +++ b/tests/data/config.json @@ -0,0 +1,15 @@ +{ + "abrp": { + "token": null + }, + "client_id": "cid", + "client_secret": "csec", + "co2_signal_api": null, + "country_code": "FR", + "customer_id": "AP-ACNT1234", + "proxies": null, + "realm": "clientsB2CPeugeot", + "refresh_token": "aasds-aaa", + "remote_refresh_token": "aa", + "weather_api": null +} \ No newline at end of file diff --git a/tests/test_chargecontrol.py b/tests/test_chargecontrol.py index 1204ca7..c22cfcc 100644 --- a/tests/test_chargecontrol.py +++ b/tests/test_chargecontrol.py @@ -22,20 +22,22 @@ from psa_car_controller.psacc.application.charge_control import ChargeControl # 2022-04-20 12:31:15,552 :: INFO :: Approaching scheduled charging time, but should not charge. Postponing charge hour! # 2022-04-20 12:31:15,552 :: INFO :: Changing stop_hour to 11:0 -class MyTestCase(unittest.TestCase): - def test_something(self): +class TestChargeControl(unittest.TestCase): + + def test_charge_control(self): my_logger() ChargeControl.MQTT_TIMEOUT = 0 now = datetime.datetime.now() + stop_hour = now + datetime.timedelta(minutes=2) vin = "123" percentage_threshold = 70 state = { "charging": True, - "stop_hour": [now.hour, now.minute + 2] + "stop_hour": [stop_hour.hour, stop_hour.minute] } expectations = {