Commit c42dd119 authored by Tres Seaver's avatar Tres Seaver

Add tests for __repr__ of user classes.

parent 36303837
...@@ -95,6 +95,10 @@ class SimpleUserTests(unittest.TestCase): ...@@ -95,6 +95,10 @@ class SimpleUserTests(unittest.TestCase):
simple = self._makeOne('phred', roles=()) simple = self._makeOne('phred', roles=())
self.assertEqual(simple.getRoles(), ('Authenticated',)) self.assertEqual(simple.getRoles(), ('Authenticated',))
def test___repr__(self):
special = self._makeOne()
self.assertEqual(repr(special), "<SimpleUser 'admin'>")
class SpecialUserTests(unittest.TestCase): class SpecialUserTests(unittest.TestCase):
...@@ -110,11 +114,15 @@ class SpecialUserTests(unittest.TestCase): ...@@ -110,11 +114,15 @@ class SpecialUserTests(unittest.TestCase):
return self._getTargetClass()(name, password, roles, domains) return self._getTargetClass()(name, password, roles, domains)
def test_overrides(self): def test_overrides(self):
simple = self._makeOne() special = self._makeOne()
self.assertEqual(simple.getUserName(), 'admin') self.assertEqual(special.getUserName(), 'admin')
self.assertEqual(simple.getId(), None) self.assertEqual(special.getId(), None)
self.assertEqual(simple._getPassword(), '123') self.assertEqual(special._getPassword(), '123')
self.assertEqual(simple.getDomains(), ()) self.assertEqual(special.getDomains(), ())
def test___repr__(self):
special = self._makeOne()
self.assertEqual(repr(special), "<SpecialUser 'admin'>")
class UnrestrictedUserTests(unittest.TestCase): class UnrestrictedUserTests(unittest.TestCase):
...@@ -159,6 +167,11 @@ class UnrestrictedUserTests(unittest.TestCase): ...@@ -159,6 +167,11 @@ class UnrestrictedUserTests(unittest.TestCase):
unrestricted = self._makeOne() unrestricted = self._makeOne()
self.failUnless(unrestricted.has_role(('Manager',), self)) self.failUnless(unrestricted.has_role(('Manager',), self))
def test___repr__(self):
unrestricted = self._makeOne()
self.assertEqual(repr(unrestricted),
"<UnrestrictedUser 'admin'>")
class NullUnrestrictedUserTests(unittest.TestCase): class NullUnrestrictedUserTests(unittest.TestCase):
......
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