OpenSlides/tests/participant/test_utils.py
Oskar Hahn d937262d28 Use flake8 instead of pep8. Orderd the imports with isort
* changed the fab-command pep8 to check
* checked and fixed any code with flake8. Also the urls.py
* checkt the projector app with pylint
2013-10-14 18:43:12 +02:00

37 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Tests for models of openslides.participant
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:copyright: 20112013 by OpenSlides team, see AUTHORS.
:license: GNU GPL, see LICENSE for more details.
"""
from openslides.participant.api import gen_username
from openslides.participant.models import User
from openslides.utils.test import TestCase
class UserGenUsername(TestCase):
"""
Tests for the function gen_username.
"""
def test_base(self):
self.assertEqual(gen_username('foo', 'bar'), 'foo bar')
self.assertEqual(gen_username('foo ', ' bar\n'), 'foo bar')
self.assertEqual(gen_username('foobar', ''), 'foobar')
self.assertEqual(gen_username('', 'foobar'), 'foobar')
self.assertRaises(ValueError, gen_username, '', '')
def test_used_username(self):
User.objects.create(username='user name')
self.assertEqual(gen_username('user', 'name'), 'user name 1')
User.objects.create(username='user name 1')
self.assertEqual(gen_username('user', 'name'), 'user name 2')
def test_umlauts(self):
self.assertEqual(gen_username('äöü', 'ßüäö'), 'äöü ßüäö')