Skip to content

Commit

Permalink
ci: add make tests
Browse files Browse the repository at this point in the history
* Update test_charging_sensor.py

* make sure attr name and cls att is the same

* Run tests with github action

* Use make
  • Loading branch information
Hellowlol committed Jan 31, 2021
1 parent c6fe2b3 commit 7348af1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/python_package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches: [ $default-branch ]
pull_request:
branches: [ $default-branch ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pipenv
pipenv install -e . --dev
- name: Lint
run: |
make lint
- name: Test with pytest
run: |
make test
2 changes: 1 addition & 1 deletion teslajsonpy/homeassistant/charger.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def refresh(self) -> None:
self.__charger_actual_current = data["charger_actual_current"]
self.__charger_voltage = data["charger_voltage"]
self.__charge_limit_soc = data["charge_limit_soc"]
self.attrs["charge_limit_soc"] = self.charge_soc_limit
self.attrs["charge_soc_limit"] = self.charge_soc_limit
if self.measurement != "mi/hr":
self.__added_range = round(self.__added_range / 0.621371, 2)
self.__charging_rate = round(self.__charging_rate / 0.621371, 2)
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/homeassistant/test_charging_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_get_value_on_init(monkeypatch):
assert _sensor.charger_actual_current is None
assert _sensor.charger_voltage is None
assert _sensor.charge_energy_added is None
assert _sensor.charge_limit_soc is None
assert _sensor.charge_soc_limit is None


@pytest.mark.asyncio
Expand All @@ -72,7 +72,7 @@ async def test_get_value_after_update(monkeypatch):
assert _sensor.charger_actual_current == 0
assert _sensor.charger_voltage == 0
assert _sensor.charge_energy_added == 12.41
assert _sensor.charge_limit_soc == 90
assert _sensor.charge_soc_limit == 90


@pytest.mark.asyncio
Expand All @@ -95,7 +95,7 @@ async def test_async_update(monkeypatch):
assert _sensor.charger_actual_current == 0
assert _sensor.charger_voltage == 0
assert _sensor.charge_energy_added == 12.41
assert _sensor.charge_limit_soc == 90
assert _sensor.charge_soc_limit == 90


@pytest.mark.asyncio
Expand Down

0 comments on commit 7348af1

Please sign in to comment.