test_auth.py 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. from pod import model
  6. from pod.tests.models import ModelTest
  7. class TestGroup(ModelTest):
  8. """Unit test case for the ``Group`` model."""
  9. klass = model.Group
  10. attrs = dict(
  11. group_name = "test_group",
  12. display_name = "Test Group"
  13. )
  14. class TestUser(ModelTest):
  15. """Unit test case for the ``User`` model."""
  16. klass = model.User
  17. attrs = dict(
  18. user_name = "ignucius",
  19. email_address = "ignucius@example.org"
  20. )
  21. def test_obj_creation_username(self):
  22. """The obj constructor must set the user name right"""
  23. eq_(self.obj.user_name, "ignucius")
  24. def test_obj_creation_email(self):
  25. """The obj constructor must set the email right"""
  26. eq_(self.obj.email_address, "ignucius@example.org")
  27. def test_no_permissions_by_default(self):
  28. """User objects should have no permission by default."""
  29. eq_(len(self.obj.permissions), 0)
  30. def test_getting_by_email(self):
  31. """Users should be fetcheable by their email addresses"""
  32. him = model.User.by_email_address("ignucius@example.org")
  33. eq_(him, self.obj)
  34. class TestPermission(ModelTest):
  35. """Unit test case for the ``Permission`` model."""
  36. klass = model.Permission
  37. attrs = dict(
  38. permission_name = "test_permission",
  39. description = "This is a test Description"
  40. )