Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
9509b932
Unverified
Commit
9509b932
authored
Apr 14, 2017
by
Thom Wiggers
📐
Browse files
Add test for board wiki permission
parent
0310f717
Changes
1
Show whitespace changes
Inline
Side-by-side
website/thaliawebsite/tests.py
View file @
9509b932
from
django.contrib.auth
import
get_user_model
from
django.contrib.auth.models
import
Permission
from
django.test
import
TestCase
,
override_settings
class
WikiLoginTestCase
(
TestCase
):
"""Tests event registrations"""
def
setUp
(
self
):
self
.
user
=
get_user_model
().
objects
.
create_user
(
@
classmethod
def
setUpTestData
(
cls
):
cls
.
user
=
get_user_model
().
objects
.
create_user
(
username
=
'testuser'
,
first_name
=
'first'
,
last_name
=
'last_name'
,
...
...
@@ -41,6 +43,22 @@ class WikiLoginTestCase(TestCase):
'name'
:
'first last_name'
,
'status'
:
'ok'
})
@
override_settings
(
WIKI_API_KEY
=
'key'
)
def
test_board_permission
(
self
):
self
.
user
.
user_permissions
.
add
(
Permission
.
objects
.
get
(
codename
=
'board_wiki'
))
response
=
self
.
client
.
post
(
'/api/wikilogin'
,
{
'apikey'
:
'key'
,
'user'
:
'testuser'
,
'password'
:
'top secret'
})
self
.
assertEqual
(
response
.
json
(),
{
'admin'
:
False
,
'committees'
:
[
'bestuur'
],
'msg'
:
'Logged in'
,
'mail'
:
'foo@bar.com'
,
'name'
:
'first last_name'
,
'status'
:
'ok'
})
self
.
assertEqual
(
response
.
status_code
,
200
)
@
override_settings
(
WIKI_API_KEY
=
'key'
)
def
test_wrongargs
(
self
):
response
=
self
.
client
.
post
(
'/api/wikilogin'
,
...
...
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