Fakultas Ilmu Komputer UI

Commit bbab743f authored by Mika dabelza abi's avatar Mika dabelza abi
Browse files

tests added for Halaman_Katalog backend

parent 93f3b463
......@@ -16,6 +16,39 @@ class DaftarKatalogTest(TestCase):
found = resolve('/')
self.assertEqual(found.func.__name__, DaftarKatalog.as_view().__name__)
def test_fields(self):
materi = Materi()
materi.title = 'tes'
materi.cover = 'https://scontent.fbdo6-2.fna.fbcdn.net/v/t1.0-9/60274038_2279638138757984_7988420823012605952_n.jpg?_nc_cat=108&_nc_sid=110474&_nc_oc=AQlRDnDhg1kJjuoXEwYCYWosatAaFqwSiZdMmfbX_ORoTXu7cvJoawUihJPCjHXCqr0&_nc_ht=scontent.fbdo6-2.fna&oh=169b2c36df1a49f6a394208f21d09f7b&oe=5E94FF4E''
materi.author = 'input'
materi.save()
resp = Materi.objects.get(materi.id)
self.assertEqual(resp,materi)
def test_resolution(self):
resolver = resolve('/listMateri')
self.assertEqual(resolver, listMateri)
def test_fungsi_get(self):
self.materi = Materi()
self.materi.title = 'Wahyu'
self.materi.cover = 'https://scontent.fbdo6-2.fna.fbcdn.net/v/t1.0-9/60274038_2279638138757984_7988420823012605952_n.jpg?_nc_cat=108&_nc_sid=110474&_nc_oc=AQlRDnDhg1kJjuoXEwYCYWosatAaFqwSiZdMmfbX_ORoTXu7cvJoawUihJPCjHXCqr0&_nc_ht=scontent.fbdo6-2.fna&oh=169b2c36df1a49f6a394208f21d09f7b&oe=5E94FF4E''
self.materi.author = 'Saul Andre Lumban Gaol'
self.materi.save()
client = Client()
res = client.get('/listMateri')
expected_output = json.dumps({
cover : 'https://scontent.fbdo6-2.fna.fbcdn.net/v/t1.0-9/60274038_2279638138757984_7988420823012605952_n.jpg?_nc_cat=108&_nc_sid=110474&_nc_oc=AQlRDnDhg1kJjuoXEwYCYWosatAaFqwSiZdMmfbX_ORoTXu7cvJoawUihJPCjHXCqr0&_nc_ht=scontent.fbdo6-2.fna&oh=169b2c36df1a49f6a394208f21d09f7b&oe=5E94FF4E',
title : 'Wahyu',
author : 'Saul Andre Lumban Gaol',
})
self.assertJSONEqual(res, expected_output)
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