Fakultas Ilmu Komputer UI

Commit 08557a22 authored by Azhar Kurnia's avatar Azhar Kurnia
Browse files

Merge branch '1606918471-104' into 'master'

Refactoring dan Memperbaiki Code Smell pada core/tests/test_vacancies.py, assets/js/__test__/ProfilePage-test.jsx

See merge request !120
parents 3b4ee3bf d907ba10
Pipeline #24524 passed with stages
in 23 minutes and 32 seconds
......@@ -219,7 +219,7 @@ describe('ProfilePage', () => {
const profile = ReactTestUtils.renderIntoDocument(
<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);
profile.handleFile({ target: { name: 'photo', files: ['abc', 'def'] } });
expect(profile.state.form.photo).to.equal('abc');
......
......@@ -137,7 +137,7 @@ class ApplicationTests(APITestCase):
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")
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/'
......@@ -155,7 +155,7 @@ class ApplicationTests(APITestCase):
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)
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(), max_accepted_applicants=3, working_period="3 Bulan")
......@@ -388,13 +388,13 @@ class VacancyTest(APITestCase):
address=None)
open_time = datetime(2019, 10, 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")
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")
url = '/api/vacancies/?company={}&company={}'.format(new_company.id, new_company2.id)
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(response.status_code, status.HTTP_200_OK)
......@@ -445,12 +445,11 @@ class VacancyTest(APITestCase):
response = self.client.post(url, {'username': 'dummy.mahasiswa', 'password': 'lalala', 'login-type': 'sso-ui'},
format='json')
student_id = response.data.get('student').get('id')
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,
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")
url = '/api/vacancies/?opened_only=true'
......@@ -520,7 +519,7 @@ class CompanyListsTests(APITestCase):
address=None)
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,
address=None)
......@@ -558,7 +557,7 @@ class CompanyListsTests(APITestCase):
address=None)
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,
address=None)
......@@ -578,7 +577,7 @@ class CompanyListsTests(APITestCase):
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")
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)
......@@ -596,10 +595,10 @@ class CompanyListsTests(APITestCase):
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")
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_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)
self.client.force_authenticate(new_user3)
......@@ -618,7 +617,7 @@ class CompanyListsTests(APITestCase):
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")
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_company3 = Company.objects.create(user=new_user3, description="lalala", status=Company.VERIFIED, logo=None,
......@@ -640,7 +639,7 @@ class CompanyListsTests(APITestCase):
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")
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)
......@@ -658,7 +657,7 @@ class CompanyListsTests(APITestCase):
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")
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)
......@@ -677,7 +676,7 @@ class CompanyListsTests(APITestCase):
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")
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)
......@@ -696,7 +695,7 @@ class CompanyListsTests(APITestCase):
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")
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)
......@@ -719,7 +718,7 @@ class CompanyListsTests(APITestCase):
class SupervisorStudentApplicationTests(APITestCase):
def test_list_student_application(self):
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)
url = '/api/applications/'
......@@ -738,7 +737,7 @@ class SupervisorStudentApplicationTests(APITestCase):
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)
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')
......@@ -1131,10 +1130,10 @@ class AcceptOneOfferTests(APITestCase):
Application.objects.create(student=new_student, vacancy=new_vacancy2, cover_letter="asdasdasd")
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):
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):
new_user3, new_vacancy, new_vacancy2, new_student = self.generateObject()
......@@ -1145,6 +1144,6 @@ class AcceptOneOfferTests(APITestCase):
url = '/api/acceptoffer/' + str(new_student.pk) + '/vacancy/' + str(new_vacancy.pk) + '/'
response = self.client.patch(url, format='json')
body = json.loads(response.content)
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