Fakultas Ilmu Komputer UI

Commit 2b54b036 authored by Syahrul Ardiansyah's avatar Syahrul Ardiansyah
Browse files

Split out unit tests into two files

parent 2da290eb
Pipeline #23517 passed with stage
in 1 minute and 58 seconds
from django.test import TestCase
from latihan2.models import Item
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')
from django.urls import resolve
from django.test import TestCase
from django.http import HttpRequest
from latihan2.views import home_page
from latihan2.models import Item
......@@ -67,19 +66,3 @@ class HomePageTest(TestCase):
response = self.client.get('/')
self.assertIn('oh tidak', response.content.decode())
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