Fakultas Ilmu Komputer UI

Commit 08080eee authored by Saul Andre's avatar Saul Andre
Browse files

[RED] add test for detail materi pages

parent a449cdea
......@@ -16,7 +16,6 @@ class DaftarKatalogTest(TestCase):
response = Client().get('/')
self.assertTemplateUsed(response, 'app/katalog_materi.html')
def test_daftar_katalog_using_daftar_katalog_func(self):
found = resolve('/')
self.assertEqual(found.func.__name__, DaftarKatalog.as_view().__name__)
......@@ -48,8 +47,24 @@ 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": ""}})
self.assertJSONEqual(queryset.json()[1:-1], expected_output)
self.assertJSONNotEqual(queryset.json()[1:-1], unexpected_output)
class DetailMateriTest(TestCase):
def test_detail_materi_url_exist(self):
url = "/detail-materi"
response = Client().get(f'{url}')
self.assertEqual(response.status_code,200)
self.assertNotEqual(response.status_code, 404)
def test_detail_materi_using_daftar_katalog_template(self):
response = Client().get('/')
self.assertTemplateUsed(response, 'app/detail_materi.html')
def test_detail_materi_using_detail_materi_func(self):
found = resolve('/')
self.assertEqual(found.func.__name__, detail_materi.as_view().__name__)
class TemplateLoaderTest(TestCase):
def test_template_loader_url_exist(self):
......
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