Skip to content

Commit

Permalink
Add basic tests (home-assistant-libs#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored Feb 16, 2022
1 parent 06c463c commit 29a06da
Show file tree
Hide file tree
Showing 12 changed files with 2,176 additions and 52 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ jobs:
pip install -r requirements-test.txt
- name: Lint with flake8
run: |
flake8 aiohue
flake8 aiohue tests
- name: Check formatting with black
run: |
black aiohue --check
black aiohue tests --check
- name: Run tests
run: |
pytest tests
2 changes: 2 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
flake8==4.0.1
black==22.1.0
pytest==7.0.1
pytest-aiohttp==1.0.4
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ ignore =
W503,
E203,
D202

[tool:pytest]
asyncio_mode = auto
Empty file added tests/__init__.py
Empty file.
15 changes: 15 additions & 0 deletions tests/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Common utilities for fixtures."""
import json
import pathlib


def load_fixture(name: str):
"""Load a fixture from disk."""
path = pathlib.Path(__file__).parent / "fixtures" / name

content = path.read_text()

if name.endswith(".json"):
return json.loads(content)

return content
50 changes: 0 additions & 50 deletions tests/fixtures/battery_state.json

This file was deleted.

Loading

0 comments on commit 29a06da

Please sign in to comment.