Fakultas Ilmu Komputer UI

Commit 177d1067 authored by Saul Andre's avatar Saul Andre
Browse files

[RED] add testcase for category models, and update test for materi models

parent a40a4f59
......@@ -46,8 +46,22 @@ class DaftarKatalogTest(TestCase):
queryset = client.get('/list-materi/')
expected_output = json.dumps({"pk": self.materi.pk, "model": "app.materi", "fields": {"cover": "https://cache.umusic.com/_sites/billieeilish/v2/images/pic-red.jpg", "title": "Wahyu", "author": "Saul Andre Lumban Gaol"}})
unexpected_output = json.dumps({"pk": self.materi.pk, "model": "app.materi", "fields": {"cover": "", "title": "", "author": ""}})
expected_output = json.dumps({"pk": self.materi.pk, "model": "app.materi",
"fields": {"cover": "https://cache.umusic.com/_sites/billieeilish/v2/images/pic-red.jpg",
"title": "Wahyu",
"author": "Saul Andre Lumban Gaol",
"uploader": "Bayu",
"publisher": "Diskominfo Depok",
"description": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
"category": "#medis"}})
unexpected_output = json.dumps({"pk": self.materi.pk, "model": "app.materi",
"fields": {"cover": "",
"title": "",
"author": "",
"uploader": "",
"publisher": "",
"description": "",
"category": ""}})
self.assertJSONEqual(queryset.json()[1:-1], expected_output)
self.assertJSONNotEqual(queryset.json()[1:-1], unexpected_output)
......@@ -66,6 +80,12 @@ class DetailMateriTest(TestCase):
found = resolve('/')
self.assertEqual(found.func.__name__, detail_materi.as_view().__name__)
def test_kategori_models_can_create_new_object(self):
test = Category.objects.create(id="1", name="medis", desc="kategori medis")
countData = Category.objects.all().count()
self.assertEqual(1, countData)
self.assertEqual(test.__str__(), "medis")
class TemplateLoaderTest(TestCase):
def test_template_loader_url_exist(self):
url = "/test-page.html"
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