-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Small refactor of Builders/Builder.py (#273)
* refactor: changed Builder.py * refactor: changed name from _BuilderState to BuilderState * refactor: added unit tests for the BuilderStates module * feat: added tox-based CI * feat: removed the newest python version * feat: removed unnecessary entries * feat: simplified workflow * fix: fixing executing tests in Actions * fix: changed allow_externals from poetry to pytest * fix: add pytest-cov as a required package for testing * fix: removed macos and windows testing * refactor: removed commented line
- Loading branch information
1 parent
f197120
commit 007d868
Showing
10 changed files
with
87 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: check | ||
on: | ||
push: | ||
pull_request: | ||
|
||
concurrency: | ||
group: check-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test: | ||
name: test with ${{ matrix.py }} on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
py: | ||
- "3.11" | ||
- "3.10" | ||
- "3.9" | ||
os: | ||
- ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup python for test ${{ matrix.py }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.py }} | ||
- name: Install tox | ||
run: python -m pip install -r tests/requirements.txt | ||
- name: Run test suite | ||
run: tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2023 @jurgenwigg | ||
# Distributed under the terms of the MIT License. | ||
"""Unit tests for Builder.py module""" | ||
from HaikuPorter.Builders.Builder import BuilderState | ||
from pytest import mark | ||
|
||
|
||
def test_number_of_possible_states(): | ||
"""Tests number of possible states. | ||
We assume that only 4 possible states are possible. | ||
""" | ||
expected_value = 4 | ||
actual_value = len( | ||
[item for item in BuilderState.__dict__.keys() if not item.startswith("__")] | ||
) | ||
assert expected_value == actual_value | ||
|
||
|
||
@mark.parametrize( | ||
"state, expected_result", | ||
[ | ||
["AVAILABLE", "Available"], | ||
["LOST", "Lost"], | ||
["NOT_AVAILABLE", "Not Available"], | ||
["RECONNECT", "Reconnecting"], | ||
], | ||
) | ||
def test_is_state_present(state, expected_result): | ||
"""Tests if given state returns expected state string.""" | ||
assert BuilderState.__dict__[state] == expected_result |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pytest | ||
pytest-cov | ||
tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,7 @@ | ||
[tox] | ||
skipsdist = true | ||
envlist = py38, py39, py310, py311 | ||
|
||
[gh-actions] | ||
python = | ||
3.8: py38 | ||
3.9: py39 | ||
3.10: py310 | ||
3.11: py311 | ||
|
||
[testenv] | ||
passenv = PYTHON_VERSION | ||
allowlist_externals = poetry | ||
allowlist_externals = pytest | ||
commands = | ||
poetry install -v | ||
pytest --doctest-modules tests --cov --cov-config=pyproject.toml --cov-report=xml | ||
mypy |