Fakultas Ilmu Komputer UI

Commit 01e5c1ed authored by Joshua Casey's avatar Joshua Casey
Browse files

[#44] [RED] Added tests for vacancy verification by supervisor

parent c81da584
......@@ -5,7 +5,7 @@ from django.contrib.auth.models import User
from rest_framework import status
from rest_framework.test import APITestCase
from core.models.accounts import Company
from core.models.accounts import Company, Supervisor
from core.models.vacancies import Vacancy
......@@ -186,3 +186,39 @@ class CompanyListsTests(APITestCase):
url = '/api/companies/' + str(new_company.pk) + '/applications'
response = self.client.post(url, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
class SupervisorApprovalTests(APITestCase):
def test_supervisor_approve_vacancy(self):
new_user = User.objects.create_user('dummy.supervisor', 'dummy.supervisor@asd.asd', 'lalala123')
new_supervisor = Supervisor.objects.create(user=new_user, nip=1212121212)
self.client.force_authenticate(user=new_user)
new_user2 = User.objects.create_user('dummy.company2', 'dummy.compan2y@company.com', 'lalala123')
new_company2 = Company.objects.create(user=new_user2, description="lalala", status=Company.VERIFIED, logo=None,
address=None)
new_vacancy2 = Vacancy.objects.create(company=new_company2, verified=False, open_time=datetime.fromtimestamp(0),
description="lalala", close_time=datetime.today())
url = '/api/vacancies/' + str(new_vacancy2.pk) + '/verify/'
response = self.client.patch(url, {'verified' : True}, format='json')
print response.data
self.assertEqual(response.status_code, status.HTTP_200_OK)
retrieve_vacancy = Vacancy.objects.get(pk=new_vacancy2.pk)
self.assertEqual(retrieve_vacancy.verified, True)
def test_unauthorized_approve_vacancy(self):
new_user = User.objects.create_user('dummy.companyz', 'dummy.companyz@company.com', 'lalala123')
new_company = Company.objects.create(user=new_user, description="lalalaz", status=Company.VERIFIED, logo=None,
address=None)
self.client.force_authenticate(user=new_user)
new_vacancy = Vacancy.objects.create(company=new_company, verified=False, open_time=datetime.fromtimestamp(0),
description="lalala", close_time=datetime.today())
url = '/api/vacancies/' + str(new_vacancy.pk) + '/verify/'
response = self.client.patch(url, format='json')
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
self.assertEqual(new_vacancy.verified, False)
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