feat: add smoke-test harness and CI (ruff + pytest)#62
Merged
Conversation
- Add GitHub Actions CI workflow with Python version matrix. - Define shared pytest fixtures for isolated environments and Jamf API mocks. - Introduce initial smoke tests for blueprints, webhooks, and login flows. - Configure ruff and pytest; update dev dependencies.
| ) | ||
| return redirect(url_for("resources_view.files")) | ||
| try: | ||
| os.remove(os.path.join(files_dir, target_file)) |
| """Install a .jawa.json workflow package into JAWA.""" | ||
| script = package["script"] | ||
| script_path = os.path.join(SCRIPTS_DIR, script["filename"]) | ||
| with open(script_path, "w", encoding="utf-8") as f: |
| script_path = os.path.join(SCRIPTS_DIR, script["filename"]) | ||
| with open(script_path, "w", encoding="utf-8") as f: | ||
| f.write(script["content"]) | ||
| os.chmod(script_path, 0o755) |
| @app.route("/webhooks/jamf/edit") | ||
| def _redir_jamf_edit(): | ||
| name = request.args.get("name", "") | ||
| return redirect(f"/automations/jamfpro/{name}/edit", code=301) |
| @app.route("/webhooks/custom/edit") | ||
| def _redir_custom_edit(): | ||
| name = request.args.get("name", "") | ||
| return redirect(f"/automations/custom/{name}/edit", code=301) |
| @app.route("/cron/edit") | ||
| def _redir_cron_edit(): | ||
| name = request.args.get("name", "") | ||
| return redirect(f"/automations/cron/{name}/edit", code=301) |
| @app.route("/cron/delete") | ||
| def _redir_cron_delete(): | ||
| name = request.args.get("target_job", "") | ||
| return redirect(f"/automations/cron/{name}/delete", code=301) |
|
|
||
| webhook = get_webhook_by_name(name) | ||
| tag = webhook.get("tag", "custom") if webhook else "custom" | ||
| return redirect(f"/automations/{tag}/{name}/delete", code=301) |
|
|
||
| @blueprint.route("/workflows/<path:rest>") | ||
| def workflows_rest_redirect(rest: str) -> Response: | ||
| return redirect(f"/templates/{rest}", code=301) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a full smoke-test suite for the JAWA web console and webhook receiver, along with the necessary configuration and fixtures to support isolated, reproducible testing. The suite requires no Jamf Pro server, network access, or root privileges, as all external dependencies are faked or stubbed. Additionally, the pull request sets up a CI workflow to run linting and tests across multiple Python versions, and adds configuration for
pytestandruff.Test Suite and Fixtures
tests/directory, covering route rendering, webhook receiver logic, and login/logout flows, with all Jamf Pro and script execution calls faked or stubbed (tests/README.md,tests/conftest.py,tests/test_smoke_routes.py,tests/test_receiver.py,tests/test_login.py) [1] [2] [3] [4] [5].tests/conftest.pyto redirect all module-level paths and external calls to per-test temporary directories and fake implementations, ensuring test isolation and no side effects (tests/conftest.py).Continuous Integration and Tooling
.github/workflows/ci.ymlto run linting (ruff) and tests (pytest) on Python 3.9 and 3.14 for both pushes and pull requests (.github/workflows/ci.yml).pytest.inito configure test discovery andrequirements-dev.txtto pin development dependencies (pytest,ruff) (pytest.ini,requirements-dev.txt) [1] [2].ruff.tomlto exclude thedata/workflows/scriptsdirectory from linting (ruff.toml).