Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Sith
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
59
Issues
59
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AE
Sith
Commits
f2aadae8
Commit
f2aadae8
authored
Feb 01, 2017
by
Sli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix errors on election tests
parent
b5363c29
Pipeline
#903
passed with stage
in 3 minutes and 45 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
12 deletions
+23
-12
election/tests.py
election/tests.py
+23
-12
No files found.
election/tests.py
View file @
f2aadae8
...
...
@@ -6,23 +6,23 @@ from django.conf import settings
from
datetime
import
date
,
datetime
from
core.models
import
User
,
Group
from
election.models
import
Election
,
Role
,
ElectionList
,
Candidature
,
Vote
from
election.models
import
Election
class
MainElection
():
election
=
Election
.
objects
.
all
().
first
()
public_group
=
Group
.
objects
.
get
(
id
=
settings
.
SITH_GROUP_PUBLIC_ID
)
subscriber_group
=
Group
.
objects
.
get
(
name
=
settings
.
SITH_MAIN_MEMBERS_GROUP
)
ae_board_group
=
Group
.
objects
.
get
(
name
=
settings
.
SITH_MAIN_BOARD_GROUP
)
sli
=
User
.
objects
.
get
(
username
=
'sli'
)
subscriber
=
User
.
objects
.
get
(
username
=
'subscriber'
)
public
=
User
.
objects
.
get
(
username
=
'public'
)
class
ElectionDetailTest
(
MainElection
,
TestCase
):
class
MainElection
(
TestCase
):
def
setUp
(
self
):
call_command
(
"populate"
)
self
.
election
=
Election
.
objects
.
all
().
first
()
self
.
public_group
=
Group
.
objects
.
get
(
id
=
settings
.
SITH_GROUP_PUBLIC_ID
)
self
.
subscriber_group
=
Group
.
objects
.
get
(
name
=
settings
.
SITH_MAIN_MEMBERS_GROUP
)
self
.
ae_board_group
=
Group
.
objects
.
get
(
name
=
settings
.
SITH_MAIN_BOARD_GROUP
)
self
.
sli
=
User
.
objects
.
get
(
username
=
'sli'
)
self
.
subscriber
=
User
.
objects
.
get
(
username
=
'subscriber'
)
self
.
public
=
User
.
objects
.
get
(
username
=
'public'
)
class
ElectionDetailTest
(
MainElection
):
def
test_permission_denied
(
self
):
self
.
election
.
view_groups
.
remove
(
self
.
public_group
)
self
.
election
.
view_groups
.
add
(
self
.
subscriber_group
)
...
...
@@ -47,3 +47,14 @@ class ElectionDetailTest(MainElection, TestCase):
self
.
assertFalse
(
response_get
.
status_code
==
403
)
self
.
assertFalse
(
response_post
.
status_code
==
403
)
self
.
assertTrue
(
'La roue tourne'
in
str
(
response_get
.
content
))
class
ElectionUpdateView
(
MainElection
):
def
test_permission_denied
(
self
):
self
.
client
.
login
(
username
=
self
.
subscriber
.
username
,
password
=
'plop'
)
response_get
=
self
.
client
.
get
(
reverse
(
'election:update'
,
args
=
str
(
self
.
election
.
id
)))
response_post
=
self
.
client
.
post
(
reverse
(
'election:update'
,
args
=
str
(
self
.
election
.
id
)))
self
.
assertTrue
(
response_get
.
status_code
==
403
)
self
.
assertTrue
(
response_post
.
status_code
==
403
)
Write
Preview
Markdown
is supported
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