test: coverage for build_args_str() and load_env_file() inline comment stripping#3
Open
thor-guardrail wants to merge 2 commits into
Open
Conversation
…line comment parsing Two improvements: 1. _build_args_str() was duplicated identically in both dds/providers/azure/container.py and dds/builders/docker.py. Moved the canonical implementation to dds/utils/shell.build_args_str() (with shell-quoting via shlex.quote — see PR digitalforgeca#1 for the safety fix). Both original sites now import and delegate to the shared version. Module-level _build_args_str aliases kept for backward compatibility. 2. load_env_file() in dds/secrets.py did not strip inline comments from unquoted values, so a line like: DATABASE_URL=postgres://localhost/mydb # local dev only would produce 'postgres://localhost/mydb # local dev only' as the value. This is incorrect — standard .env file parsers (dotenv et al.) strip inline comments from unquoted values. Quoted values are left untouched (the comment is considered part of the value when quoted). Added stripping for ' #' and '\t#' comment separators on unquoted values.
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
Adds test coverage for the two new behaviours introduced in PR #2.
Depends on PR #2 (
fix/build-args-dedup-env-file-comments) — merge that first.1.
tests/test_shell_utils.py(new file) —build_args_str()andrun_cmd()Tests cover:
None/ empty dict → empty stringshell=True)=(connection strings, base64) → survive round-tripAlso adds smoke tests for
run_cmd()which had zero coverage: stdout capture, non-zero exit,cwd, andenvmerging.2.
tests/test_secrets.py—load_env_file()inline comment stripping (4 new cases)# comment→ comment stripped\t# comment→ comment stripped#inside → hash preserved (PASSWORD="hunter#2")