Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Class Project
Kape
Commits
cedb80f2
Commit
cedb80f2
authored
Oct 06, 2019
by
NICHOLAS PRIAMBODO
Browse files
Merge branch 'master' into '1606879905-25'
# Conflicts: # core/tests/test_vacancies.py
parent
3eebdef1
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/serializers/vacancies.py
View file @
cedb80f2
...
...
@@ -35,9 +35,15 @@ class VacancySerializer(serializers.ModelSerializer):
fields
=
[
'company'
,
'verified'
,
'open_time'
,
'description'
,
'close_time'
,
'created'
,
'updated'
,
'name'
,
\
'status'
,
'bookmarked'
,
'id'
]
def
name_position_validator
(
names
):
for
name
in
names
.
split
(
" "
):
if
not
name
.
isalpha
():
raise
serializers
.
ValidationError
(
"Name must alphabets only"
)
return
name
class
PostVacancySerializer
(
serializers
.
ModelSerializer
):
company
=
serializers
.
PrimaryKeyRelatedField
(
queryset
=
Company
.
objects
.
all
())
name
=
serializers
.
CharField
(
validators
=
[
name_position_validator
],
max_length
=
100
,
allow_null
=
False
)
class
Meta
:
model
=
Vacancy
...
...
core/tests/test_vacancies.py
View file @
cedb80f2
...
...
@@ -523,6 +523,96 @@ class SupervisorApprovalTests(APITestCase):
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
self
.
assertEqual
(
new_vacancy
.
verified
,
False
)
class
ValidationPositionNameinCreateLowonganKP
(
APITestCase
):
def
setUp
(
self
):
user
=
User
.
objects
.
create_user
(
'dummy'
,
'dummy@dummy.com'
,
'dummy'
)
self
.
client
.
force_authenticate
(
user
=
user
)
self
.
company
=
Company
.
objects
.
create
(
user
=
user
,
description
=
"dummy"
,
status
=
Company
.
VERIFIED
,
logo
=
None
,
address
=
None
)
self
.
url
=
'/api/vacancies/'
self
.
payload
=
{
"company"
:
self
.
company
.
id
,
"open_time"
:
datetime
.
fromtimestamp
(
0
),
"close_time"
:
datetime
.
today
()
}
self
.
message
=
"Name must alphabets only"
def
test_name_contains_only_alphabets
(
self
):
self
.
payload
[
"name"
]
=
"Engineer"
response
=
self
.
client
.
post
(
self
.
url
,
self
.
payload
,
format
=
"json"
)
response_status_code
=
response
.
status_code
self
.
assertEqual
(
response_status_code
,
201
)
def
test_name_contains_only_alphabets_and_spaces
(
self
):
self
.
payload
[
"name"
]
=
"Software Engineer "
response
=
self
.
client
.
post
(
self
.
url
,
self
.
payload
,
format
=
"json"
)
response_status_code
=
response
.
status_code
self
.
assertEqual
(
response_status_code
,
201
)
def
test_name_contains_alphabets_and_numerics
(
self
):
self
.
payload
[
"name"
]
=
"Software18 Engineer"
response
=
self
.
client
.
post
(
self
.
url
,
self
.
payload
,
format
=
"json"
)
response_status_code
=
response
.
status_code
self
.
assertEqual
(
response_status_code
,
400
)
response_message
=
response
.
data
[
"name"
][
0
]
self
.
assertEqual
(
response_message
,
self
.
message
)
def
test_name_contains_only_numerics
(
self
):
self
.
payload
[
"name"
]
=
"123654789"
response
=
self
.
client
.
post
(
self
.
url
,
self
.
payload
,
format
=
"json"
)
response_status_code
=
response
.
status_code
self
.
assertEqual
(
response_status_code
,
400
)
response_message
=
response
.
data
[
"name"
][
0
]
self
.
assertEqual
(
response_message
,
self
.
message
)
def
test_name_contains_characters_besides_alphabets
(
self
):
self
.
payload
[
"name"
]
=
"!@#$%^&*()"
response
=
self
.
client
.
post
(
self
.
url
,
self
.
payload
,
format
=
"json"
)
response_status_code
=
response
.
status_code
self
.
assertEqual
(
response_status_code
,
400
)
response_message
=
response
.
data
[
"name"
][
0
]
self
.
assertEqual
(
response_message
,
self
.
message
)
class
AcceptOneOfferTests
(
APITestCase
):
def
generateObject
(
self
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment