vigiboard / dashboard / tests / models / test_auth.py @ 805cc54a
History | View | Annotate | Download (1.46 KB)
1 | 805cc54a | Thomas ANDREJAK | # -*- coding: utf-8 -*-
|
---|---|---|---|
2 | """Test suite for the TG app's models"""
|
||
3 | from nose.tools import eq_ |
||
4 | |||
5 | from dashboard import model |
||
6 | from dashboard.tests.models import ModelTest |
||
7 | |||
8 | class TestGroup(ModelTest): |
||
9 | """Unit test case for the ``Group`` model."""
|
||
10 | klass = model.Group |
||
11 | attrs = dict(
|
||
12 | group_name = u"test_group",
|
||
13 | display_name = u"Test Group"
|
||
14 | ) |
||
15 | |||
16 | |||
17 | class TestUser(ModelTest): |
||
18 | """Unit test case for the ``User`` model."""
|
||
19 | |||
20 | klass = model.User |
||
21 | attrs = dict(
|
||
22 | user_name = u"ignucius",
|
||
23 | email_address = u"ignucius@example.org"
|
||
24 | ) |
||
25 | |||
26 | def test_obj_creation_username(self): |
||
27 | """The obj constructor must set the user name right"""
|
||
28 | eq_(self.obj.user_name, u"ignucius") |
||
29 | |||
30 | def test_obj_creation_email(self): |
||
31 | """The obj constructor must set the email right"""
|
||
32 | eq_(self.obj.email_address, u"ignucius@example.org") |
||
33 | |||
34 | def test_no_permissions_by_default(self): |
||
35 | """User objects should have no permission by default."""
|
||
36 | eq_(len(self.obj.permissions), 0) |
||
37 | |||
38 | def test_getting_by_email(self): |
||
39 | """Users should be fetcheable by their email addresses"""
|
||
40 | him = model.User.by_email_address(u"ignucius@example.org")
|
||
41 | eq_(him, self.obj)
|
||
42 | |||
43 | |||
44 | class TestPermission(ModelTest): |
||
45 | """Unit test case for the ``Permission`` model."""
|
||
46 | |||
47 | klass = model.Permission |
||
48 | attrs = dict(
|
||
49 | permission_name = u"test_permission",
|
||
50 | description = u"This is a test Description"
|
||
51 | ) |