Fakultas Ilmu Komputer UI

Commit 2a08fd0f authored by Zamil Majdy's avatar Zamil Majdy
Browse files

[#140652771] [#21] [Refactor] move unused testcases add miss coverage test

parent ee6ba1f9
# 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()
# 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)
......@@ -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
......
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