Fakultas Ilmu Komputer UI

Commit 04ff52c7 authored by Nabila Febri Viola's avatar Nabila Febri Viola
Browse files

[REFACTOR] Fix acara donor model post request test

parent 19f9a309
Pipeline #48844 passed with stages
in 1 minute and 38 seconds
......@@ -99,8 +99,8 @@ class AcaraDonorCreateViewTest(APITestCase):
def setUp(self):
self.user = UserFactory()
self.user.save()
self.client.credentials(HTTP_AUTHORIZATION='Bearer ' +
str(AccessToken.for_user(self.user)))
base_time = timezone.localtime(datetime.datetime(
2020, 6, 12, 9, 18, tzinfo=datetime.timezone.utc))
self.data = {"alamat_institusi": "Pacilkom",
"alamat_lokasi_donor": "Sekre Pacil",
"email_kantor": "pacil@cs.ui.ac.id",
......@@ -114,21 +114,23 @@ class AcaraDonorCreateViewTest(APITestCase):
"no_telp_kantor": "08165342342",
"no_telp_koor": "08167021743",
"perkiraan_jumlah_donor": 455,
"waktu_berakhir": timezone.now()
"waktu_berakhir": base_time
+ timezone.timedelta(hours=7),
"waktu_mulai": timezone.now()
"waktu_mulai": base_time
+ timezone.timedelta(hours=5)}
def test_create_acara_donor_with_post_request(self, mock_timezone):
self.client.credentials(HTTP_AUTHORIZATION='Bearer ' +
str(AccessToken.for_user(self.user)))
response = self.client.post('/acara-donor/pengajuan/',
self.data,
format='multipart')
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
def test_create_acara_donor_unauthorized(self):
def test_create_acara_donor_unauthorized(self, mock_timezone):
response = self.client.post('/acara-donor/pengajuan/',
self.data,
format='json')
format='multipart')
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
......
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