Skip to content

Game Management Commands #8

@uxabix

Description

@uxabix

We need to implement a set of Django management commands to simplify database initialization, testing, and maintenance for the game application.

Requirements

Implement the following management commands:

  • init_game_data — Create default suits, ranks, and cards.
  • create_test_users — Generate several test users (e.g., player1, player2, admin).
  • reset_games — Remove all active or unfinished games and related data.
  • generate_fake_games — Create sample games for UI and statistics testing.
  • export_db (optional) — Export current database data to a JSON file.
  • import_db (optional) — Import data from a JSON file.
  • check_integrity (optional) — Validate data consistency (cards, players, games).

Technical details

  • Place all commands inside the app’s management/commands/ directory.
  • Each command should inherit from BaseCommand and include:
    • A short help description.
    • Console feedback using self.stdout.write() and style helpers.
  • Commands like init_game_data and create_test_users must be idempotent (safe to run multiple times).
  • Commands should use existing Django models (e.g., Suit, Rank, Card, User, Game).
  • Optional commands (export_db, import_db, check_integrity) can be added later if needed.

Testing

  • Write unit tests for:
    • Data creation commands (init_game_data, create_test_users).
    • Reset functionality (reset_game).
    • Fake data generation (generate_fake_games).
  • Ensure each command runs successfully via:
python manage.py <command_name>
  • Verify that repeated execution does not create duplicates.

Definition of Done

  • All required commands are implemented and functional.
  • Each command includes clear docstrings and helpful CLI messages.
  • Basic tests confirm correct operation.
  • Optional commands are defined but may be implemented in future iterations.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions