Skip to content

fix(tests): correct mock paths and context type in test_generators#319

Open
ota2000 wants to merge 1 commit intoz3z1ma:mainfrom
ota2000:ota2000/fix/test-generators-mock-paths
Open

fix(tests): correct mock paths and context type in test_generators#319
ota2000 wants to merge 1 commit intoz3z1ma:mainfrom
ota2000:ota2000/fix/test-generators-mock-paths

Conversation

@ota2000
Copy link

@ota2000 ota2000 commented Feb 14, 2026

Summary

Fixes 17 failing tests in tests/core/test_generators.py caused by two issues:

  1. Wrong context type: Tests passed yaml_context (YamlRefactorContext) to generator functions that expect DbtProjectContext. Fixed by passing yaml_context.project instead.

  2. Invalid mock paths: Tests patched non-existent module-level attributes (e.g., dbt_osmosis.core.generators.SourceGenerator) for symbols that are lazy-imported inside functions. Fixed by targeting the actual import source modules:

    • dbt_core_interface.source_generator.SourceGenerator
    • dbt_core_interface.staging_generator.generate_staging_model_from_source
    • dbt_core_interface.doc_checker.DocumentationChecker
  3. Filesystem error: One test used /custom/staging as a path, causing OSError: Read-only file system. Fixed by using pytest's tmp_path fixture.

Result

  • Before: 17 failed, 11 passed
  • After: 28 passed, 0 failed
  • Full suite: 633 passed, 6 skipped, 0 failed

@ota2000 ota2000 marked this pull request as ready for review February 14, 2026 05:56
- Pass yaml_context.project (DbtProjectContext) instead of yaml_context
  (YamlRefactorContext) to generator functions that expect DbtProjectContext
- Fix mock.patch paths to target lazy import sources
  (dbt_core_interface.source_generator/staging_generator/doc_checker)
  instead of non-existent module-level attributes on dbt_osmosis.core.generators
- Use tmp_path fixture instead of absolute /custom/staging path to avoid
  read-only filesystem errors
@ota2000 ota2000 force-pushed the ota2000/fix/test-generators-mock-paths branch from 3c0d8ea to 055ab5e Compare February 14, 2026 05:57
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