diff --git a/core/tests/test_studentViewSet.py b/core/tests/test_studentViewSet.py deleted file mode 100644 index efd3f41311b54636109a6e58bbb8dfd33eb90439..0000000000000000000000000000000000000000 --- a/core/tests/test_studentViewSet.py +++ /dev/null @@ -1,18 +0,0 @@ -# from unittest import TestCase -# -# from django.urls import reverse -# -# -# class TestStudentViewSet(TestCase): -# # def setUp(self): -# # #c = Client() -# # Student.objects.create(user = User.objects.create(username = "farhan"), npm = "1406572321") -# -# #def test_bookmark_vacancies(self): -# # url = reverse('bookmarked-vacancies') -# # data = {'company_id': 1} -# # response = self.client.post(url, data, format='json') -# # self.fail() -# # -# # def test_remove_vacancies(self): -# # self.fail() diff --git a/core/tests/test_userViewSet.py b/core/tests/test_userViewSet.py index 5a7822067e9c40c916127a2b93c66943ddd0ab91..ad2179c83312890d5c13569ef9c0f1fb6573ba44 100644 --- a/core/tests/test_userViewSet.py +++ b/core/tests/test_userViewSet.py @@ -1,6 +1,46 @@ -# from unittest import TestCase -# -# -# class TestUserViewSet(TestCase): -# def test_me(self): -# self.fail() +from django.contrib.auth.models import User +from rest_framework import status +from rest_framework.test import APITestCase + + +class TestUserViewSet(APITestCase): + def test_me_success(self): + superuser = User.objects.create_superuser('dummy.user', 'dummy.user@user.com', 'lalala123') + self.client.force_authenticate(user=superuser) + + url = '/api/users/me/' + response = self.client.get(url, format='json') + self.assertEqual(response.status_code, status.HTTP_200_OK) + + def test_users_fail(self): + url = '/api/users/' + response = self.client.get(url, format='json') + self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) + + response = self.client.put(url, format='json') + self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) + + response = self.client.patch(url, format='json') + self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) + + def test_user_students_success(self): + superuser = User.objects.create_superuser('dummy.user', 'dummy.user@user.com', 'lalala123') + self.client.force_authenticate(user=superuser) + + url = '/api/students/' + response = self.client.get(url, format='json') + self.assertEqual(response.status_code, status.HTTP_200_OK) + + def test_user_students_fail(self): + url = '/api/students/' + response = self.client.get(url, format='json') + self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) + + response = self.client.post(url, format='json') + self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) + + response = self.client.put(url, format='json') + self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) + + response = self.client.patch(url, format='json') + self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) diff --git a/core/tests/test_vacancies.py b/core/tests/test_vacancies.py index a4195f0265c037a1f901bb238773ad066e774a25..b8c7267f069d019eb27ea9ecf0ec2847c6404a61 100644 --- a/core/tests/test_vacancies.py +++ b/core/tests/test_vacancies.py @@ -3,7 +3,7 @@ from datetime import datetime import requests_mock from django.contrib.auth.models import User from rest_framework import status -from rest_framework.test import APITestCase, force_authenticate, APIRequestFactory +from rest_framework.test import APITestCase from core.models.accounts import Company from core.models.vacancies import Vacancy