Fakultas Ilmu Komputer UI

Commit 1c941264 authored by addffa's avatar addffa
Browse files

[RED] membuat test_no_ktp_mustahik_is_unique

parent c6fa6cb0
from datetime import date
from django.db.utils import IntegrityError
from django.test import TestCase
from .models import Mustahik
......@@ -24,3 +25,20 @@ class MustahikModelTestCase(TestCase):
def test_mustahik_creation(self):
mustahik = Mustahik.objects.get(no_ktp='31751234567890')
self.assertTrue(isinstance(mustahik, Mustahik))
def test_no_ktp_mustahik_is_unique(self):
with self.assertRaises(IntegrityError):
Mustahik.objects.create(
name='kihatsum',
no_ktp='31751234567890',
phone='08987654321',
address='Jalan raya bogor',
province='Jawa Barat',
regency='Bogor',
rt='002',
rw='003',
birthdate=date(1987, 4, 3),
status=Mustahik.Status.MISKIN,
family_size=1,
description='no_ktp is unique'
)
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