-
Notifications
You must be signed in to change notification settings - Fork 1
Add db seeding script for jwt protected route testing #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add db seeding script for jwt protected route testing #12
Conversation
Using context managers for mocks fixes the mock leak that caused KeyError failures in test_app.py and test_integration.py. Confirmed by successful run of test_script_entry_point_calls_main.
…of github.com:methods/S_BookAPIV.2 into Add-DB-seeding-script-for-JWT-protected-route-testing
There was a problem hiding this 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 |
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>
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.
How Has This Been Tested?
Checklist: