Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7f221be
feat: use gemini to write tests for python modules
justinbarclay Oct 24, 2025
5469d92
chore: add test workflow
justinbarclay Oct 23, 2025
ce5cb0e
chore: update contributing on running tests
justinbarclay Oct 24, 2025
774bd81
test: add test for cli
justinbarclay Oct 24, 2025
44e0c74
test: add comprehensive tests for proc_stats module
justinbarclay Oct 24, 2025
7e12f46
chore: Add debug prints and refine proc stats test
justinbarclay Oct 24, 2025
1a1cfe3
refactor: Extract helper functions from parse_status
justinbarclay Oct 24, 2025
4aa10be
refactor: tests to handle new structure in proc_stats
justinbarclay Oct 24, 2025
20b01fe
chore: update gitignore pyc
justinbarclay Oct 24, 2025
93b6228
fix: Refactor proc_stats module control flow to prevent UnboundLocalE…
justinbarclay Oct 24, 2025
bf1eb78
chore: fix potential divide by zero bug
justinbarclay Oct 24, 2025
4a182d8
tests: enhance and expand the test coverage
justinbarclay Oct 24, 2025
9e8a296
chore: fix bug where a timeout of 1 results in only running once
justinbarclay Oct 24, 2025
502702d
clarify and add tests
justinbarclay Oct 24, 2025
6f69186
fix: bug where module.exit_json doesn't return
justinbarclay Oct 24, 2025
09c1548
fix: assign result after after successful calculation.
justinbarclay Oct 24, 2025
30eea3d
test: Add test_main to verify main function setup with mocks
justinbarclay Oct 24, 2025
e42a9cd
fix: Correctly mock open context manager and assert call in test_main
justinbarclay Oct 24, 2025
077d265
fix: workflow triggers
justinbarclay Oct 24, 2025
6197cf4
chore: fix lints
justinbarclay Oct 24, 2025
fa0fb85
remove: pointless cli tests
justinbarclay Oct 24, 2025
a054956
chore: fix python flake integration
justinbarclay Oct 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Python Tests

on:
pull_request:
branches:
- main
- master

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
cd ./unix
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev-requirements.txt
- name: Test with pytest
run: |
pytest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
.vscode/
*.pyc
16 changes: 16 additions & 0 deletions unix/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ We use the following tools:
src/machine_stats/*` or `pipenv run pylint src`)
* `bump2version` for version bumps (`pipenv run bump2version`)

### Testing

We use `pytest` for testing. Test files are located in the `tests/` directory and should be named with a `test_` prefix (e.g., `test_my_feature.py`).

To run the tests, use the following command:

```console
pytest
```

or

```console
pipenv run pytest
```

### How to release a new Machine Stats version

To deploy a new version of Machine Stats, you will need to create a release. The steps are pretty simple, You can find Github's instruction [here](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release).
Expand Down
2 changes: 2 additions & 0 deletions unix/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ twine = "*"
wheel = "*"
build = "*"
bump2version = "*"
pytest = "*"
pytest-mock = "*"

[scripts]
stats = "machine_stats"
2 changes: 2 additions & 0 deletions unix/dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ webencodings==0.5.1
wheel==0.38.4
wrapt==1.14.1; python_version < '3.11'
zipp==3.11.0; python_version < '3.10'
pytest
pytest-mock
218 changes: 209 additions & 9 deletions unix/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading