Fakultas Ilmu Komputer UI

Commit c264ce23 authored by Kianutama Radianur's avatar Kianutama Radianur
Browse files

Add test to count the sum of person who already register to a vacancy

parent a5b4f0a5
......@@ -82,6 +82,49 @@ class ApplicationTests(APITestCase):
response = self.client.delete(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_count_application_a_person_is_already_register(self):
new_user = User.objects.create_user('dummy.company', 'dummy.company@company.com', 'lalala123')
new_user2 = User.objects.create_user('dummy.student', 'dummy.student@student.com', 'lalala123')
self.client.force_authenticate(new_user)
self.client.force_authenticate(new_user2)
new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None,
address=None)
new_student = Student.objects.create(user=new_user2, npm=1234123412)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0),
description="lalala", close_time=datetime.today())
application = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="lorem ipsum")
url = '/api/applications/' + str(new_vacancy.pk) + '/count/'
response = self.client.get(url, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()['count'], 1)
def test_count_application_nobody_register(self):
new_user = User.objects.create_user('dummy.company', 'dummy.company@company.com', 'lalala123')
new_user2 = User.objects.create_user('dummy.student', 'dummy.student@student.com', 'lalala123')
self.client.force_authenticate(new_user)
self.client.force_authenticate(new_user2)
new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None,
address=None)
new_student = Student.objects.create(user=new_user2, npm=1234123412)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0),
description="lalala", close_time=datetime.today())
url = '/api/applications/' + str(new_vacancy.pk) + '/count/'
response = self.client.get(url, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()['count'], 0)
class BookmarkApplicationTests(APITestCase):
@requests_mock.Mocker()
......
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