Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
5e5cd658
Commit
5e5cd658
authored
May 16, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge further test cleanups from 2.12 branch.
parent
9d73c472
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
58 deletions
+18
-58
src/AccessControl/tests/testUser.py
src/AccessControl/tests/testUser.py
+18
-58
No files found.
src/AccessControl/tests/testUser.py
View file @
5e5cd658
...
...
@@ -95,6 +95,10 @@ class SimpleUserTests(unittest.TestCase):
simple
=
self
.
_makeOne
(
'phred'
,
roles
=
())
self
.
assertEqual
(
simple
.
getRoles
(),
(
'Authenticated'
,))
def
test___repr__
(
self
):
special
=
self
.
_makeOne
()
self
.
assertEqual
(
repr
(
special
),
"<SimpleUser 'admin'>"
)
class
SpecialUserTests
(
unittest
.
TestCase
):
...
...
@@ -110,11 +114,15 @@ class SpecialUserTests(unittest.TestCase):
return
self
.
_getTargetClass
()(
name
,
password
,
roles
,
domains
)
def
test_overrides
(
self
):
simple
=
self
.
_makeOne
()
self
.
assertEqual
(
simple
.
getUserName
(),
'admin'
)
self
.
assertEqual
(
simple
.
getId
(),
None
)
self
.
assertEqual
(
simple
.
_getPassword
(),
'123'
)
self
.
assertEqual
(
simple
.
getDomains
(),
())
special
=
self
.
_makeOne
()
self
.
assertEqual
(
special
.
getUserName
(),
'admin'
)
self
.
assertEqual
(
special
.
getId
(),
None
)
self
.
assertEqual
(
special
.
_getPassword
(),
'123'
)
self
.
assertEqual
(
special
.
getDomains
(),
())
def
test___repr__
(
self
):
special
=
self
.
_makeOne
()
self
.
assertEqual
(
repr
(
special
),
"<SpecialUser 'admin'>"
)
class
UnrestrictedUserTests
(
unittest
.
TestCase
):
...
...
@@ -159,6 +167,11 @@ class UnrestrictedUserTests(unittest.TestCase):
unrestricted
=
self
.
_makeOne
()
self
.
failUnless
(
unrestricted
.
has_role
((
'Manager'
,),
self
))
def
test___repr__
(
self
):
unrestricted
=
self
.
_makeOne
()
self
.
assertEqual
(
repr
(
unrestricted
),
"<UnrestrictedUser 'admin'>"
)
class
NullUnrestrictedUserTests
(
unittest
.
TestCase
):
...
...
@@ -211,58 +224,6 @@ class NullUnrestrictedUserTests(unittest.TestCase):
self
.
assertEqual
(
str
(
null
),
"<NullUnrestrictedUser (None, None)>"
)
class
UserTests
(
unittest
.
TestCase
):
def
_getTargetClass
(
self
):
from
AccessControl.User
import
User
return
User
def
_makeOne
(
self
,
name
,
password
,
roles
,
domains
):
return
self
.
_getTargetClass
()(
name
,
password
,
roles
,
domains
)
def
testGetUserName
(
self
):
f
=
self
.
_makeOne
(
'chris'
,
'123'
,
[
'Manager'
],
[])
self
.
assertEqual
(
f
.
getUserName
(),
'chris'
)
def
testGetUserId
(
self
):
f
=
self
.
_makeOne
(
'chris'
,
'123'
,
[
'Manager'
],
[])
self
.
assertEqual
(
f
.
getId
(),
'chris'
)
def
testBaseUserGetIdEqualGetName
(
self
):
# this is true for the default user type, but will not
# always be true for extended user types going forward (post-2.6)
f
=
self
.
_makeOne
(
'chris'
,
'123'
,
[
'Manager'
],
[])
self
.
assertEqual
(
f
.
getId
(),
f
.
getUserName
())
def
testGetPassword
(
self
):
f
=
self
.
_makeOne
(
'chris'
,
'123'
,
[
'Manager'
],
[])
self
.
assertEqual
(
f
.
_getPassword
(),
'123'
)
def
testGetRoles
(
self
):
f
=
self
.
_makeOne
(
'chris'
,
'123'
,
[
'Manager'
],
[])
self
.
assertEqual
(
f
.
getRoles
(),
(
'Manager'
,
'Authenticated'
))
def
testGetDomains
(
self
):
f
=
self
.
_makeOne
(
'chris'
,
'123'
,
[
'Manager'
],
[])
self
.
assertEqual
(
f
.
getDomains
(),
())
def
testRepr
(
self
):
f
=
self
.
_makeOne
(
'flo'
,
'123'
,
[
'Manager'
],
[])
self
.
assertEqual
(
repr
(
f
),
"<User 'flo'>"
)
def
testReprSpecial
(
self
):
from
AccessControl.User
import
NullUnrestrictedUser
from
AccessControl.User
import
nobody
from
AccessControl.User
import
system
# NullUnrestrictedUser is used when there is no emergency user
self
.
assertEqual
(
repr
(
NullUnrestrictedUser
()),
"<NullUnrestrictedUser (None, None)>"
)
self
.
assertEqual
(
repr
(
nobody
),
"<SpecialUser 'Anonymous User'>"
)
self
.
assertEqual
(
repr
(
system
),
"<UnrestrictedUser 'System Processes'>"
)
class
UserFolderTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
@@ -533,6 +494,5 @@ def test_suite():
suite
.
addTest
(
unittest
.
makeSuite
(
SpecialUserTests
))
suite
.
addTest
(
unittest
.
makeSuite
(
UnrestrictedUserTests
))
suite
.
addTest
(
unittest
.
makeSuite
(
NullUnrestrictedUserTests
))
suite
.
addTest
(
unittest
.
makeSuite
(
UserTests
))
suite
.
addTest
(
unittest
.
makeSuite
(
UserFolderTests
))
return
suite
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment