im/inventory/tests.py

26 lines
785 B
Python

from django.test import TestCase
from django.test import Client
from inventory.models import PantryItem, Category
class PantryItemTestCase(TestCase):
""" simple test case for a model"""
def setUp(self):
cat = Category.objects.create(name="UNCATEGORIZED")
PantryItem.objects.create(name="testitem", category=cat)
def test_pantryitem_looksok(self):
"""Pantryitems to string is ok"""
testitem = PantryItem.objects.get(name="testitem")
self.assertEqual(str(testitem), 'testitem')
class InterFaceTestCase(TestCase):
"""Simple test case for the web interface"""
def test_consume_view_exists(self):
client = Client()
response = client.get('/consume/')
self.assertTrue(b"TODO" not in response.content)