Skip to content

Add pytest scaffolding + first batch of unit tests for utils/helpers.py#63

Draft
andrewtclim wants to merge 1 commit into
mainfrom
andrew/scaffold-tests
Draft

Add pytest scaffolding + first batch of unit tests for utils/helpers.py#63
andrewtclim wants to merge 1 commit into
mainfrom
andrew/scaffold-tests

Conversation

@andrewtclim
Copy link
Copy Markdown

@andrewtclim andrewtclim commented Jun 3, 2026

Summary

  • Adds the first tests/ directory in the repo, with pytest configured as a dev dependency in pyproject.toml and discovery pointed at tests/.
  • Writes six unit tests against src/deployml/utils/helpers.py, deliberately chosen to cover three distinct testing patterns rather than six variations of one:
    • Pure functiongenerate_bucket_name (2 tests: normal project ID; ID with underscores → hyphens for GCS validity)
    • Mocking the OS boundarycheck_command (2 tests: binary found, binary missing — shutil.which patched via unittest.mock)
    • Parsing logicestimate_terraform_time (2 tests: Cloud SQL detected → 20-min estimate; small non-SQL stack → resource-count estimate)
  • All six tests pass locally in <2s.

Why this PR

The repo has no test scaffolding yet. Rather than add a large suite all at once, this PR establishes the infrastructure and demonstrates the three patterns future tests will lean on. Subsequent batches can extend tests/test_helpers.py (or split into more files) without touching the scaffolding.

Marking as draft so reviewers can weigh in on testing conventions (file layout, naming, fixture style) before more tests land.

Test plan

  • python3 -m pytest -v runs and reports 6 passed
  • python3 -m pytest -k bucket runs only the 2 bucket tests
  • Reviewer confirms tests/ layout + pyproject.toml config match the conventions they'd like to see going forward

Notes / follow-ups

  • No CI workflow added yet — intentional for this first PR. A GitHub Actions job that runs pytest on every PR is a small follow-up.
  • No coverage tool (pytest-cov) added — also intentional, to keep the first batch focused.
  • Next testing targets discussed: copy_modules_to_workspace (will need a tmp_path fixture), bucket_exists / generate_unique_bucket_name (will need to mock the google.cloud.storage client).

Sets up the first tests/ directory in the repo. Adds pytest as a dev
dependency, configures discovery via pyproject.toml, and writes six
unit tests covering three patterns: a pure function (generate_bucket_name),
a function mocked at the OS boundary (check_command), and parsing logic
(estimate_terraform_time).
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.

1 participant