Fakultas Ilmu Komputer UI

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

[RED] added test for category filtering

parent 1e4a7137
# Generated by Django 3.0.3 on 2020-04-22 14:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0007_auto_20200421_2151'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='profile',
field=models.CharField(default='51e685', max_length=100),
),
migrations.AlterField(
model_name='comment',
name='user',
field=models.CharField(default='9a89fd18ef5d4351a884acf98b36b71d', max_length=100),
),
]
# Generated by Django 3.0.3 on 2020-04-22 16:11
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0008_auto_20200422_2144'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='profile',
field=models.CharField(default='ca5be3', max_length=100),
),
migrations.AlterField(
model_name='comment',
name='user',
field=models.CharField(default='f88e20b6dcfc43daba68479578ecc003', max_length=100),
),
]
......@@ -17,6 +17,29 @@ class DaftarKatalogTest(TestCase):
response = Client().get('/')
self.assertTemplateUsed(response, 'app/katalog_materi.html')
def test_daftar_kategori(self):
kategori = Category()
kategori.name = "baru"
kategori.description = "kategori baru saya"
kategori.save()
kategori2 = Category()
kategori2.name = "baru2"
kategori2.save()
materi1 = Materi()
materi1.category.add(kategori)
materi1.title = "baru lah"
materi1.save()
materi2 = Materi()
materi2.category.add(kategori2)
cl = Client()
res = cl.get('/?kategori="baru"')
self.assertIN(b'materi1', res.content)
self.assertNotIn(b'materi2',res.content)
def test_daftar_katalog_using_daftar_katalog_func(self):
found = resolve('/')
......@@ -91,6 +114,7 @@ class DaftarKatalogTest(TestCase):
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 = "/materi/"
......
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