Fakultas Ilmu Komputer UI

Commit dc5d3293 authored by emil farisan's avatar emil farisan
Browse files

Model for list Items and associated migration

parent 4c05cc3b
from django.db import models
# Create your models here.
class Item(models.Model):
text = models.TextField(default='')
from django.test import TestCase
from lists.models import Item
class HomePageTest(TestCase):
......@@ -18,3 +19,23 @@ class HomePageTest(TestCase):
self.assertIn('<title>To-Do lists</title>', html)
self.assertTrue(html.strip().endswith('</html>'))
self.assertTemplateUsed(response, 'home.html')
class ItemModelTest(TestCase):
def test_saving_and_retrieving_items(self):
first_item = Item()
first_item.text = 'The first (ever) list item'
first_item.save()
second_item = Item()
second_item.text = 'Item the second'
second_item.save()
saved_items = Item.objects.all()
self.assertEqual(saved_items.count(), 2)
first_saved_item = saved_items[0]
second_saved_item = saved_items[1]
self.assertEqual(first_saved_item.text, 'The first (ever) list item')
self.assertEqual(second_saved_item.text, 'Item the second')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment