Skip to content

Commit

Permalink
Fix minor issues with test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs committed Oct 12, 2023
1 parent c45df23 commit 5190865
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ jobs:
runs-on: "ubuntu-latest"
name: Validate
steps:
- uses: "actions/checkout@v4"
- uses: "actions/checkout@v4"

- name: HACS validation
uses: "hacs/action@main"
with:
category: "integration"
ignore: brands
- name: HACS validation
uses: "hacs/action@main"
with:
category: "integration"
ignore: brands

- name: Hassfest validation
uses: "home-assistant/actions/hassfest@master"
- name: Hassfest validation
uses: "home-assistant/actions/hassfest@master"

style:
runs-on: "ubuntu-latest"
name: Check style formatting
steps:
- uses: "actions/checkout@v4"
- uses: "actions/setup-python@v4"
with:
python-version: "3.x"
- run: python3 -m pip install black
- run: black .
- uses: "actions/checkout@v4"
- uses: "actions/setup-python@v4"
with:
python-version: "3.x"
- run: python3 -m pip install black
- run: black .

tests:
runs-on: "ubuntu-latest"
Expand All @@ -42,9 +42,9 @@ jobs:
- name: Setup Python
uses: "actions/setup-python@v4"
with:
python-version: "3.8"
python-version: "3.11"
- name: Install requirements
run: python3 -m pip install -r requirements_test.txt
run: python3 -m pip install -r requirements_dev.txt
- name: Run tests
run: |
pytest \
Expand All @@ -55,4 +55,4 @@ jobs:
--cov custom_components.expose_camera_stream_source \
-o console_output_style=count \
-p no:sugar \
tests
tests
13 changes: 7 additions & 6 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ While tests aren't required to publish a custom component for Home Assistant, th
# Getting Started

To begin, it is recommended to create a virtual environment to install dependencies:

```bash
python3 -m venv venv
source venv/bin/activate
```

You can then install the dependencies that will allow you to run tests:
`pip3 install -r requirements_test.txt.`
`pip3 install -r requirements_dev.txt.`

This will install `homeassistant`, `pytest`, and `pytest-homeassistant-custom-component`, a plugin which allows you to leverage helpers that are available in Home Assistant for core integration tests.

# Useful commands

Command | Description
------- | -----------
`pytest tests/` | This will run all tests in `tests/` and tell you how many passed/failed
`pytest --durations=10 --cov-report term-missing --cov=custom_components.expose_camera_stream_source tests` | This tells `pytest` that your target module to test is `custom_components.expose_camera_stream_source` so that it can give you a [code coverage](https://en.wikipedia.org/wiki/Code_coverage) summary, including % of code that was executed and the line numbers of missed executions.
`pytest tests/test_init.py -k test_setup_unload_and_reload_entry` | Runs the `test_setup_unload_and_reload_entry` test function located in `tests/test_init.py`
| Command | Description |
| ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `pytest tests/` | This will run all tests in `tests/` and tell you how many passed/failed |
| `pytest --durations=10 --cov-report term-missing --cov=custom_components.expose_camera_stream_source tests` | This tells `pytest` that your target module to test is `custom_components.expose_camera_stream_source` so that it can give you a [code coverage](https://en.wikipedia.org/wiki/Code_coverage) summary, including % of code that was executed and the line numbers of missed executions. |
| `pytest tests/test_init.py -k test_setup_unload_and_reload_entry` | Runs the `test_setup_unload_and_reload_entry` test function located in `tests/test_init.py` |

0 comments on commit 5190865

Please sign in to comment.