Skip to content

Commit

Permalink
Merge branch 'add-test-framework' of https://github.com/Pyhass/Pyhiveapi
Browse files Browse the repository at this point in the history
 into dev
  • Loading branch information
Khole Jones authored and Khole Jones committed Nov 20, 2024
2 parents 3f183a3 + 9100fda commit 1841f5d
Show file tree
Hide file tree
Showing 58 changed files with 1,555 additions and 1,420 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[run]
source = src
omit =
*/__init__.py
*/debugger.py
46 changes: 23 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements.txt') }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_all.txt') }}-${{
hashFiles('requirements_test_all.txt') }}
restore-keys: |
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_test.txt') }}-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements_all.txt') }}-${{ hashFiles('requirements_test_all.txt') }}-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements_all.txt') }}
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-
- name: Create Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
python -m venv venv
. venv/bin/activate
pip install -U "pip<20.3" setuptools
pip install -r requirements.txt -r requirements_test.txt
pip install -r requirements_all.txt -r requirements_test_all.txt
- name: Restore pre-commit environment from cache
id: cache-precommit
uses: actions/[email protected]
Expand Down Expand Up @@ -83,8 +83,8 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements.txt') }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_all.txt') }}-${{
hashFiles('requirements_test_all.txt') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -127,8 +127,8 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements.txt') }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_all.txt') }}-${{
hashFiles('requirements_test_all.txt') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -171,8 +171,8 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements.txt') }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_all.txt') }}-${{
hashFiles('requirements_test_all.txt') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -218,8 +218,8 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements.txt') }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_all.txt') }}-${{
hashFiles('requirements_test_all.txt') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -265,8 +265,8 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements.txt') }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_all.txt') }}-${{
hashFiles('requirements_test_all.txt') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -312,8 +312,8 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements.txt') }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_all.txt') }}-${{
hashFiles('requirements_test_all.txt') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -356,8 +356,8 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements.txt') }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_all.txt') }}-${{
hashFiles('requirements_test_all.txt') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -403,8 +403,8 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements.txt') }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_all.txt') }}-${{
hashFiles('requirements_test_all.txt') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -447,8 +447,8 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements.txt') }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_all.txt') }}-${{
hashFiles('requirements_test_all.txt') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements_all.txt ]; then pip install -r requirements_all.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors.
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ __pycache__/
build
dist
pyhiveapi.egg-info
*.coverage

# due to using tox and pytest
.tox
.cache
test*
custom_tests/*

# virtual environment folder
Expand Down
8 changes: 6 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"python.testing.pytestArgs": [],
"python.testing.pytestArgs": ["--disable-warnings"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
"python.testing.pytestEnabled": true,
"[python]": {
"editor.showUnused": false,
},
"python.formatting.provider": "black",
}
115 changes: 115 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Pytest",
"detail": "Execute pytest tests for pyhiveapi/apyhiveapi",
"type": "shell",
"command": "pytest --timeout=10 tests",
"dependsOn": ["Install all Test Requirements", "Install Package Locally"],
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Flake8",
"detail": "Run flake8 checks on the libary",
"type": "shell",
"command": "pre-commit run flake8 --all-files",
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Pylint",
"detail": "Run pylint checks on the libary",
"type": "shell",
"command": "pylint src",
"dependsOn": ["Install all Requirements"],
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Code Coverage",
"detail": "Generate local code coverage report.",
"type": "shell",
"command": "pytest --cov-report html --cov=apyhiveapi tests/apyhiveapi && pytest --cov-report html --cov=pyhiveapi --cov-append tests/pyhiveapi",
"dependsOn": ["Install all Test Requirements", "Install Package Locally"],
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Install all Requirements",
"detail": "Install all requirements needed to run pyhiveapi/apyihiveapi ",
"type": "shell",
"command": "pip3 install --use-deprecated=legacy-resolver -r requirements_all.txt",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Install all Test Requirements",
"detail": "Install all test requirement for pytest.",
"type": "shell",
"command": "pip3 install --use-deprecated=legacy-resolver -r requirements_test_all.txt",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Install Package Locally",
"detail": "Install pyhiveapi/apyhiveapi locally.",
"type": "shell",
"command": "pip3 install --upgrade --use-deprecated=legacy-resolver .",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
],
"inputs": []
}

6 changes: 3 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
recursive-include pyhiveapi *
include requirements.txt
include requirements_test.txt
recursive-include src *
include requirements_all.txt
include requirements_test_all.txt
recursive-include data *
17 changes: 0 additions & 17 deletions pyhiveapi/apyhiveapi/data/camera.json

This file was deleted.

Loading

0 comments on commit 1841f5d

Please sign in to comment.