Commit d7a937b4 authored by Tres Seaver's avatar Tres Seaver

Coverage for SimpleUser.

parent e7b71fdd
...@@ -67,6 +67,35 @@ class BasicUserTests(unittest.TestCase): ...@@ -67,6 +67,35 @@ class BasicUserTests(unittest.TestCase):
self.assertEqual(repr(derived), "<Derived 'phred'>") self.assertEqual(repr(derived), "<Derived 'phred'>")
class SimpleUserTests(unittest.TestCase):
def _getTargetClass(self):
from AccessControl.User import SimpleUser
return SimpleUser
def _makeOne(self, name='admin', password='123', roles=None, domains=None):
if roles is None:
roles = ['Manager']
if domains is None:
domains = []
return self._getTargetClass()(name, password, roles, domains)
def test_overrides(self):
simple = self._makeOne()
self.assertEqual(simple.getUserName(), 'admin')
self.assertEqual(simple.getId(), 'admin')
self.assertEqual(simple._getPassword(), '123')
self.assertEqual(simple.getDomains(), ())
def test_getRoles_anonymous(self):
simple = self._makeOne('Anonymous User', roles=())
self.assertEqual(simple.getRoles(), ())
def test_getRoles_non_anonymous(self):
simple = self._makeOne('phred', roles=())
self.assertEqual(simple.getRoles(), ('Authenticated',))
class UserTests(unittest.TestCase): class UserTests(unittest.TestCase):
def _getTargetClass(self): def _getTargetClass(self):
...@@ -385,6 +414,7 @@ class UserFolderTests(unittest.TestCase): ...@@ -385,6 +414,7 @@ class UserFolderTests(unittest.TestCase):
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(BasicUserTests)) suite.addTest(unittest.makeSuite(BasicUserTests))
suite.addTest(unittest.makeSuite(SimpleUserTests))
suite.addTest(unittest.makeSuite(UserTests)) suite.addTest(unittest.makeSuite(UserTests))
suite.addTest(unittest.makeSuite(UserFolderTests)) suite.addTest(unittest.makeSuite(UserFolderTests))
return suite return suite
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment