Add shopping cart and related models
This commit is contained in:
@@ -1,16 +1,28 @@
|
||||
import pytest
|
||||
|
||||
from allmende_payment_system.models import Account, User
|
||||
|
||||
|
||||
def test_user_model(test_db):
|
||||
@pytest.fixture(scope="function")
|
||||
def test_user(test_db):
|
||||
user = User(username="test", display_name="Test User")
|
||||
test_db.add(user)
|
||||
test_db.commit()
|
||||
test_db.flush()
|
||||
return user
|
||||
|
||||
assert user.id is not None
|
||||
|
||||
def test_user_model(test_db, test_user):
|
||||
assert test_user.id is not None
|
||||
|
||||
account = Account(name="Test Account")
|
||||
account.users.append(user)
|
||||
account.users.append(test_user)
|
||||
test_db.add(account)
|
||||
test_db.commit()
|
||||
test_db.flush()
|
||||
|
||||
assert len(user.accounts) == 1
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user