Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ckanext-odsh
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open-Data
ckanext-odsh
Commits
57fcf31b
Commit
57fcf31b
authored
6 years ago
by
anonymous
Browse files
Options
Downloads
Patches
Plain Diff
ODPSH-196: add test for user login and api key
parent
4fbaca2b
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ckanext/odsh/tests/test_helpers.py
+4
-0
4 additions, 0 deletions
ckanext/odsh/tests/test_helpers.py
ckanext/odsh/tests/test_search.py
+1
-0
1 addition, 0 deletions
ckanext/odsh/tests/test_search.py
ckanext/odsh/tests/test_user.py
+71
-0
71 additions, 0 deletions
ckanext/odsh/tests/test_user.py
with
76 additions
and
0 deletions
ckanext/odsh/tests/test_helpers.py
0 → 100644
+
4
−
0
View file @
57fcf31b
import
ckan.tests.helpers
as
helpers
def
odsh_test
():
return
helpers
.
change_config
(
'
ckanext.odsh.spatial.mapping
'
,
'
file:///usr/lib/ckan/default/src/ckanext-odsh/ckanext/odsh/tests/spatial_mapping.csv
'
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ckanext/odsh/tests/test_search.py
+
1
−
0
View file @
57fcf31b
...
...
@@ -21,6 +21,7 @@ class TestSearch(helpers.FunctionalTestBase):
def
teardown
(
self
):
model
.
repo
.
rebuild_db
()
@odsh_test
()
def
test_dataset_is_in_search_result
(
self
):
# arrange
...
...
This diff is collapsed.
Click to expand it.
ckanext/odsh/tests/test_user.py
0 → 100644
+
71
−
0
View file @
57fcf31b
# encoding: utf-8
import
ckan.tests.factories
as
factories
import
ckan.tests.helpers
as
helpers
from
ckan
import
model
from
test_helpers
import
odsh_test
from
routes
import
url_for
from
nose.tools
import
assert_true
,
assert_false
,
assert_equal
,
assert_in
class
TestUser
(
helpers
.
FunctionalTestBase
):
_load_plugins
=
[
'
odsh
'
,
'
spatial_metadata
'
,
'
spatial_query
'
]
def
teardown
(
self
):
model
.
repo
.
rebuild_db
()
@odsh_test
()
def
test_user_login
(
self
):
# arrange
user
=
factories
.
User
()
# act
response
=
self
.
_login_user
(
user
)
# arrange
# we land on the default search page
response
.
mustcontain
(
'
Logout
'
)
response
.
mustcontain
(
'
Search dataset
'
)
@odsh_test
()
def
test_user_logout
(
self
):
app
=
self
.
_get_test_app
()
logout_url
=
url_for
(
controller
=
'
user
'
,
action
=
'
logout
'
)
logout_response
=
app
.
get
(
logout_url
,
status
=
302
)
final_response
=
helpers
.
webtest_maybe_follow
(
logout_response
)
assert_true
(
'
You are now logged out.
'
in
final_response
)
@odsh_test
()
def
test_user_can_see_api_key
(
self
):
# arrange
user
=
factories
.
User
()
self
.
_login_user
(
user
)
# act
response
=
self
.
_open_url
(
'
/user/
'
+
user
[
'
name
'
])
# arrange
# we land on the default search page
response
.
mustcontain
(
'
API Key
'
)
def
_open_url
(
self
,
url
):
app
=
self
.
_get_test_app
()
return
app
.
get
(
url
)
def
_submit_form
(
self
,
form
):
submit_response
=
form
.
submit
()
# let's go to the last redirect in the chain
return
helpers
.
webtest_maybe_follow
(
submit_response
)
def
_login_user
(
self
,
user
):
response
=
self
.
_open_url
(
'
/user/login
'
)
login_form
=
response
.
forms
[
0
]
login_form
[
'
login
'
]
=
user
[
'
name
'
]
login_form
[
'
password
'
]
=
'
pass
'
return
self
.
_submit_form
(
login_form
)
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