Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Fasilkom UI Open Source Software
Kape
Commits
01e5c1ed
Commit
01e5c1ed
authored
May 17, 2017
by
Joshua Casey
Browse files
[#44] [RED] Added tests for vacancy verification by supervisor
parent
c81da584
Changes
1
Hide whitespace changes
Inline
Side-by-side
core/tests/test_vacancies.py
View file @
01e5c1ed
...
@@ -5,7 +5,7 @@ from django.contrib.auth.models import User
...
@@ -5,7 +5,7 @@ from django.contrib.auth.models import User
from
rest_framework
import
status
from
rest_framework
import
status
from
rest_framework.test
import
APITestCase
from
rest_framework.test
import
APITestCase
from
core.models.accounts
import
Company
from
core.models.accounts
import
Company
,
Supervisor
from
core.models.vacancies
import
Vacancy
from
core.models.vacancies
import
Vacancy
...
@@ -186,3 +186,39 @@ class CompanyListsTests(APITestCase):
...
@@ -186,3 +186,39 @@ class CompanyListsTests(APITestCase):
url
=
'/api/companies/'
+
str
(
new_company
.
pk
)
+
'/applications'
url
=
'/api/companies/'
+
str
(
new_company
.
pk
)
+
'/applications'
response
=
self
.
client
.
post
(
url
,
format
=
'json'
)
response
=
self
.
client
.
post
(
url
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
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
)
self
.
client
.
force_authenticate
(
user
=
new_user
)
new_user2
=
User
.
objects
.
create_user
(
'dummy.company2'
,
'dummy.compan2y@company.com'
,
'lalala123'
)
new_company2
=
Company
.
objects
.
create
(
user
=
new_user2
,
description
=
"lalala"
,
status
=
Company
.
VERIFIED
,
logo
=
None
,
address
=
None
)
new_vacancy2
=
Vacancy
.
objects
.
create
(
company
=
new_company2
,
verified
=
False
,
open_time
=
datetime
.
fromtimestamp
(
0
),
description
=
"lalala"
,
close_time
=
datetime
.
today
())
url
=
'/api/vacancies/'
+
str
(
new_vacancy2
.
pk
)
+
'/verify/'
response
=
self
.
client
.
patch
(
url
,
{
'verified'
:
True
},
format
=
'json'
)
print
response
.
data
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
retrieve_vacancy
=
Vacancy
.
objects
.
get
(
pk
=
new_vacancy2
.
pk
)
self
.
assertEqual
(
retrieve_vacancy
.
verified
,
True
)
def
test_unauthorized_approve_vacancy
(
self
):
new_user
=
User
.
objects
.
create_user
(
'dummy.companyz'
,
'dummy.companyz@company.com'
,
'lalala123'
)
new_company
=
Company
.
objects
.
create
(
user
=
new_user
,
description
=
"lalalaz"
,
status
=
Company
.
VERIFIED
,
logo
=
None
,
address
=
None
)
self
.
client
.
force_authenticate
(
user
=
new_user
)
new_vacancy
=
Vacancy
.
objects
.
create
(
company
=
new_company
,
verified
=
False
,
open_time
=
datetime
.
fromtimestamp
(
0
),
description
=
"lalala"
,
close_time
=
datetime
.
today
())
url
=
'/api/vacancies/'
+
str
(
new_vacancy
.
pk
)
+
'/verify/'
response
=
self
.
client
.
patch
(
url
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
self
.
assertEqual
(
new_vacancy
.
verified
,
False
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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