Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create_user_with_detail(*args, **kwargs):
user = _create_user_with_detail(*args, **kwargs)
db.session.add(user)
try:
db.session.commit()
except Exception as e:
db.session.rollback()
raise UserCreationFailed(e)
return user
def test_days_until_next_birthday(today_text, expected):
user = create_user_with_detail(date_of_birth=date(1994, 3, 18))
with freeze_time(today_text):
assert user.detail.days_until_next_birthday == expected
def test_is_birthday_today(today_text, expected):
user = create_user_with_detail(date_of_birth=date(1994, 3, 18))
with freeze_time(today_text):
assert user.detail.is_birthday_today == expected
def create_user(date_of_birth):
return create_user_with_detail(date_of_birth=date_of_birth)
def test_age(today_text, expected):
user = create_user_with_detail(date_of_birth=date(1994, 3, 18))
with freeze_time(today_text):
assert user.detail.age == expected