Add pytest scaffolding + first batch of unit tests for utils/helpers.py#63
Draft
andrewtclim wants to merge 1 commit into
Draft
Add pytest scaffolding + first batch of unit tests for utils/helpers.py#63andrewtclim wants to merge 1 commit into
andrewtclim wants to merge 1 commit into
Conversation
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).
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.
Summary
tests/directory in the repo, withpytestconfigured as a dev dependency inpyproject.tomland discovery pointed attests/.src/deployml/utils/helpers.py, deliberately chosen to cover three distinct testing patterns rather than six variations of one:generate_bucket_name(2 tests: normal project ID; ID with underscores → hyphens for GCS validity)check_command(2 tests: binary found, binary missing —shutil.whichpatched viaunittest.mock)estimate_terraform_time(2 tests: Cloud SQL detected → 20-min estimate; small non-SQL stack → resource-count estimate)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 -vruns and reports6 passedpython3 -m pytest -k bucketruns only the 2 bucket teststests/layout +pyproject.tomlconfig match the conventions they'd like to see going forwardNotes / follow-ups
pyteston every PR is a small follow-up.pytest-cov) added — also intentional, to keep the first batch focused.copy_modules_to_workspace(will need atmp_pathfixture),bucket_exists/generate_unique_bucket_name(will need to mock thegoogle.cloud.storageclient).