summaryrefslogtreecommitdiff
path: root/service/test/unit/config/test_register.py
blob: 7db2b000fcf2caf721faa5e4dddf2ac3bc49a30c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import unittest

from pixelated.config.register import validate_username


class TestRegister(unittest.TestCase):

    def test_username_raises_error_when_it_contains_uppercase_letters(self):
        with self.assertRaises(ValueError):
            validate_username('INVALIDUSERNAME')

    def test_username_raises_error_when_it_contains_special_characters(self):
        with self.assertRaises(ValueError):
            validate_username('invalid@username')

    def test_username_pass_when_valid(self):
        try:
            validate_username('a.valid_username-123')
        except:
            self.fail('Valid username should not raise an exception')