Skip to content

Commit

Permalink
Add more code quality checks to tests (#78)
Browse files Browse the repository at this point in the history
* Fix tests to be ruff compliant.

* Tidy projects settings.

* Add ruff checks to test dir.
  • Loading branch information
gwww authored Aug 21, 2024
1 parent c090e70 commit f7ffa92
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: uv run ruff format --check

- name: Ruff lint/sort/etc checking
run: uv run ruff check --no-fix elkm1_lib
run: uv run ruff check --no-fix elkm1_lib test

- name: Run pylint
run: uv run pylint elkm1_lib
Expand Down
24 changes: 9 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ build-backend = "hatchling.build"
[tool.pytest.ini_options]
asyncio_mode = "auto"

[tool.pyright]
pythonVersion = "3.11"

[tool.pylint."MESSAGES CONTROL"]
disable = [
"format", # Handled by black
Expand Down Expand Up @@ -76,18 +73,15 @@ enable = [
python_version = "3.11"
ignore_missing_imports = true

[tool.pyright]
pythonVersion = "3.11"

[tool.ruff.lint]
select = [
# pycodestyle
"E",
# Pyflakes
"F",
# pyupgrade
# "UP",
# flake8-bugbear
# "B",
# flake8-simplify
"SIM",
# isort
"I",
"E", # pycodestyle
"F", # Pyflakes
# "UP", # pyupgrade
# "B", # flake8-bugbear
"SIM", # flake8-simplify
"I", # isort
]
14 changes: 7 additions & 7 deletions test/test_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ def areas(notifier):
def test_entry_exit_general(areas, notifier):
rx_msg("EE", "100601201", notifier)
area = areas[0]
assert area.is_exit == True
assert area.is_exit is True
assert area.timer1 == 60
assert area.timer2 == 120
assert area.armed_status == ArmedStatus.ARMED_AWAY


def test_entry_exit_armed_status(areas, notifier):
area = areas[0]
assert area.is_armed() == False
assert area.is_armed() is False
rx_msg("EE", "110300601", notifier)
assert area.is_armed() == True
assert area.is_armed() is True


def test_alarm_memory(areas, notifier):
rx_msg("AM", "10101010", notifier, zeros="")
assert areas[0].alarm_memory == True
assert areas[1].alarm_memory == False
assert areas[0].alarm_memory is True
assert areas[1].alarm_memory is False


def test_armed_status(areas, notifier):
Expand All @@ -55,7 +55,7 @@ def test_armed_status_updates_alarm_triggers(notifier):

def test_is_in_alarm_state():
area = Area(0, Mock(), Mock())
assert area.in_alarm_state() == False
assert area.in_alarm_state() is False

area.alarm_state = AlarmState.POLICE_ALARM
assert area.in_alarm_state() == True
assert area.in_alarm_state() is True
2 changes: 1 addition & 1 deletion test/test_thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_entry_exit_general(thermostats, notifier):
rx_msg("TR", "0120072687500", notifier)
thermostat = thermostats[0]
assert thermostat.mode == ThermostatMode.COOL
assert thermostat.hold == False
assert thermostat.hold is False
assert thermostat.fan == ThermostatFan.AUTO
assert thermostat.current_temp == 72
assert thermostat.heat_setpoint == 68
Expand Down
8 changes: 4 additions & 4 deletions test/test_zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def test_zone_definition(zones, notifier):

def test_zone_alarm_state(zones, notifier):
rx_msg("AZ", f"05:A0000{'0' * 200}", notifier)
assert zones[0].triggered_alarm == False
assert zones[1].triggered_alarm == True
assert zones[2].triggered_alarm == True
assert zones[3].triggered_alarm == True
assert zones[0].triggered_alarm is False
assert zones[1].triggered_alarm is True
assert zones[2].triggered_alarm is True
assert zones[3].triggered_alarm is True


def test_zone_voltage(zones, notifier):
Expand Down

0 comments on commit f7ffa92

Please sign in to comment.