Fakultas Ilmu Komputer UI

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

[RED] Add test to admin download AcaraDonor

parent a4085ea6
import datetime
from unittest.mock import patch
from django.contrib.auth import get_user_model
from django.test import TestCase
from django.urls import reverse
from django.utils import timezone
from rest_framework import status
from rest_framework.test import APITestCase
......@@ -12,6 +14,9 @@ from acara_donor.admin import AcaraDonorAdmin
from acara_donor.filters import AcaraDonorFilter
User = get_user_model()
class AcaraDonorTest(TestCase):
""" Test module for Acara Donor model"""
......@@ -138,4 +143,21 @@ class AcaraDonorFilterTest(TestCase):
class AcaraDonorAdminTest(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_acaradonor(self):
user = UserFactory()
acara_donor = AcaraDonorFactory(user=user)
endpoint = reverse('admin:acara_donor_acaradonor_changelist')
data = {'action': 'download_acara_donor', '_selected_action': [acara_donor.nomor]}
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