Fakultas Ilmu Komputer UI

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

[RED] Add test to admin download JadwalDonor

parent bcd02709
from datetime import timedelta
from django.urls import reverse
from django.utils import timezone
from django.utils.timezone import localtime
from django.test import TestCase
from rest_framework import status
from rest_framework.test import APITestCase
from django.utils import timezone
from donor.factories import JadwalDonorFactory, DaftarDonorFactory
from donor.models import JadwalDonor
from main.factories import UserFactory
from datetime import timedelta
from main.models import User
from rest_framework_authlib.tokens import AccessToken
from django.utils.timezone import localtime
class JadwalDonorTests(APITestCase):
......@@ -271,3 +274,27 @@ class RiwayatDonorTest(APITestCase):
'quota': second_jadwal_donor.quota,
'category': second_jadwal_donor.category
}])
class JadwalDonorAdminTest(TestCase):
def setUp(self):
username = 'admin@host'
password = 'secretsauce'
User.objects.create_superuser(username, password)
self.client.login(username=username, password=password)
def test_action_download_jadwaldonor(self):
user = UserFactory(email='donald@duckduckgo.org')
user.save()
jadwal_donor = JadwalDonorFactory(time_start=timezone.localtime() - timedelta(hours=24),
time_end=timezone.localtime() - timedelta(hours=23))
daftar_donor = DaftarDonorFactory(user=user,
jadwal_donor=jadwal_donor,
has_attended=True)
endpoint = reverse('admin:donor_jadwaldonor_changelist')
data = {'action': 'download_jadwaldonor', '_selected_action': [jadwal_donor.id]}
response = self.client.post(endpoint, data=data)
self.assertEqual(response['content-type'], 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
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