Skip to content

test: cover toCamelCase first_upper=True branch - #3

Closed
olitreadwell wants to merge 1 commit into
masterfrom
olitreadwell/cover-tocamelcase-first-upper
Closed

test: cover toCamelCase first_upper=True branch#3
olitreadwell wants to merge 1 commit into
masterfrom
olitreadwell/cover-tocamelcase-first-upper

Conversation

@olitreadwell

@olitreadwell olitreadwell commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Upstream target

Amsterdam/schema-tools: no issue, self-found test-coverage gap.

What changed

Add a unit test for toCamelCase(..., first_upper=True) (the PascalCase form).

Test only.

No source change.

Why

toCamelCase has a first_upper argument, but no test exercised the first_upper=True branch.

A coverage run on naming.py reported exactly one missing line: line 82, which is that branch:

src/schematools/naming.py   25   1   6   1   94%   82

That branch is not dead code: schematools/types.py calls toCamelCase(self.id, first_upper=True) (lines 443 and 1305) to build class names from dataset and table ids.

So the behaviour is worth locking down.

How to verify

git fetch https://github.com/olitreadwell/schema-tools.git olitreadwell/cover-tocamelcase-first-upper
git checkout FETCH_HEAD
uv sync --extra django
uv run pytest tests/test_naming.py \
  --cov=schematools.naming --cov-report=term-missing -q

Before this change: naming.py 94%, line 82 missing.

After this change: naming.py 100%, no missing lines. 4 passed.

Coverage

Before: naming.py 94% (line 82 missing) / After: naming.py 100%.

Checks run locally

  • Tests: PASS (4 passed, 0 failed: tests/test_naming.py, re-verified during this audit with uv run pytest)
  • Lint: PASS (uvx pre-commit run --files tests/test_naming.py: ruff, pyupgrade, django-upgrade, whitespace/EOF all pass, re-verified during this audit)
  • Typecheck: N/A: this repo has no mypy/typecheck hook in CI or pre-commit
  • Build: N/A: test-only change, no packaging impact

The full pytest suite needs PostgreSQL + GDAL, which the fork CI provides (postgis service container + gdal apt install).

This change only touches the pure tests/test_naming.py, which needs neither.

Style / template compliance

No CONTRIBUTING.md, no PR template, and no CLA/DCO requirement found in this repo.

Matched the existing style of tests/test_naming.py: same imports, same -> None signatures, docstring first line, grounded assertions, and a pytest.raises(ValueError) empty-string check like the neighbouring tests.

Commit convention: this repo's own history is plain, lowercase, imperative, no type prefix, no emoji (e.g. add tests, improve test coverage, catch unexpected validation errors).

The original commit here used a Conventional Commits style (test: ✅ ...) which doesn't match.

During this audit I amended the single commit to add test for toCamelCase first_upper branch to match the house style, and force-pushed the fix, the PR content is unchanged.

AI review (ocr)

Ran ocr delegate rule (delegation mode, self-reviewed against its Python rubric: no mutable defaults, no dead code, no resource/exception-handling issues, correct == comparisons throughout).

All seven assertions were re-verified during this audit by actually running the new test (uv run pytest), not just re-reading them: confirmed passing against the real implementation, not guessed values.

Clean, no changes needed.

Confidence: HIGH

Small, isolated, additive test.

Expected values were produced by the current implementation, not guessed.

Worst case: a future refactor of toCamelCase changes the PascalCase output, which is exactly what this test is meant to catch.

Promotion command (when Oli chooses to send this upstream):

gh pr create --repo Amsterdam/schema-tools --base master --head olitreadwell:test/tocamelcase-first-upper-coverage-20260804-201541

No CLA, no DCO, no signed-commit requirement, no PR template file to fill.

AI assistance

Drafted with AI assistance.

The gap was found and verified against the current code, the change was verified before opening, and this diff was reviewed line by line.


PROMOTION NOTE (remove this section before/when opening against upstream):

gh pr create --repo Amsterdam/schema-tools --base master --head olitreadwell:olitreadwell/cover-tocamelcase-first-upper

Prerequisites: none outstanding (re-verify CLA/DCO/signing before promoting).

Add test_toCamelCase_first_upper for the PascalCase form of toCamelCase.
This first_upper=True path had no direct test; it is the single line that
coverage reported missing in naming.py (line 82).

It is the form used in schematools.types to build class names from dataset
and table ids, so it is worth locking down.

Values were verified against the current implementation. Also checks that an
empty ident still raises ValueError with first_upper=True.
@olitreadwell
olitreadwell force-pushed the olitreadwell/cover-tocamelcase-first-upper branch from 6a5f4aa to 065d059 Compare August 18, 2026 22:33
@olitreadwell

Copy link
Copy Markdown
Owner Author

Closing as superseded: the same change is already open upstream in Amsterdam#765. See Amsterdam#765

@olitreadwell

Copy link
Copy Markdown
Owner Author

Superseded by upstream Amsterdam#765.

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