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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Helios Server
Commits
f1b46067
Commit
f1b46067
authored
13 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
fixed tests for python 2.7, will need to check python 2.6
parent
248698b6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
helios/tests.py
+34
-10
34 additions, 10 deletions
helios/tests.py
settings.py
+3
-0
3 additions, 0 deletions
settings.py
with
37 additions
and
10 deletions
helios/tests.py
+
34
−
10
View file @
f1b46067
...
...
@@ -2,7 +2,7 @@
Unit Tests for Helios
"""
import
unittest
,
datetime
,
re
import
unittest
,
datetime
,
re
,
urllib
import
django_webtest
import
models
...
...
@@ -346,19 +346,40 @@ class WebTest(django_webtest.WebTest):
def
assertRedirects
(
self
,
response
,
url
):
"""
reimplement this in case it
'
s a WebOp response
and it seems to be screwing up in a few places too
thus the localhost exception
"""
if
hasattr
(
response
,
'
status_code
'
):
return
super
(
django_webtest
.
WebTest
,
self
).
assertRedirects
(
response
,
url
)
if
hasattr
(
response
,
'
location
'
):
assert
url
in
response
.
location
else
:
assert
url
in
response
.
_headers
[
'
location
'
][
1
]
self
.
assertEqual
(
response
.
status_code
,
302
)
#return super(django_webtest.WebTest, self).assertRedirects(response, url)
#if hasattr(response, 'status_code') and hasattr(response, 'location'):
assert
response
.
status_int
==
302
assert
url
in
response
.
location
,
"
redirected to %s instead of %s
"
%
(
response
.
location
,
url
)
#if hasattr(response, 'status_code'):
# assert response.status_code == 302
#else:
# assert response.status_int == 302
#assert url in response.location, "redirected to %s instead of %s" % (response.location, url)
def
assertContains
(
self
,
response
,
text
):
if
hasattr
(
response
,
'
status_code
'
):
return
super
(
django_webtest
.
WebTest
,
self
).
assertContains
(
response
,
text
)
assert
response
.
status_code
==
200
# return super(django_webtest.WebTest, self).assertContains(response, text)
else
:
assert
response
.
status_int
==
200
if
hasattr
(
response
,
"
testbody
"
):
assert
text
in
response
.
testbody
,
"
missing text %s
"
%
text
else
:
if
hasattr
(
response
,
"
body
"
):
assert
text
in
response
.
body
,
"
missing text %s
"
%
text
else
:
assert
text
in
response
.
content
,
"
missing text %s
"
%
text
##
...
...
@@ -567,7 +588,10 @@ class ElectionBlackboxTests(WebTest):
# vote by preparing a ballot via the server-side encryption
response
=
self
.
app
.
post
(
"
/helios/elections/%s/encrypt-ballot
"
%
election_id
,
{
'
answers_json
'
:
utils
.
to_json
([[
1
]])})
try
:
self
.
assertContains
(
response
,
"
answers
"
)
except
:
import
pdb
;
pdb
.
set_trace
()
# parse it as an encrypted vote with randomness, and make sure randomness is there
the_ballot
=
utils
.
from_json
(
response
.
testbody
)
...
...
@@ -692,7 +716,7 @@ class ElectionBlackboxTests(WebTest):
response
=
self
.
app
.
get
(
"
/helios/elections/%s/view
"
%
election_id
)
# ensure it redirects
self
.
assertRedirects
(
response
,
"
/helios/elections/%s/password_voter_login
"
%
election_id
)
self
.
assertRedirects
(
response
,
"
/helios/elections/%s/password_voter_login
?%s
"
%
(
election_id
,
urllib
.
urlencode
({
"
return_url
"
:
"
/helios/elections/%s/view
"
%
election_id
}))
)
login_form
=
response
.
follow
().
form
...
...
This diff is collapsed.
Click to expand it.
settings.py
+
3
−
0
View file @
f1b46067
...
...
@@ -186,3 +186,6 @@ import djcelery
djcelery
.
setup_loader
()
BROKER_BACKEND
=
"
djkombu.transport.DatabaseTransport
"
CELERY_RESULT_DBURI
=
DATABASES
[
'
default
'
]
# for testing
CELERY_ALWAYS_EAGER
=
True
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