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