Skip to content

Conversation

@codesungrape
Copy link
Collaborator

Description

This PR introduces a seeding script as a way to populate the development database with default users. This script follows a clean, testable pattern by separating the core logic into a seed_users() function and the execution into a main() function.
It results seeding the database with users with securely hashed passwords.
The Makefile and README.md files have been updated to reflect the new associated make command.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update
  • Code refactor (improving code quality without changing functionality)

How Has This Been Tested?

  • Automated tests: Script tests (tests/scripts/test_seed_users.py)
  • Manual verification- makefile command 'make seed-users' + mongosh

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My individual commit messages are descriptive and follow our commit guidelines
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link

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 introduces a database seeding script for populating the development database with default users to support JWT protected route testing. The implementation follows clean coding practices with separated concerns and comprehensive test coverage.

Key changes:

  • Adds a new seed_users() function that securely hashes passwords and handles duplicate email checks
  • Implements a main() function for script execution with proper error handling for file operations
  • Includes comprehensive test suite covering success cases, error scenarios, and edge cases

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
scripts/seed_users.py Core seeding script with password hashing and duplicate user handling
scripts/test_data/sample_user_data.json Sample user data for development database seeding
tests/scripts/test_seed_users.py Comprehensive test suite for the seeding functionality
tests/scripts/test_create_books.py Refactored existing tests to use modern testing patterns
Makefile Added seed-users command for easy script execution
README.md Updated documentation to reflect new seeding command

codesungrape and others added 5 commits August 12, 2025 18:00
Apply copilot typo fix

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Apply copilot typo fix

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Apply copilot typo fix

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Apply copilot typo fix

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Apply copilot typo fix

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@codesungrape codesungrape merged commit e30f56f into main Aug 13, 2025
2 checks passed
@codesungrape codesungrape deleted the Add-DB-seeding-script-for-JWT-protected-route-testing branch August 13, 2025 10:46
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.

3 participants