Skip to content

test(orm): refactor DBSeedCommand tests to class-based app-driven style - #175

Merged
tmgbedu merged 1 commit into
experimentsfrom
task/1001-db-seed-command-tests
Jul 14, 2026
Merged

test(orm): refactor DBSeedCommand tests to class-based app-driven style#175
tmgbedu merged 1 commit into
experimentsfrom
task/1001-db-seed-command-tests

Conversation

@tmgbedu

@tmgbedu tmgbedu commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Refactors the DBSeedCommand test coverage introduced in PR Add test coverage for masoniteorm make and seed console commands #155 to the desired class-based style: TestDBSeedCommand(unittest.TestCase) with a setUp that builds a real Application via fixtures.app.create_app().
  • Consolidates test_db_seed_command.py (mocked-Seeder option/argument-resolution coverage) and test_seed_commands.py (real fixture-seeder end-to-end coverage) into one file/class, since both were testing DBSeedCommand and had drifted into duplicate coverage across two files.
  • Fixture/end-to-end tests now drive the command through self.app.run("db:seed", ...), exercising the fully registered console command.
  • Mocked-Seeder tests and the two exception-path tests keep using a CommandTester-based _run helper for direct execution — the console application swallows command exceptions (Application.run catches and reports them rather than propagating), so assertRaises(ValueError) requires the direct path.
  • fixtures/app.py already existed (used by test_migrate_commands.py) and is reused as-is; no framework code changed.
  • test_make_commands.py and test_migrate_commands.py were left untouched — they're already class-based unittest.TestCases, and the make/generator commands operate on os.getcwd() rather than the app container, so folding them into the create_app() pattern wouldn't add coverage (and MakeObserverCommand isn't registered on the app, so it can't be driven via self.app.run()).

Test plan

  • uv run pytest tests/masoniteorm/commands/ -v — 41 passed, 1 skipped
  • uv run pytest --ignore=tests/masoniteorm/postgres — 1837 passed, 7 skipped, no regressions
  • uv run ruff check / ruff format --check on the changed file

🤖 Generated with Claude Code

Consolidate test_db_seed_command.py and test_seed_commands.py into a
single TestDBSeedCommand(unittest.TestCase). setUp now builds a real
Application via fixtures.app.create_app(); option/argument-resolution
tests keep driving the command directly through CommandTester (needed
for the mocked-Seeder assertions and for the exception paths, since the
console app swallows command exceptions), while the fixture-backed
end-to-end tests now run through self.app.run("db:seed", ...).
@tmgbedu
tmgbedu merged commit f4b6cd9 into experiments Jul 14, 2026
5 checks passed
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

tmgbedu added a commit that referenced this pull request Jul 14, 2026
Replace the hand-rolled FakeSeeder class in test_db_seed_command.py
with mock.patch(..., autospec=True) against the real Seeder, asserting
constructor args and awaited calls directly. Same cleanup already
applied on the PR #155 branch (commit 8471bd9) but missed on the
experiments seeds->seeders refactor (PR #175).
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