🧪 Add tests for user registration error paths#66
🧪 Add tests for user registration error paths#66DivyanshuChipa wants to merge 1 commit intomasterfrom
Conversation
This change introduces unit tests for the `register_user` function in `backend/users.py`, specifically covering: - Successful user registration. - Duplicate username registration (triggers `sqlite3.IntegrityError`). - Registration requiring admin approval. A `backend/tests/conftest.py` was added to: - Mock the `passlib` dependency which is missing in the environment. - Provide a `setup_test_db` fixture that creates an isolated temporary SQLite database for each test. Verified by running `pytest backend/tests/test_users.py`. Co-authored-by: DivyanshuChipa <211708943+DivyanshuChipa@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f4e33763a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,42 @@ | |||
| import pytest | |||
| from backend.users import register_user | |||
There was a problem hiding this comment.
Remove hard dependency on PYTHONPATH in test import
Using from backend.users import register_user makes test collection fail under a standard pytest run when PYTHONPATH is not explicitly set (it raises ModuleNotFoundError: No module named 'backend'), so the new suite is not runnable out of the box. This blocks the registration tests in default local/CI environments unless extra path configuration is added; switch to an import path that works with the repo layout (or add explicit pytest path config) so tests collect reliably.
Useful? React with 👍 / 👎.
Added a comprehensive test suite for user registration in
backend/users.py. The tests cover the happy path (successful registration), the edge case where admin approval is required, and the error path where a duplicate username triggers ansqlite3.IntegrityError. Since thepassliblibrary is not available in the environment, a mocking strategy was implemented inconftest.pyto allow the tests to run successfully. Each test runs against an isolated, temporary SQLite database to ensure no side effects.PR created automatically by Jules for task 14722163909695510411 started by @DivyanshuChipa