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_order_with_payment_state(payment_state):
user = create_user()
shop_id = 'shop-123'
placed_by = user
order = create_order(shop_id, placed_by)
order.payment_state = payment_state
return order
def test_path(data_path, avatar_id, image_type, expected):
user = create_user()
avatar = create_avatar(user.id, avatar_id, image_type)
with app_context() as app:
app.config['PATH_DATA'] = data_path
assert avatar.path == expected
def test_is_expired(purpose, now, expected):
user = create_user()
created_at = datetime(2014, 11, 26, 17, 44, 53)
token = create_verification_token(user.id, purpose, created_at)
with freeze_time(now):
assert token.is_expired == expected
:License: Modified BSD, see LICENSE for details.
"""
from uuid import UUID
import pytest
from byceps.services.ticketing.models.ticket import Ticket
from testfixtures.user import create_user
ANY_BUNDLE_ID = UUID('4138fcfb-cc18-45c0-aede-d49a8e279885')
user1 = create_user('TicketUser1')
user2 = create_user('TicketUser2')
user3 = create_user('TicketUser3')
@pytest.mark.parametrize('bundle_id, expected', [
(ANY_BUNDLE_ID, True ),
(None, False),
])
def test_belongs_to_bundle(bundle_id, expected):
ticket = create_ticket(user1.id, bundle_id=bundle_id)
assert ticket.belongs_to_bundle == expected
@pytest.mark.parametrize('owned_by_id, seat_managed_by_id, user_managed_by_id, user_id, expected', [
(user1.id, None , None , user1.id, True ),
def test_hybrid_image_type_setter(image_type, expected):
user = create_user()
avatar = create_avatar(user.id)
avatar.image_type = image_type
assert avatar._image_type == expected
from uuid import UUID
import pytest
from byceps.services.ticketing.models.ticket import Ticket
from testfixtures.user import create_user
ANY_BUNDLE_ID = UUID('4138fcfb-cc18-45c0-aede-d49a8e279885')
user1 = create_user('TicketUser1')
user2 = create_user('TicketUser2')
user3 = create_user('TicketUser3')
@pytest.mark.parametrize('bundle_id, expected', [
(ANY_BUNDLE_ID, True ),
(None, False),
])
def test_belongs_to_bundle(bundle_id, expected):
ticket = create_ticket(user1.id, bundle_id=bundle_id)
assert ticket.belongs_to_bundle == expected
@pytest.mark.parametrize('owned_by_id, seat_managed_by_id, user_managed_by_id, user_id, expected', [
(user1.id, None , None , user1.id, True ),
(user1.id, user1.id, None , user1.id, True ),
(user1.id, None , user1.id, user1.id, True ),
def test_hybrid_image_type_setter(image_type, expected):
user = create_user(1)
user.avatar_image_type = image_type
assert user._avatar_image_type == expected
def test_hybrid_image_type_getter(database_value, expected):
user = create_user()
avatar = create_avatar(user.id)
avatar._image_type = database_value
assert avatar.image_type == expected