[973dd91] | 1 | # -*- coding: utf-8 -*- |
---|
| 2 | """Test suite for the TG app's models""" |
---|
| 3 | |
---|
| 4 | from tg.testutil import DBTest |
---|
| 5 | from nose.tools import eq_ |
---|
| 6 | |
---|
| 7 | from sipbmp3web import model |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | class TestModel(DBTest): |
---|
| 11 | """The base class for testing models in you TG project.""" |
---|
| 12 | model = model |
---|
| 13 | |
---|
| 14 | class TestUser(TestModel): |
---|
| 15 | """Test case for the User model.""" |
---|
| 16 | |
---|
| 17 | def setUp(self): |
---|
| 18 | super(TestUser, self).setUp() |
---|
| 19 | self.member = model.User() |
---|
| 20 | self.member.user_name = u"ignucius" |
---|
| 21 | self.member.email_address = u"ignucius@example.org" |
---|
| 22 | |
---|
| 23 | def test_member_creation_username(self): |
---|
| 24 | """The member constructor must set the user name right""" |
---|
| 25 | eq_(self.member.user_name, u"ignucius") |
---|
| 26 | |
---|
| 27 | def test_member_creation_email(self): |
---|
| 28 | """The member constructor must set the email right""" |
---|
| 29 | eq_(self.member.email_address, u"ignucius@example.org") |
---|
| 30 | |
---|
| 31 | def test_no_permissions_by_default(self): |
---|
| 32 | """User objects should have no permission by default.""" |
---|
| 33 | eq_(len(self.member.permissions), 0) |
---|
| 34 | |
---|
| 35 | def test_getting_by_email(self): |
---|
| 36 | """Users should be fetcheable by their email addresses""" |
---|
| 37 | model.DBSession.add(self.member) |
---|
| 38 | him = model.User.by_email_address(u"ignucius@example.org") |
---|
| 39 | eq_(him, self.member) |
---|