2013-04-03 17:55:30 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from django.test.client import Client
|
2013-11-29 16:47:31 +01:00
|
|
|
from mock import patch
|
2013-04-03 17:55:30 +02:00
|
|
|
|
|
|
|
from openslides import get_version
|
2013-10-30 17:48:09 +01:00
|
|
|
from openslides.agenda.models import Item
|
2013-11-14 19:29:08 +01:00
|
|
|
from openslides.config.api import config
|
2013-04-03 17:55:30 +02:00
|
|
|
from openslides.participant.models import User
|
2013-09-25 10:01:01 +02:00
|
|
|
from openslides.utils.test import TestCase
|
2013-04-03 17:55:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
class VersionViewTest(TestCase):
|
2013-10-30 17:48:09 +01:00
|
|
|
def setUp(self):
|
2013-09-25 10:01:01 +02:00
|
|
|
User.objects.create_user('CoreMaximilian', 'xxx@xx.xx', 'default')
|
2013-10-30 17:48:09 +01:00
|
|
|
self.client = Client()
|
|
|
|
self.client.login(username='CoreMaximilian', password='default')
|
|
|
|
|
|
|
|
def test_get(self):
|
|
|
|
response = self.client.get('/version/')
|
2013-04-03 17:55:30 +02:00
|
|
|
self.assertContains(response, get_version(), status_code=200)
|
2013-10-30 17:48:09 +01:00
|
|
|
|
|
|
|
@patch('openslides.core.views.settings')
|
|
|
|
def test_with_missing_plugin(self, mock_settings):
|
|
|
|
"""
|
2013-11-29 16:47:31 +01:00
|
|
|
Tests that a not existing app does not appear on the version view.
|
2013-10-30 17:48:09 +01:00
|
|
|
"""
|
|
|
|
mock_settings.INSTALLED_PLUGINS = ('unexisting_app_nvhbkdfgmnsd',)
|
2013-11-29 16:47:31 +01:00
|
|
|
self.assertRaises(ImportError, self.client.get, '/version/')
|
2013-10-30 17:48:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
class SearchViewTest(TestCase):
|
|
|
|
def test_simple_search(self):
|
|
|
|
Item.objects.create(title='agenda_item_bnghfdjkgndkjdfg')
|
|
|
|
User.objects.create_user('CoreMaximilian', 'xxx@xx.xx', 'default')
|
|
|
|
self.client = Client()
|
|
|
|
self.client.login(username='CoreMaximilian', password='default')
|
|
|
|
response = self.client.get('/search/?q=agenda_item_bnghfd')
|
|
|
|
text = '<span class="highlighted">agenda_item_bnghfd</span>jkgndkjdfg'
|
|
|
|
self.assertContains(response, text)
|
2013-11-14 19:29:08 +01:00
|
|
|
|
|
|
|
def test_anonymous(self):
|
|
|
|
self.assertFalse(config['system_enable_anonymous'])
|
|
|
|
self.assertEqual(Client().get('/search/').status_code, 403)
|
|
|
|
config['system_enable_anonymous'] = True
|
|
|
|
self.assertEqual(Client().get('/search/').status_code, 200)
|