Fakultas Ilmu Komputer UI

Commit a453f6fd authored by Zamil Majdy's avatar Zamil Majdy
Browse files

[#140652771] [#21] [Red] Add list vacancy testcases

parent 91bf23a6
from datetime import datetime
import requests_mock
from rest_framework import status
from rest_framework.test import APITestCase
from django.contrib.auth.models import User
from rest_framework import status
from rest_framework.test import APITestCase, force_authenticate, APIRequestFactory
from core.models.accounts import Company
from core.models.vacancies import Vacancy
class ApplicationTests(APITestCase):
class ApplicationTests(APITestCase):
@requests_mock.Mocker()
def test_application_list(self, m):
m.post('https://api.cs.ui.ac.id/authentication/ldap/v2/', json={
......@@ -29,7 +31,6 @@ class ApplicationTests(APITestCase):
self.assertEqual(response.status_code, status.HTTP_200_OK)
@requests_mock.Mocker()
def test_application_create_and_delete(self, m):
m.post('https://api.cs.ui.ac.id/authentication/ldap/v2/', json={
......@@ -59,8 +60,8 @@ class ApplicationTests(APITestCase):
response = self.client.delete(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
class BookmarkApplicationTests(APITestCase):
class BookmarkApplicationTests(APITestCase):
@requests_mock.Mocker()
def test_application_list(self, m):
m.post('https://api.cs.ui.ac.id/authentication/ldap/v2/', json={
......@@ -82,7 +83,6 @@ class BookmarkApplicationTests(APITestCase):
self.assertEqual(response.status_code, status.HTTP_200_OK)
@requests_mock.Mocker()
def test_application_create_and_delete(self, m):
m.post('https://api.cs.ui.ac.id/authentication/ldap/v2/', json={
......@@ -111,3 +111,26 @@ class BookmarkApplicationTests(APITestCase):
url = '/api/students/' + str(student_id) + '/bookmarked-vacancies/' + str(new_vacancy.pk) + '/'
response = self.client.delete(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
class VacancyTest(APITestCase):
def test_verified_vacancy_list(self):
superuser = User.objects.create_superuser('dummy.company', 'dummy.company@company.com', 'lalala123')
self.client.force_authenticate(user=superuser)
url = '/api/vacancies/'
response = self.client.get(url, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_unverified_vacancy_list(self):
superuser = User.objects.create_superuser('dummy.company', 'dummy.company@company.com', 'lalala123')
self.client.force_authenticate(user=superuser)
url = '/api/vacancies/?verified=false'
response = self.client.get(url, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_fail_on_unverified_user_vacancy_list(self):
url = '/api/vacancies/'
response = self.client.post(url, format='json')
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
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