Skip to content

feat: Use Gemini to set-up the basics of tests for our python cli#277

Merged
justinbarclay merged 22 commits intomasterfrom
jb/gemini-tests
Oct 27, 2025
Merged

feat: Use Gemini to set-up the basics of tests for our python cli#277
justinbarclay merged 22 commits intomasterfrom
jb/gemini-tests

Conversation

@justinbarclay
Copy link
Member

No description provided.

@justinbarclay justinbarclay requested a review from Copilot October 24, 2025 15:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a test suite for the Python CLI machine stats project, utilizing pytest as the testing framework. The changes include setting up basic test infrastructure and adding initial test coverage for core functionality.

  • Adds pytest and pytest-mock to development dependencies across multiple package management systems (Pipfile, dev-requirements.txt, flake.nix)
  • Creates test files covering process statistics, CPU utilization, and helper functions
  • Sets up a GitHub Actions workflow to run tests on pull requests against Python 3.8, 3.9, and 3.10
  • Bumps the version from "develop" to "0.1.1"

Reviewed Changes

Copilot reviewed 9 out of 15 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
unix/tests/test_proc_stats.py Adds unit tests for parse_status and process_stats functions with comprehensive mocking
unix/tests/test_main.py Creates tests for RAM, storage, CPU, and IP address helper functions
unix/tests/test_helpers.py Duplicates helper function tests with slightly different test cases
unix/tests/test_cpu_utilization.py Adds tests for CPU utilization measurement functions
unix/setup.py Updates package version from "develop" to "0.1.1"
unix/flake.nix Adds pytest and pluggy to Nix development environment
unix/dev-requirements.txt Adds pytest and pytest-mock dependencies
unix/Pipfile Adds pytest and pytest-mock to pipenv configuration
.github/workflows/python-tests.yml Creates GitHub Actions workflow for automated testing on PRs

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 14 out of 17 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@justinbarclay justinbarclay force-pushed the jb/gemini-tests branch 2 times, most recently from 9768723 to fa0fb85 Compare October 24, 2025 21:01
Copy link
Contributor

@SamDesmondKing SamDesmondKing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome improvements and refactors here, this repo was long overdue for some love.

@SamDesmondKing
Copy link
Contributor

As an aside, I'm having some trouble getting things set up correctly so that I can run tests locally. Tried a variety of things, maybe we can take a look together if we get time.

image

@justinbarclay
Copy link
Member Author

@SamDesmondKing this should be fixed

@justinbarclay justinbarclay merged commit d6beb08 into master Oct 27, 2025
5 checks passed
@justinbarclay justinbarclay deleted the jb/gemini-tests branch October 27, 2025 18:44
justinbarclay added a commit that referenced this pull request Oct 27, 2025
* feat: use gemini to write tests for python modules

* chore: add test workflow

* chore: update contributing on running tests

* test: add test for cli

* test: add comprehensive tests for proc_stats module

* chore: Add debug prints and refine proc stats test

* refactor: Extract helper functions from parse_status

* refactor: tests to handle new structure in proc_stats

* chore: update gitignore pyc

* fix: Refactor proc_stats module control flow to prevent UnboundLocalError

* chore: fix potential divide by zero bug

* tests: enhance and expand the test coverage

* chore: fix bug where a timeout of 1 results in only running once

* clarify and add tests

* fix: bug where module.exit_json doesn't return

* fix: assign result after after successful calculation.

This makes it easier to follow the logic and does not rely on a second
if check for the same condition

* test: Add test_main to verify main function setup with mocks

* fix: Correctly mock open context manager and assert call in test_main

* fix: workflow triggers

* chore: fix lints

* remove: pointless cli tests

* chore: fix python flake integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants