Fakultas Ilmu Komputer UI

Commit b7d6d0fe authored by Yusuf Sholeh's avatar Yusuf Sholeh
Browse files

Fix failed tests

parent 2475179b
Pipeline #25169 passed with stages
in 5 minutes and 40 seconds
...@@ -607,8 +607,8 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase): ...@@ -607,8 +607,8 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase):
self.payload = { self.payload = {
"name": "dummy", "name": "dummy",
"company" : self.company.id, "company" : self.company.id,
"open_time" : datetime.fromtimestamp(0), "open_time" : datetime.today(),
"close_time" : datetime.today(), "close_time" : datetime.today() + timedelta(days=10),
"description" : "dummy", "description" : "dummy",
"working_period": "Summer 2019", "working_period": "Summer 2019",
"max_accepted_applicants": 10, "max_accepted_applicants": 10,
...@@ -704,7 +704,7 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase): ...@@ -704,7 +704,7 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase):
self.assertEqual(response_status_code, 400) self.assertEqual(response_status_code, 400)
def test_amount_contains_number_only(self): def test_amount_contains_number_only(self):
self.payload["amount"] = 231231221312 self.payload["amount"] = 231231
response = self.client.post( response = self.client.post(
self.url, self.url,
...@@ -716,7 +716,7 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase): ...@@ -716,7 +716,7 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase):
self.assertEqual(response_status_code, 200) self.assertEqual(response_status_code, 200)
def test_max_accepted_applicants_contains_only_number(self): def test_max_accepted_applicants_contains_only_number(self):
self.payload[""] = "11" self.payload["max_accepted_applicants"] = "11"
response = self.client.post( response = self.client.post(
self.url, self.url,
...@@ -728,7 +728,7 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase): ...@@ -728,7 +728,7 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase):
self.assertEqual(response_status_code, 200) self.assertEqual(response_status_code, 200)
def test_max_accepted_applicants_contains_only_alphabet(self): def test_max_accepted_applicants_contains_only_alphabet(self):
self.payload[""] = "abcd" self.payload["max_accepted_applicants"] = "abcd"
response = self.client.post( response = self.client.post(
self.url, self.url,
...@@ -740,7 +740,7 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase): ...@@ -740,7 +740,7 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase):
self.assertEqual(response_status_code, 400) self.assertEqual(response_status_code, 400)
def test_max_accepted_applicants_contains_number_and_alphabet(self): def test_max_accepted_applicants_contains_number_and_alphabet(self):
self.payload[""] = "a1r1" self.payload["max_accepted_applicants"] = "a1r1"
response = self.client.post( response = self.client.post(
self.url, self.url,
......
...@@ -181,6 +181,9 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet): ...@@ -181,6 +181,9 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet):
except ValidationError as e: except ValidationError as e:
print("[LOG] error: " + str(e)) print("[LOG] error: " + str(e))
return Response({"error": str(e.detail[0])}, status=status.HTTP_400_BAD_REQUEST) return Response({"error": str(e.detail[0])}, status=status.HTTP_400_BAD_REQUEST)
except ValueError as e:
print("[LOG] error: " + str(e))
return Response({"error": str(e)}, status=status.HTTP_400_BAD_REQUEST)
return Response(status=status.HTTP_200_OK) return Response(status=status.HTTP_200_OK)
def partial_update(self, request, pk): def partial_update(self, request, pk):
......
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