Fakultas Ilmu Komputer UI

Commit d907ba10 authored by Azhar Kurnia's avatar Azhar Kurnia
Browse files

Refactoring dan Memperbaiki Code Smell pada core/tests/test_vacancies.py,...

Refactoring dan Memperbaiki Code Smell pada core/tests/test_vacancies.py, assets/js/__test__/ProfilePage-test.jsx
parent 3b4ee3bf
...@@ -219,7 +219,7 @@ describe('ProfilePage', () => { ...@@ -219,7 +219,7 @@ describe('ProfilePage', () => {
const profile = ReactTestUtils.renderIntoDocument( const profile = ReactTestUtils.renderIntoDocument(
<ProfilePage route={{ own: true, data: studentSession }} user={{ data: studentSession }} params={{ id: 3 }} />); <ProfilePage route={{ own: true, data: studentSession }} user={{ data: studentSession }} params={{ id: 3 }} />);
const emailNode = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Input')[0]; ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Input')[0];
// const passwordNode = ReactDOM.findDOMNode(formLogin.refs.password); // const passwordNode = ReactDOM.findDOMNode(formLogin.refs.password);
profile.handleFile({ target: { name: 'photo', files: ['abc', 'def'] } }); profile.handleFile({ target: { name: 'photo', files: ['abc', 'def'] } });
expect(profile.state.form.photo).to.equal('abc'); expect(profile.state.form.photo).to.equal('abc');
......
...@@ -137,7 +137,7 @@ class ApplicationTests(APITestCase): ...@@ -137,7 +137,7 @@ class ApplicationTests(APITestCase):
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0), new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0),
description="lalala", close_time=datetime.today(), max_accepted_applicants=3, working_period="3 Bulan") description="lalala", close_time=datetime.today(), max_accepted_applicants=3, working_period="3 Bulan")
application = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="lorem ipsum") Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="lorem ipsum")
url = '/api/applications/' + str(new_vacancy.pk) + '/count/' url = '/api/applications/' + str(new_vacancy.pk) + '/count/'
...@@ -155,7 +155,7 @@ class ApplicationTests(APITestCase): ...@@ -155,7 +155,7 @@ class ApplicationTests(APITestCase):
new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None, new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None,
address=None) address=None)
new_student = Student.objects.create(user=new_user2, npm=1234123412) Student.objects.create(user=new_user2, npm=1234123412)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0), new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0),
description="lalala", close_time=datetime.today(), max_accepted_applicants=3, working_period="3 Bulan") description="lalala", close_time=datetime.today(), max_accepted_applicants=3, working_period="3 Bulan")
...@@ -388,13 +388,13 @@ class VacancyTest(APITestCase): ...@@ -388,13 +388,13 @@ class VacancyTest(APITestCase):
address=None) address=None)
open_time = datetime(2019, 10, 20) open_time = datetime(2019, 10, 20)
close_time = datetime(2019, 12, 20) close_time = datetime(2019, 12, 20)
vacancy1 = Vacancy.objects.create(company=new_company, verified=True, open_time=open_time, Vacancy.objects.create(company=new_company, verified=True, open_time=open_time,
description='', close_time=close_time, name='vacancy1', max_accepted_applicants=3, working_period="3 Bulan") description='', close_time=close_time, name='vacancy1', max_accepted_applicants=3, working_period="3 Bulan")
vacancy2 = Vacancy.objects.create(company=new_company2, verified=True, open_time=open_time, Vacancy.objects.create(company=new_company2, verified=True, open_time=open_time,
description='', close_time=close_time, name='vacancy2', max_accepted_applicants=3, working_period="3 Bulan") description='', close_time=close_time, name='vacancy2', max_accepted_applicants=3, working_period="3 Bulan")
url = '/api/vacancies/?company={}&company={}'.format(new_company.id, new_company2.id) url = '/api/vacancies/?company={}&company={}'.format(new_company.id, new_company2.id)
response = self.client.get(url, format='json') response = self.client.get(url, format='json')
vacancies = Vacancy.objects.filter(company__id__in=[new_company.id, new_company2.id]) Vacancy.objects.filter(company__id__in=[new_company.id, new_company2.id])
self.assertEqual(dict(response.data)['count'], Vacancy.objects.count()) self.assertEqual(dict(response.data)['count'], Vacancy.objects.count())
self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.status_code, status.HTTP_200_OK)
...@@ -445,12 +445,11 @@ class VacancyTest(APITestCase): ...@@ -445,12 +445,11 @@ class VacancyTest(APITestCase):
response = self.client.post(url, {'username': 'dummy.mahasiswa', 'password': 'lalala', 'login-type': 'sso-ui'}, response = self.client.post(url, {'username': 'dummy.mahasiswa', 'password': 'lalala', 'login-type': 'sso-ui'},
format='json') format='json')
student_id = response.data.get('student').get('id')
new_user = User.objects.create_user('dummy.company2', 'dummy.compan2y@company.com', 'lalala123') new_user = User.objects.create_user('dummy.company2', 'dummy.compan2y@company.com', 'lalala123')
new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None, new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None,
address=None) address=None)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0), Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0),
description="expired vacancy", close_time=datetime.fromtimestamp(1541319301.0), max_accepted_applicants=3, working_period="3 Bulan") description="expired vacancy", close_time=datetime.fromtimestamp(1541319301.0), max_accepted_applicants=3, working_period="3 Bulan")
url = '/api/vacancies/?opened_only=true' url = '/api/vacancies/?opened_only=true'
...@@ -520,7 +519,7 @@ class CompanyListsTests(APITestCase): ...@@ -520,7 +519,7 @@ class CompanyListsTests(APITestCase):
address=None) address=None)
new_user2 = User.objects.create_user('dummy.companyzxc', 'dummy.companyzxc@company.com', 'lalala123') new_user2 = User.objects.create_user('dummy.companyzxc', 'dummy.companyzxc@company.com', 'lalala123')
new_company2 = Company.objects.create(user=new_user2, description="lalalaasdsad", status=Company.VERIFIED, Company.objects.create(user=new_user2, description="lalalaasdsad", status=Company.VERIFIED,
logo=None, logo=None,
address=None) address=None)
...@@ -558,7 +557,7 @@ class CompanyListsTests(APITestCase): ...@@ -558,7 +557,7 @@ class CompanyListsTests(APITestCase):
address=None) address=None)
new_user2 = User.objects.create_user('dummy.companyzxc', 'dummy.companyzxc@company.com', 'lalala123') new_user2 = User.objects.create_user('dummy.companyzxc', 'dummy.companyzxc@company.com', 'lalala123')
new_company2 = Company.objects.create(user=new_user2, description="lalalaasdsad", status=Company.VERIFIED, Company.objects.create(user=new_user2, description="lalalaasdsad", status=Company.VERIFIED,
logo=None, logo=None,
address=None) address=None)
...@@ -578,7 +577,7 @@ class CompanyListsTests(APITestCase): ...@@ -578,7 +577,7 @@ class CompanyListsTests(APITestCase):
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0), new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0),
description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan") description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan")
new_app = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd") Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd")
self.client.force_authenticate(new_user) self.client.force_authenticate(new_user)
...@@ -596,10 +595,10 @@ class CompanyListsTests(APITestCase): ...@@ -596,10 +595,10 @@ class CompanyListsTests(APITestCase):
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0), new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0),
description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan") description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan")
new_app = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd") Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd")
new_user3 = User.objects.create_user('dummy.company4', 'dummy.company4@company.com', 'lalala123') new_user3 = User.objects.create_user('dummy.company4', 'dummy.company4@company.com', 'lalala123')
new_company3 = Company.objects.create(user=new_user3, description="lalala", status=Company.VERIFIED, logo=None, Company.objects.create(user=new_user3, description="lalala", status=Company.VERIFIED, logo=None,
address=None) address=None)
self.client.force_authenticate(new_user3) self.client.force_authenticate(new_user3)
...@@ -618,7 +617,7 @@ class CompanyListsTests(APITestCase): ...@@ -618,7 +617,7 @@ class CompanyListsTests(APITestCase):
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0), new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0),
description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan") description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan")
new_app = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd") Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd")
new_user3 = User.objects.create_user('dummy.company4', 'dummy.company4@company.com', 'lalala123') new_user3 = User.objects.create_user('dummy.company4', 'dummy.company4@company.com', 'lalala123')
new_company3 = Company.objects.create(user=new_user3, description="lalala", status=Company.VERIFIED, logo=None, new_company3 = Company.objects.create(user=new_user3, description="lalala", status=Company.VERIFIED, logo=None,
...@@ -640,7 +639,7 @@ class CompanyListsTests(APITestCase): ...@@ -640,7 +639,7 @@ class CompanyListsTests(APITestCase):
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0), new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0),
description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan") description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan")
new_app = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd") Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd")
self.client.force_authenticate(new_user) self.client.force_authenticate(new_user)
...@@ -658,7 +657,7 @@ class CompanyListsTests(APITestCase): ...@@ -658,7 +657,7 @@ class CompanyListsTests(APITestCase):
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0), new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0),
description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan") description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan")
new_app = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd") Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd")
self.client.force_authenticate(new_user) self.client.force_authenticate(new_user)
...@@ -677,7 +676,7 @@ class CompanyListsTests(APITestCase): ...@@ -677,7 +676,7 @@ class CompanyListsTests(APITestCase):
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0), new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0),
description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan") description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan")
new_app = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd") Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd")
self.client.force_authenticate(new_user) self.client.force_authenticate(new_user)
...@@ -696,7 +695,7 @@ class CompanyListsTests(APITestCase): ...@@ -696,7 +695,7 @@ class CompanyListsTests(APITestCase):
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0), new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0),
description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan") description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan")
new_app = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd") Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd")
self.client.force_authenticate(new_user) self.client.force_authenticate(new_user)
...@@ -719,7 +718,7 @@ class CompanyListsTests(APITestCase): ...@@ -719,7 +718,7 @@ class CompanyListsTests(APITestCase):
class SupervisorStudentApplicationTests(APITestCase): class SupervisorStudentApplicationTests(APITestCase):
def test_list_student_application(self): def test_list_student_application(self):
new_user = User.objects.create_user('dummy.supervisor', 'dummy.supervisor@asd.asd', 'lalala123') new_user = User.objects.create_user('dummy.supervisor', 'dummy.supervisor@asd.asd', 'lalala123')
new_supervisor = Supervisor.objects.create(user=new_user, nip=1212121212) Supervisor.objects.create(user=new_user, nip=1212121212)
self.client.force_authenticate(user=new_user) self.client.force_authenticate(user=new_user)
url = '/api/applications/' url = '/api/applications/'
...@@ -738,7 +737,7 @@ class SupervisorStudentApplicationTests(APITestCase): ...@@ -738,7 +737,7 @@ class SupervisorStudentApplicationTests(APITestCase):
class SupervisorApprovalTests(APITestCase): class SupervisorApprovalTests(APITestCase):
def test_supervisor_approve_vacancy(self): def test_supervisor_approve_vacancy(self):
new_user = User.objects.create_user('dummy.supervisor', 'dummy.supervisor@asd.asd', 'lalala123') new_user = User.objects.create_user('dummy.supervisor', 'dummy.supervisor@asd.asd', 'lalala123')
new_supervisor = Supervisor.objects.create(user=new_user, nip=1212121212) Supervisor.objects.create(user=new_user, nip=1212121212)
self.client.force_authenticate(user=new_user) self.client.force_authenticate(user=new_user)
new_user2 = User.objects.create_user('dummy.company2', 'dummy.compan2y@company.com', 'lalala123') new_user2 = User.objects.create_user('dummy.company2', 'dummy.compan2y@company.com', 'lalala123')
...@@ -1131,10 +1130,10 @@ class AcceptOneOfferTests(APITestCase): ...@@ -1131,10 +1130,10 @@ class AcceptOneOfferTests(APITestCase):
Application.objects.create(student=new_student, vacancy=new_vacancy2, cover_letter="asdasdasd") Application.objects.create(student=new_student, vacancy=new_vacancy2, cover_letter="asdasdasd")
with self.assertRaises(TypeError): with self.assertRaises(TypeError):
url = '/api/acceptoffer/' + None + '/vacancy/' + str(new_vacancy.pk) + '/' '/api/acceptoffer/' + None + '/vacancy/' + str(new_vacancy.pk) + '/'
with self.assertRaises(TypeError): with self.assertRaises(TypeError):
url = '/api/acceptoffer/' + str(new_student.pk) + '/vacancy/' + None + '/' '/api/acceptoffer/' + str(new_student.pk) + '/vacancy/' + None + '/'
def test_if_requester_is_not_authenticated(self): def test_if_requester_is_not_authenticated(self):
new_user3, new_vacancy, new_vacancy2, new_student = self.generateObject() new_user3, new_vacancy, new_vacancy2, new_student = self.generateObject()
...@@ -1145,6 +1144,6 @@ class AcceptOneOfferTests(APITestCase): ...@@ -1145,6 +1144,6 @@ class AcceptOneOfferTests(APITestCase):
url = '/api/acceptoffer/' + str(new_student.pk) + '/vacancy/' + str(new_vacancy.pk) + '/' url = '/api/acceptoffer/' + str(new_student.pk) + '/vacancy/' + str(new_vacancy.pk) + '/'
response = self.client.patch(url, format='json') response = self.client.patch(url, format='json')
body = json.loads(response.content)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) 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