Skip to content

Move test infrastructure to proper locations#124

Closed
StephanMeijer wants to merge 1 commit into
mainfrom
feat/seed
Closed

Move test infrastructure to proper locations#124
StephanMeijer wants to merge 1 commit into
mainfrom
feat/seed

Conversation

@StephanMeijer
Copy link
Copy Markdown
Collaborator

Summary

  • Move factories.py from core/ to core/tests/ (test utilities belong in test folders)
  • Create seed management command in core/ (renamed from create_demo in demo/ app)
  • Delete the entire demo/ Django app (was overkill for one management command)

Changes

Before After
core/factories.py core/tests/factories.py
demo/management/commands/create_demo.py core/management/commands/seed.py
demo/defaults.py Inlined into seed.py
make demo make seed
demo/ app in INSTALLED_APPS Removed

Verification

  • ✅ All 75 tests pass
  • make seed creates 1000 documents across 5 test indexes
  • ✅ No orphan imports from demo module
  • ✅ Makefile, Tiltfile, and README updated

@StephanMeijer StephanMeijer changed the title refactor(core): move test infrastructure to proper locations Move test infrastructure to proper locations May 7, 2026
@StephanMeijer StephanMeijer requested a review from Copilot May 7, 2026 15:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reorganizes Django “demo/seed” and test utilities by removing the demo app, relocating factories into core/tests, and renaming/moving the demo data management command into core as seed, with corresponding updates to developer workflows (Make/Tilt/README).

Changes:

  • Removed the demo app from INSTALLED_APPS and deleted its defaults module.
  • Moved test factories into core/tests/factories.py and updated test imports accordingly.
  • Added core.management.commands.seed (renamed from create_demo) and updated make/Tilt/README to use seed.

Reviewed changes

Copilot reviewed 10 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/backend/find/settings.py Removes demo from INSTALLED_APPS.
src/backend/demo/defaults.py Deletes demo defaults (now inlined into seed).
src/backend/core/tests/test_models_services.py Updates factories import path to core.tests.factories.
src/backend/core/tests/test_commands_seed.py Renames test to seed and patches inlined constants.
src/backend/core/tests/test_api_documents_index_bulk.py Updates factories import path to core.tests.factories.
src/backend/core/tests/test_api_documents_delete.py Updates factories import path to core.tests.factories.
src/backend/core/tests/factories.py Fixes imports after moving factories into core/tests/.
src/backend/core/management/commands/seed.py Introduces seed command, inlines defaults, and replaces create_demo.
README.md Updates developer instructions from make demo to make seed.
Makefile Renames demo target to seed and updates bootstrap dependency.
bin/Tiltfile Renames Tilt button/script to run seed instead of create_demo.
Comments suppressed due to low confidence (3)

src/backend/core/management/commands/seed.py:175

  • seed() is using service.name as the OpenSearch index name (e.g., ensure_index_exists(service.name) / indices.refresh(index=service.name)), but the rest of the codebase uses the prefixed index name via Service.index_name ({OPENSEARCH_INDEX_PREFIX}-{service.name}). This will seed documents into indexes the API won’t query. Use service.index_name consistently here (and in the later bulk indexing / count/refresh calls).
    src/backend/core/management/commands/seed.py:21
  • This management command imports core.tests.factories, which pulls in factory_boy/faker from the dev extras and couples runtime code to the test package. Consider moving the ServiceFactory used for seeding into a non-test module (e.g., core/factories.py or core/devdata.py) or doing local object creation, and leave core.tests.factories for tests only.
    src/backend/core/management/commands/seed.py:168
  • opensearch_client_.indices.delete(index="*") will delete every index in the cluster (including unrelated or system indices) when run in DEBUG. To reduce blast radius, consider deleting only the project’s indices (e.g., ${OPENSEARCH_INDEX_PREFIX}-*) or adding an explicit --all-indices flag for the current behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
@StephanMeijer
Copy link
Copy Markdown
Collaborator Author

Closed: is LaSuite convention

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants