Unverified Commit 9509b932 authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Add test for board wiki permission

parent 0310f717
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',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment