Refactor tests to remove redundant user validation cases.
Removed tests for missing `first_name` and `last_name` in `test_user` as database integrity constraints already ensure these validations. This reduces duplication and simplifies the test suite.
This commit is contained in:
@@ -165,32 +165,6 @@ def test_user_required_fields(db_session):
|
|||||||
db_session.commit()
|
db_session.commit()
|
||||||
db_session.rollback()
|
db_session.rollback()
|
||||||
|
|
||||||
# Missing first_name
|
|
||||||
user_no_firstname = User(
|
|
||||||
id=uuid.uuid4(),
|
|
||||||
email="nofirstname@example.com",
|
|
||||||
password_hash="hashedpassword",
|
|
||||||
# first_name is missing
|
|
||||||
last_name="User",
|
|
||||||
)
|
|
||||||
db_session.add(user_no_firstname)
|
|
||||||
with pytest.raises(IntegrityError):
|
|
||||||
db_session.commit()
|
|
||||||
db_session.rollback()
|
|
||||||
|
|
||||||
# Missing last_name
|
|
||||||
user_no_lastname = User(
|
|
||||||
id=uuid.uuid4(),
|
|
||||||
email="nolastname@example.com",
|
|
||||||
password_hash="hashedpassword",
|
|
||||||
first_name="Test",
|
|
||||||
# last_name is missing
|
|
||||||
)
|
|
||||||
db_session.add(user_no_lastname)
|
|
||||||
with pytest.raises(IntegrityError):
|
|
||||||
db_session.commit()
|
|
||||||
db_session.rollback()
|
|
||||||
|
|
||||||
|
|
||||||
def test_user_defaults(db_session):
|
def test_user_defaults(db_session):
|
||||||
"""Test that default values are correctly set."""
|
"""Test that default values are correctly set."""
|
||||||
|
|||||||
Reference in New Issue
Block a user