Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Helios Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Helios Server
Commits
69ec942a
Unverified
Commit
69ec942a
authored
6 years ago
by
Marco Ciotola
Browse files
Options
Downloads
Patches
Plain Diff
[tests] Extend setup_login capabilities
parent
1df36cdf
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
helios/tests.py
+12
-12
12 additions, 12 deletions
helios/tests.py
with
12 additions
and
12 deletions
helios/tests.py
+
12
−
12
View file @
69ec942a
...
@@ -393,10 +393,17 @@ class ElectionBlackboxTests(WebTest):
...
@@ -393,10 +393,17 @@ class ElectionBlackboxTests(WebTest):
self
.
election
=
models
.
Election
.
objects
.
all
()[
0
]
self
.
election
=
models
.
Election
.
objects
.
all
()[
0
]
self
.
user
=
auth_models
.
User
.
objects
.
get
(
user_id
=
'
ben@adida.net
'
,
user_type
=
'
google
'
)
self
.
user
=
auth_models
.
User
.
objects
.
get
(
user_id
=
'
ben@adida.net
'
,
user_type
=
'
google
'
)
def
setup_login
(
self
):
def
setup_login
(
self
,
from_scratch
=
False
,
**
kwargs
):
if
from_scratch
:
# a bogus call to set up the session
self
.
client
.
get
(
"
/
"
)
# set up the session
# set up the session
session
=
self
.
client
.
session
session
=
self
.
client
.
session
session
[
'
user
'
]
=
{
'
type
'
:
self
.
user
.
user_type
,
'
user_id
'
:
self
.
user
.
user_id
}
if
kwargs
:
user
=
auth_models
.
User
.
objects
.
get
(
**
kwargs
)
else
:
user
=
self
.
user
session
[
'
user
'
]
=
{
'
type
'
:
user
.
user_type
,
'
user_id
'
:
user
.
user_id
}
session
.
save
()
session
.
save
()
# set up the app, too
# set up the app, too
...
@@ -468,10 +475,7 @@ class ElectionBlackboxTests(WebTest):
...
@@ -468,10 +475,7 @@ class ElectionBlackboxTests(WebTest):
self
.
assertRedirects
(
response
,
"
/auth/?return_url=/helios/elections/new
"
)
self
.
assertRedirects
(
response
,
"
/auth/?return_url=/helios/elections/new
"
)
def
test_election_edit
(
self
):
def
test_election_edit
(
self
):
# a bogus call to set up the session
self
.
setup_login
(
from_scratch
=
True
)
self
.
client
.
get
(
"
/
"
)
self
.
setup_login
()
response
=
self
.
client
.
get
(
"
/helios/elections/%s/edit
"
%
self
.
election
.
uuid
)
response
=
self
.
client
.
get
(
"
/helios/elections/%s/edit
"
%
self
.
election
.
uuid
)
response
=
self
.
client
.
post
(
"
/helios/elections/%s/edit
"
%
self
.
election
.
uuid
,
{
response
=
self
.
client
.
post
(
"
/helios/elections/%s/edit
"
%
self
.
election
.
uuid
,
{
"
short_name
"
:
self
.
election
.
short_name
+
"
-2
"
,
"
short_name
"
:
self
.
election
.
short_name
+
"
-2
"
,
...
@@ -490,11 +494,8 @@ class ElectionBlackboxTests(WebTest):
...
@@ -490,11 +494,8 @@ class ElectionBlackboxTests(WebTest):
def
_setup_complete_election
(
self
,
election_params
=
None
):
def
_setup_complete_election
(
self
,
election_params
=
None
):
"
do the setup part of a whole election
"
"
do the setup part of a whole election
"
# a bogus call to set up the session
self
.
client
.
get
(
"
/
"
)
# REPLACE with params?
# REPLACE with params?
self
.
setup_login
()
self
.
setup_login
(
from_scratch
=
True
)
# create the election
# create the election
full_election_params
=
{
full_election_params
=
{
...
@@ -755,8 +756,7 @@ class ElectionBlackboxTests(WebTest):
...
@@ -755,8 +756,7 @@ class ElectionBlackboxTests(WebTest):
def
test_election_voters_eligibility
(
self
):
def
test_election_voters_eligibility
(
self
):
# create the election
# create the election
self
.
client
.
get
(
"
/
"
)
self
.
setup_login
(
from_scratch
=
True
)
self
.
setup_login
()
response
=
self
.
client
.
post
(
"
/helios/elections/new
"
,
{
response
=
self
.
client
.
post
(
"
/helios/elections/new
"
,
{
"
short_name
"
:
"
test-eligibility
"
,
"
short_name
"
:
"
test-eligibility
"
,
"
name
"
:
"
Test Eligibility
"
,
"
name
"
:
"
Test Eligibility
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment