summaryrefslogtreecommitdiff
path: root/service/test/unit/config/test_register.py
blob: 8e1a71a4aedede70fe089bf4a95383a403603577 (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.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')