29 lines
617 B
Python
29 lines
617 B
Python
import pytest
|
|
|
|
from allmende_payment_system.models import Account, User
|
|
|
|
|
|
@pytest.fixture(scope="function")
|
|
def test_user(test_db):
|
|
user = User(username="test", display_name="Test User")
|
|
test_db.add(user)
|
|
test_db.flush()
|
|
return user
|
|
|
|
|
|
def test_user_model(test_db, test_user):
|
|
assert test_user.id is not None
|
|
|
|
account = Account(name="Test Account")
|
|
account.users.append(test_user)
|
|
test_db.add(account)
|
|
test_db.flush()
|
|
|
|
assert len(test_user.accounts) == 1
|
|
|
|
|
|
def test_user_shopping_cart_new(test_db, test_user):
|
|
cart = test_user.shopping_cart
|
|
|
|
assert len(cart.items) == 0
|