Add CRUD operations for users with tests and fixtures
Implemented user CRUD operations including creation, retrieval, updating, and deletion through a generic CRUD base class. Enhanced user schemas with additional attributes and created tests to verify functionality, covering edge cases such as duplicates and pagination. Updated the test suite with new fixtures and methods to support the tests.
This commit is contained in:
@@ -38,6 +38,18 @@ async def async_test_db():
|
||||
yield test_engine, AsyncTestingSessionLocal
|
||||
await teardown_async_test_db(test_engine)
|
||||
|
||||
@pytest.fixture
|
||||
def user_create_data():
|
||||
return {
|
||||
"email": "newtest@example.com", # Changed to avoid conflict with mock_user
|
||||
"password": "TestPassword123!",
|
||||
"first_name": "Test",
|
||||
"last_name": "User",
|
||||
"phone_number": "+1234567890",
|
||||
"is_superuser": False,
|
||||
"preferences": None
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_user(db_session):
|
||||
@@ -50,7 +62,8 @@ def mock_user(db_session):
|
||||
last_name="User",
|
||||
phone_number="1234567890",
|
||||
is_active=True,
|
||||
is_superuser=False
|
||||
is_superuser=False,
|
||||
preferences=None,
|
||||
)
|
||||
db_session.add(mock_user)
|
||||
db_session.commit()
|
||||
|
||||
Reference in New Issue
Block a user