Fakultas Ilmu Komputer UI

Verified Commit 7c5af83c authored by Giovan Isa Musthofa's avatar Giovan Isa Musthofa
Browse files

[RED] Add download_query test for JadwalDonor model

parent d7325369
from datetime import datetime, timedelta
from django.test import TestCase
from django.utils import timezone
from django.core.exceptions import ValidationError
from main.factories import UserFactory
from donor.models import JadwalDonor
from donor.factories import JadwalDonorFactory, DaftarDonorFactory
from datetime import datetime
from django.core.exceptions import ValidationError
class JadwalDonorTest(TestCase):
......@@ -26,6 +28,19 @@ class JadwalDonorTest(TestCase):
time_end=datetime.fromisoformat(time_end), quota=150, category=JadwalDonor.Category.PRIVATE
def test_download_query(self):
user1 = UserFactory(email='donald@duckduckgo.org')
user2 = UserFactory(email='daisy@duckduckgo.org')
jadwal_donor = JadwalDonorFactory(time_start=timezone.localtime() - timedelta(hours=24),
time_end=timezone.localtime() - timedelta(hours=23))
DaftarDonorFactory(user=user1, jadwal_donor=jadwal_donor, has_attended=True)
DaftarDonorFactory(user=user2, jadwal_donor=jadwal_donor, has_attended=True)
qs = JadwalDonor.download_query([jadwal_donor.id])
self.assertEqual(len(qs), 2)
class DaftarDonorTest(TestCase):
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