Update tests to extend test cover by coverage

This commit is contained in:
Norman Jäckel 2013-04-03 17:55:30 +02:00
parent a75c390bc5
commit 5d472b274a
5 changed files with 60 additions and 3 deletions

View File

@ -11,8 +11,8 @@ RELEASE = False
def get_version(version=None, release=None):
"""
Derives a PEP386-compliant version number from VERSION. Adds id of
the current git commit.
Derives a PEP386-compliant version number from VERSION. Adds '-dev',
if it is not a release commit.
"""
if version is None:
version = VERSION

View File

@ -56,6 +56,14 @@ class HandleConfigTest(TestCase):
config['string_var'] = 'other_special_unique_string dauTex9eAiy7jeen'
self.assertEqual(config['string_var'], 'other_special_unique_string dauTex9eAiy7jeen')
def test_missing_cache_(self):
del config._cache
self.assertEqual(config['string_var'], 'default_string_rien4ooCZieng6ah')
def test_config_contains(self):
self.assertTrue('string_var' in config)
self.assertFalse('unknown_config_var' in config)
class ConfigFormTest(TestCase):
@ -155,6 +163,16 @@ class ConfigFormTest(TestCase):
response = self.client_manager.get('/config/testgroupedpage1/')
self.assertNotContains(response=response, text='Ho5iengaoon5Hoht', status_code=200)
def test_extra_stylefiles(self):
response = self.client_manager.get('/config/testgroupedpage1/')
text = '<link href="/static/styles/test-config-sjNN56dFGDrg2.css" type="text/css" rel="stylesheet" />'
self.assertContains(response=response, text=text, status_code=200)
def test_extra_javascript(self):
response = self.client_manager.get('/config/testgroupedpage1/')
text = '<script src="/static/javascript/test-config-djg4dFGVslk4209f.js" type="text/javascript"></script>'
self.assertContains(response=response, text=text, status_code=200)
class ConfigWeightTest(TestCase):
@ -222,7 +240,9 @@ def set_grouped_config_page(sender, **kwargs):
url='testgroupedpage1',
required_permission='config.can_manage',
weight=10000,
groups=(group_1, group_2))
groups=(group_1, group_2),
extra_context={'extra_stylefiles': ['styles/test-config-sjNN56dFGDrg2.css'],
'extra_javascript': ['javascript/test-config-djg4dFGVslk4209f.js']})
@receiver(config_signal, dispatch_uid='set_simple_config_page_for_testing')

0
tests/core/__init__.py Normal file
View File

24
tests/core/test_views.py Normal file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Tests for openslides.core.views
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:copyright: 20112013 by OpenSlides team, see AUTHORS.
:license: GNU GPL, see LICENSE for more details.
"""
from django.test.client import Client
from openslides.utils.test import TestCase
from openslides import get_version
from openslides.participant.models import User
class VersionViewTest(TestCase):
def test_get(self):
user = User.objects.create_user('CoreMaximilian', 'xxx@xx.xx', 'default')
client = Client()
client.login(username='CoreMaximilian', password='default')
response = client.get('/version/')
self.assertContains(response, get_version(), status_code=200)

View File

@ -0,0 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
openslides.person_api
~~~~~~~~~~~~~~~~~~~~~
Unit test for the person api.
:copyright: 20112013 by OpenSlides team, see AUTHORS.
:license: GNU GPL, see LICENSE for more details.
"""
VERSION = (9999, 9999, 9999, 'alpha', 1)