Skip to content

fix(#23): add tests/ with unit coverage for dialect write-path hooks - #26

Open
Analitiq-Bot wants to merge 2 commits into
mainfrom
fix/issue-23-no-tests-directory-zero-unit-coverage
Open

fix(#23): add tests/ with unit coverage for dialect write-path hooks#26
Analitiq-Bot wants to merge 2 commits into
mainfrom
fix/issue-23-no-tests-directory-zero-unit-coverage

Conversation

@Analitiq-Bot

Copy link
Copy Markdown
Collaborator

Summary

Adds the missing tests/ directory, mirroring the mysql/mariadb/bigquery layout, to close the parity gap raised in #23. The test suite covers the three pure-Python entry points that had zero unit coverage:

  • stage_table_sql — both temp=True and temp=False branches; verifies identifiers are quoted via quote_table and never interpolated raw.
  • merge_statement_sql — the DO UPDATE SET path for a normal upsert, and the DO NOTHING degradation when every landed column is a conflict key (an empty DO UPDATE SET is a PostgreSQL syntax error, so this branch is load-bearing).
  • build_tls_connect_arg — all seven mode paths: verify-ca/verify-full require a CA bundle; require+CA builds a verifying context without hostname checking; disable/allow/prefer/require (no CA) pass through as strings; any unrecognized or case-variant mode raises ValueError (security invariant — prevents silent bypass of CA verification).

Two contract pins are also added:

  • max_identifier_length == 63 must match sql_capabilities.limits.max_identifier_len in definition/connector.json.
  • empty_table_sql must render DELETE FROM, not TRUNCATE (the CDK conformance kit rejects TRUNCATE unconditionally).

pyproject.toml gains [tool.pytest.ini_options] with testpaths = ["tests"], pythonpath = ["."], and addopts = "--import-mode=importlib".

Test plan

pip install analitiq-cdk pyarrow pytest
python -m pytest tests/ -v

26 tests collected, all passing. Every branch in the issue's "Worth covering" list is exercised by at least one test, with parametrized cases for passthrough modes and bad mode strings.

Closes #23

Analitiq-Bot and others added 2 commits August 2, 2026 11:51
Mirror the mysql layout: tests/conftest.py + tests/test_connector.py,
with [tool.pytest.ini_options] in pyproject.toml (testpaths, pythonpath,
--import-mode=importlib).

Covers all items listed in #23:
- stage_table_sql: temp=True/False branches; identifiers go through
  quote_table, not raw interpolation.
- merge_statement_sql: DO UPDATE SET path; DO NOTHING degradation when
  every landed column is a conflict key (empty SET list is a syntax error).
- build_tls_connect_arg: verify-ca/verify-full require a CA bundle;
  require + CA builds a verifying context (check_hostname=False); the
  three plaintext modes pass through as strings; any unrecognized or
  case-variant mode raises ValueError (security property).
- Contract pin: max_identifier_length == 63 == sql_capabilities.limits.max_identifier_len.
- Contract pin: empty_table_sql renders DELETE not TRUNCATE.

26 tests, all passing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Read max_identifier_len from connector.json in the contract pin so the
  test actually cross-checks the dialect against the published contract
  (hardcoded 63 would stay green even if the two values diverged).
- Add test_require_with_empty_string_ca_is_passthrough: empty string is
  falsy and must not trigger CA verification, same as None.
- test_do_nothing_when_all_columns_are_conflict_keys: switch from
  substring assertions to exact string equality so INSERT/SELECT/ON
  CONFLICT structure is also pinned.
- test_column_order_preserved: replace fragile sql.index() extraction
  with exact string equality; document both INSERT and SELECT order.
- test_identifiers_are_quoted (stage): remove the redundant
  assert "DROP TABLE x" in sql line (the quoted-form assertions above
  already prove safe quoting).
- Module docstring: drop the "no other automated coverage" qualifier
  (only what IS covered here can be stated confidently).
- Replace non-ASCII arrow -> in comment with ASCII --.
- Add comment above parametrize explaining why require is excluded.

27 tests, all passing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Analitiq-Bot
Analitiq-Bot marked this pull request as ready for review August 2, 2026 11:56
@Analitiq-Bot

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

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.

No tests/ directory: the rc17 dialect hooks have zero unit coverage

1 participant