Skip to content

Commit

Permalink
actually add the model test
Browse files Browse the repository at this point in the history
  • Loading branch information
dmeliza committed Dec 7, 2024
1 parent dcccce7 commit 9847449
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions inventory/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- mode: python -*-

import pytest

from django.contrib.auth import get_user_model
from inventory.models import Item, Order, OrderItem, Vendor, Unit, Category, Account

def get_sentinel_user():
return get_user_model().objects.get_or_create(username="deleted")[0]

@pytest.mark.django_db
def test_order_cost():
user = get_sentinel_user()
category = Category.objects.create(name="glues and pastes")
unit = Unit.objects.create(name="each")
vendor = Vendor.objects.create(name="Unicorn Dispensary")
account = Account.objects.create(code="1234", description="unicorn paste fund")
item = Item.objects.create(name="unicorn paste", category=category, unit=unit, vendor=vendor, catalog="UPASTE1")
order = Order.objects.create(name="yearly unicorn paste supply", account=account, ordered_by=user)

orderitem = OrderItem.objects.create(item=item, order=order, units_purchased=10, cost=20)

assert orderitem.total_price() == 200

0 comments on commit 9847449

Please sign in to comment.