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
6220f215
Commit
6220f215
authored
Aug 08, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced failUnless with assertTrue and failIf with assertFalse in tests.
parent
422ab1b6
Changes
63
Hide whitespace changes
Inline
Side-by-side
Showing
63 changed files
with
703 additions
and
698 deletions
+703
-698
doc/CHANGES.rst
doc/CHANGES.rst
+5
-0
src/App/tests/testImageFile.py
src/App/tests/testImageFile.py
+3
-3
src/App/tests/test_ApplicationManager.py
src/App/tests/test_ApplicationManager.py
+27
-27
src/App/tests/test_Extensions.py
src/App/tests/test_Extensions.py
+14
-14
src/OFS/tests/testAppInitializer.py
src/OFS/tests/testAppInitializer.py
+15
-15
src/OFS/tests/testApplication.py
src/OFS/tests/testApplication.py
+3
-3
src/OFS/tests/testCache.py
src/OFS/tests/testCache.py
+2
-2
src/OFS/tests/testCopySupport.py
src/OFS/tests/testCopySupport.py
+62
-62
src/OFS/tests/testFileAndImage.py
src/OFS/tests/testFileAndImage.py
+14
-14
src/OFS/tests/testHistory.py
src/OFS/tests/testHistory.py
+5
-5
src/OFS/tests/testObjectManager.py
src/OFS/tests/testObjectManager.py
+48
-48
src/OFS/tests/testProperties.py
src/OFS/tests/testProperties.py
+14
-14
src/OFS/tests/testRanges.py
src/OFS/tests/testRanges.py
+18
-18
src/OFS/tests/testSimpleItem.py
src/OFS/tests/testSimpleItem.py
+3
-3
src/OFS/tests/testTraverse.py
src/OFS/tests/testTraverse.py
+13
-13
src/OFS/tests/test_DTMLDocument.py
src/OFS/tests/test_DTMLDocument.py
+3
-3
src/OFS/tests/test_DTMLMethod.py
src/OFS/tests/test_DTMLMethod.py
+3
-3
src/OFS/tests/test_Uninstalled.py
src/OFS/tests/test_Uninstalled.py
+6
-6
src/OFS/tests/test_XMLExportImport.py
src/OFS/tests/test_XMLExportImport.py
+2
-2
src/OFS/tests/test_userfolder.py
src/OFS/tests/test_userfolder.py
+8
-8
src/Products/Five/browser/tests/pages_ftest.txt
src/Products/Five/browser/tests/pages_ftest.txt
+4
-4
src/Products/Five/browser/tests/test_metaconfigure.py
src/Products/Five/browser/tests/test_metaconfigure.py
+7
-7
src/Products/Five/browser/tests/test_pagetemplatefile.py
src/Products/Five/browser/tests/test_pagetemplatefile.py
+17
-17
src/Products/PageTemplates/tests/testExpressions.py
src/Products/PageTemplates/tests/testExpressions.py
+7
-7
src/Products/PageTemplates/tests/testZRPythonExpr.py
src/Products/PageTemplates/tests/testZRPythonExpr.py
+2
-2
src/Products/PageTemplates/tests/testZopePageTemplate.py
src/Products/PageTemplates/tests/testZopePageTemplate.py
+6
-6
src/Products/PageTemplates/tests/test_ptfile.py
src/Products/PageTemplates/tests/test_ptfile.py
+1
-1
src/Products/PluginIndexes/DateIndex/tests/test_DateIndex.py
src/Products/PluginIndexes/DateIndex/tests/test_DateIndex.py
+10
-10
src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
...PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
+5
-5
src/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
...ucts/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
+6
-6
src/Products/PluginIndexes/PathIndex/tests/testPathIndex.py
src/Products/PluginIndexes/PathIndex/tests/testPathIndex.py
+3
-3
src/Products/Sessions/tests/testBrowserIdManager.py
src/Products/Sessions/tests/testBrowserIdManager.py
+33
-33
src/Products/Sessions/tests/testSessionDataManager.py
src/Products/Sessions/tests/testSessionDataManager.py
+18
-18
src/Products/SiteAccess/tests/testAccessRule.py
src/Products/SiteAccess/tests/testAccessRule.py
+30
-30
src/Products/SiteAccess/tests/testSiteRoot.py
src/Products/SiteAccess/tests/testSiteRoot.py
+15
-15
src/Products/SiteAccess/tests/testVirtualHostMonster.py
src/Products/SiteAccess/tests/testVirtualHostMonster.py
+4
-4
src/Products/Transience/tests/testTransientObject.py
src/Products/Transience/tests/testTransientObject.py
+3
-3
src/Products/Transience/tests/testTransientObjectContainer.py
...Products/Transience/tests/testTransientObjectContainer.py
+4
-4
src/Products/ZCatalog/tests/test_brains.py
src/Products/ZCatalog/tests/test_brains.py
+4
-4
src/Products/ZCatalog/tests/test_zcatalog.py
src/Products/ZCatalog/tests/test_zcatalog.py
+1
-1
src/Products/ZReST/tests/test_ZReST.py
src/Products/ZReST/tests/test_ZReST.py
+3
-3
src/Testing/ZopeTestCase/testFunctional.py
src/Testing/ZopeTestCase/testFunctional.py
+1
-1
src/Testing/ZopeTestCase/testInterfaces.py
src/Testing/ZopeTestCase/testInterfaces.py
+19
-19
src/Testing/ZopeTestCase/testPortalTestCase.py
src/Testing/ZopeTestCase/testPortalTestCase.py
+34
-34
src/Testing/ZopeTestCase/testZODBCompat.py
src/Testing/ZopeTestCase/testZODBCompat.py
+26
-26
src/Testing/ZopeTestCase/testZopeTestCase.py
src/Testing/ZopeTestCase/testZopeTestCase.py
+26
-26
src/Testing/tests/test_makerequest.py
src/Testing/tests/test_makerequest.py
+4
-4
src/ZPublisher/tests/testHTTPRangeSupport.py
src/ZPublisher/tests/testHTTPRangeSupport.py
+3
-3
src/ZPublisher/tests/testHTTPRequest.py
src/ZPublisher/tests/testHTTPRequest.py
+12
-12
src/ZPublisher/tests/testHTTPResponse.py
src/ZPublisher/tests/testHTTPResponse.py
+50
-50
src/ZPublisher/tests/test_WSGIPublisher.py
src/ZPublisher/tests/test_WSGIPublisher.py
+17
-17
src/ZPublisher/tests/test_xmlrpc.py
src/ZPublisher/tests/test_xmlrpc.py
+7
-7
src/ZPublisher/tests/testpubevents.py
src/ZPublisher/tests/testpubevents.py
+1
-1
src/ZServer/tests/test_clockserver.py
src/ZServer/tests/test_clockserver.py
+3
-3
src/ZServer/tests/test_responses.py
src/ZServer/tests/test_responses.py
+1
-1
src/ZTUtils/tests/testTree.py
src/ZTUtils/tests/testTree.py
+1
-1
src/Zope2/App/tests/testExceptionHook.py
src/Zope2/App/tests/testExceptionHook.py
+24
-24
src/Zope2/App/tests/test_schema.py
src/Zope2/App/tests/test_schema.py
+1
-1
src/Zope2/Startup/tests/testStarter.py
src/Zope2/Startup/tests/testStarter.py
+8
-8
src/reStructuredText/tests/testReST.py
src/reStructuredText/tests/testReST.py
+2
-2
src/webdav/tests/testLockable.py
src/webdav/tests/testLockable.py
+5
-5
src/webdav/tests/testNullResource.py
src/webdav/tests/testNullResource.py
+2
-2
src/webdav/tests/testPUT_factory.py
src/webdav/tests/testPUT_factory.py
+5
-5
No files found.
doc/CHANGES.rst
View file @
6220f215
...
...
@@ -12,6 +12,11 @@ Bugs Fixed
++++++++++
Features Added
++++++++++++++
- Replaced failUnless with assertTrue and failIf with assertFalse in tests.
2.13.0a3 (2010-08-04)
---------------------
...
...
src/App/tests/testImageFile.py
View file @
6220f215
...
...
@@ -27,17 +27,17 @@ class TestImageFile(unittest.TestCase):
path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
App
.
__file__
),
'www'
,
'zopelogo.jpg'
)
App
.
ImageFile
.
ImageFile
(
path
)
self
.
failIf
(
self
.
warningshook
.
warnings
)
self
.
assertFalse
(
self
.
warningshook
.
warnings
)
def
test_no_warn_on_path_as_prefix
(
self
):
prefix
=
os
.
path
.
dirname
(
App
.
__file__
)
App
.
ImageFile
.
ImageFile
(
'www/zopelogo.jpg'
,
prefix
)
self
.
failIf
(
self
.
warningshook
.
warnings
)
self
.
assertFalse
(
self
.
warningshook
.
warnings
)
def
test_no_warn_on_namespace_as_prefix
(
self
):
prefix
=
App
.
__dict__
# same as calling globals() inside the App module
App
.
ImageFile
.
ImageFile
(
'www/zopelogo.jpg'
,
prefix
)
self
.
failIf
(
self
.
warningshook
.
warnings
)
self
.
assertFalse
(
self
.
warningshook
.
warnings
)
def
test_suite
():
return
unittest
.
TestSuite
((
...
...
src/App/tests/test_ApplicationManager.py
View file @
6220f215
...
...
@@ -31,7 +31,7 @@ class FakeConnectionTests(unittest.TestCase):
db
=
object
()
parent_jar
=
object
()
fc
=
self
.
_makeOne
(
db
,
parent_jar
)
self
.
failUnless
(
fc
.
db
()
is
db
)
self
.
assertTrue
(
fc
.
db
()
is
db
)
class
DatabaseChooserTests
(
ConfigTestBase
,
unittest
.
TestCase
):
...
...
@@ -70,12 +70,12 @@ class DatabaseChooserTests(ConfigTestBase, unittest.TestCase):
root
=
self
.
_makeRoot
()
dc
=
self
.
_makeOne
(
'test'
).
__of__
(
root
)
found
=
dc
[
'foo'
]
self
.
failUnless
(
isinstance
(
found
,
AltDatabaseManager
))
self
.
assertTrue
(
isinstance
(
found
,
AltDatabaseManager
))
self
.
assertEqual
(
found
.
id
,
'foo'
)
self
.
failUnless
(
found
.
aq_parent
is
dc
)
self
.
assertTrue
(
found
.
aq_parent
is
dc
)
conn
=
found
.
_p_jar
self
.
failUnless
(
isinstance
(
conn
,
FakeConnection
))
self
.
failUnless
(
conn
.
db
()
is
foo
)
self
.
assertTrue
(
isinstance
(
conn
,
FakeConnection
))
self
.
assertTrue
(
conn
.
db
()
is
foo
)
def
test___bobo_traverse___miss
(
self
):
self
.
_makeConfig
(
foo
=
object
(),
bar
=
object
(),
qux
=
object
())
...
...
@@ -93,12 +93,12 @@ class DatabaseChooserTests(ConfigTestBase, unittest.TestCase):
root
=
self
.
_makeRoot
()
dc
=
self
.
_makeOne
(
'test'
).
__of__
(
root
)
found
=
dc
.
__bobo_traverse__
(
None
,
'foo'
)
self
.
failUnless
(
isinstance
(
found
,
AltDatabaseManager
))
self
.
assertTrue
(
isinstance
(
found
,
AltDatabaseManager
))
self
.
assertEqual
(
found
.
id
,
'foo'
)
self
.
failUnless
(
found
.
aq_parent
is
dc
)
self
.
assertTrue
(
found
.
aq_parent
is
dc
)
conn
=
found
.
_p_jar
self
.
failUnless
(
isinstance
(
conn
,
FakeConnection
))
self
.
failUnless
(
conn
.
db
()
is
foo
)
self
.
assertTrue
(
isinstance
(
conn
,
FakeConnection
))
self
.
assertTrue
(
conn
.
db
()
is
foo
)
def
test___bobo_traverse___miss_db_hit_attr
(
self
):
foo
=
object
()
...
...
@@ -109,7 +109,7 @@ class DatabaseChooserTests(ConfigTestBase, unittest.TestCase):
dc
=
self
.
_makeOne
(
'test'
).
__of__
(
root
)
dc
.
spam
=
spam
=
object
()
found
=
dc
.
__bobo_traverse__
(
None
,
'spam'
)
self
.
failUnless
(
found
is
spam
)
self
.
assertTrue
(
found
is
spam
)
def
test_tpValues
(
self
):
from
App.ApplicationManager
import
AltDatabaseManager
...
...
@@ -121,13 +121,13 @@ class DatabaseChooserTests(ConfigTestBase, unittest.TestCase):
dc
=
self
.
_makeOne
(
'test'
).
__of__
(
root
)
values
=
dc
.
tpValues
()
self
.
assertEqual
(
len
(
values
),
3
)
self
.
failUnless
(
isinstance
(
values
[
0
],
AltDatabaseManager
))
self
.
assertTrue
(
isinstance
(
values
[
0
],
AltDatabaseManager
))
self
.
assertEqual
(
values
[
0
].
id
,
'bar'
)
self
.
assertEqual
(
values
[
0
].
_p_jar
,
None
)
self
.
failUnless
(
isinstance
(
values
[
1
],
AltDatabaseManager
))
self
.
assertTrue
(
isinstance
(
values
[
1
],
AltDatabaseManager
))
self
.
assertEqual
(
values
[
1
].
id
,
'foo'
)
self
.
assertEqual
(
values
[
1
].
_p_jar
,
None
)
self
.
failUnless
(
isinstance
(
values
[
2
],
AltDatabaseManager
))
self
.
assertTrue
(
isinstance
(
values
[
2
],
AltDatabaseManager
))
self
.
assertEqual
(
values
[
2
].
id
,
'qux'
)
self
.
assertEqual
(
values
[
2
].
_p_jar
,
None
)
...
...
@@ -177,11 +177,11 @@ class DebugManagerTests(unittest.TestCase):
pairs
=
dm
.
refcount
()
# XXX : Ugly empiricism here: I don't know why the count is up 1.
foo_count
=
sys
.
getrefcount
(
Foo
)
self
.
failUnless
((
foo_count
+
1
,
'foo.Foo'
)
in
pairs
)
self
.
assertTrue
((
foo_count
+
1
,
'foo.Foo'
)
in
pairs
)
bar_count
=
sys
.
getrefcount
(
Bar
)
self
.
failUnless
((
bar_count
+
1
,
'foo.Bar'
)
in
pairs
)
self
.
assertTrue
((
bar_count
+
1
,
'foo.Bar'
)
in
pairs
)
baz_count
=
sys
.
getrefcount
(
Baz
)
self
.
failUnless
((
baz_count
+
1
,
'qux.Baz'
)
in
pairs
)
self
.
assertTrue
((
baz_count
+
1
,
'qux.Baz'
)
in
pairs
)
def
test_refdict
(
self
):
import
sys
...
...
@@ -206,7 +206,7 @@ class DebugManagerTests(unittest.TestCase):
dm
.
rcsnapshot
()
after
=
DateTime
()
# XXX : Ugly empiricism here: I don't know why the count is up 1.
self
.
failUnless
(
before
<=
App
.
ApplicationManager
.
_v_rst
<=
after
)
self
.
assertTrue
(
before
<=
App
.
ApplicationManager
.
_v_rst
<=
after
)
mapping
=
App
.
ApplicationManager
.
_v_rcs
foo_count
=
sys
.
getrefcount
(
Foo
)
self
.
assertEqual
(
mapping
[
'foo.Foo'
],
foo_count
+
1
)
...
...
@@ -222,17 +222,17 @@ class DebugManagerTests(unittest.TestCase):
dm
=
self
.
_makeOne
(
'test'
)
found
=
dm
.
rcdate
()
App
.
ApplicationManager
.
_v_rst
=
None
self
.
failUnless
(
found
is
dummy
)
self
.
assertTrue
(
found
is
dummy
)
def
test_rcdeltas
(
self
):
dm
=
self
.
_makeOne
(
'test'
)
dm
.
rcsnapshot
()
Foo
,
Bar
,
Baz
=
self
.
_makeModuleClasses
()
mappings
=
dm
.
rcdeltas
()
self
.
failUnless
(
len
(
mappings
))
self
.
assertTrue
(
len
(
mappings
))
mapping
=
mappings
[
0
]
self
.
failUnless
(
'rc'
in
mapping
)
self
.
failUnless
(
'pc'
in
mapping
)
self
.
assertTrue
(
'rc'
in
mapping
)
self
.
assertTrue
(
'pc'
in
mapping
)
self
.
assertEqual
(
mapping
[
'delta'
],
mapping
[
'rc'
]
-
mapping
[
'pc'
])
#def test_dbconnections(self): XXX -- TOO UGLY TO TEST
...
...
@@ -252,8 +252,8 @@ class DebugManagerTests(unittest.TestCase):
sys
.
_ps_
=
_old_sys__ps_
if
_old_Publish_pstat
is
not
self
:
Publish
.
_pstat
=
_old_Publish_pstat
self
.
failUnless
(
sys
.
_ps_
is
None
)
self
.
failUnless
(
Publish
.
_pstat
is
None
)
self
.
assertTrue
(
sys
.
_ps_
is
None
)
self
.
assertTrue
(
Publish
.
_pstat
is
None
)
def
test_manage_getSysPath
(
self
):
import
sys
...
...
@@ -353,11 +353,11 @@ class ApplicationManagerTests(ConfigTestBase,
def
test_ctor_initializes_Products
(
self
):
from
App.Product
import
ProductFolder
am
=
self
.
_makeOne
()
self
.
failUnless
(
isinstance
(
am
.
Products
,
ProductFolder
))
self
.
assertTrue
(
isinstance
(
am
.
Products
,
ProductFolder
))
def
test__canCopy
(
self
):
am
=
self
.
_makeOne
()
self
.
failIf
(
am
.
_canCopy
())
self
.
assertFalse
(
am
.
_canCopy
())
def
test_manage_app
(
self
):
from
zExceptions
import
Redirect
...
...
@@ -505,8 +505,8 @@ class ApplicationManagerTests(ConfigTestBase,
socket_map
.
update
(
_old_socket_map
)
self
.
assertEqual
(
len
(
pairs
),
2
)
self
.
failUnless
((
str
(
DummySocketServer
),
'Port: 45'
)
in
pairs
)
self
.
failUnless
((
str
(
AnotherSocketServer
),
'Port: 57'
)
in
pairs
)
self
.
assertTrue
((
str
(
DummySocketServer
),
'Port: 45'
)
in
pairs
)
self
.
assertTrue
((
str
(
AnotherSocketServer
),
'Port: 57'
)
in
pairs
)
#def test_objectIds(self): XXX -- TOO UGLY TO TEST (BBB for Zope 2.3!!)
...
...
src/App/tests/test_Extensions.py
View file @
6220f215
...
...
@@ -56,13 +56,13 @@ class FuncCodeTests(unittest.TestCase):
def
f
(
self
):
pass
fc
=
self
.
_makeOne
(
f
,
im
=
1
)
self
.
failUnless
(
cmp
(
fc
,
None
)
>
0
)
self
.
assertTrue
(
cmp
(
fc
,
None
)
>
0
)
def
test___cmp___non_FuncCode
(
self
):
def
f
(
self
):
pass
fc
=
self
.
_makeOne
(
f
,
im
=
1
)
self
.
failUnless
(
cmp
(
fc
,
object
())
>
0
)
self
.
assertTrue
(
cmp
(
fc
,
object
())
>
0
)
def
test___cmp___w_FuncCode_same_args
(
self
):
def
f
(
self
,
a
,
b
):
...
...
@@ -71,7 +71,7 @@ class FuncCodeTests(unittest.TestCase):
pass
fc
=
self
.
_makeOne
(
f
,
im
=
1
)
fc2
=
self
.
_makeOne
(
g
,
im
=
1
)
self
.
failUnless
(
cmp
(
fc
,
fc2
)
==
0
)
self
.
assertTrue
(
cmp
(
fc
,
fc2
)
==
0
)
def
test___cmp___w_FuncCode_different_args
(
self
):
def
f
(
self
):
...
...
@@ -80,7 +80,7 @@ class FuncCodeTests(unittest.TestCase):
pass
fc
=
self
.
_makeOne
(
f
,
im
=
1
)
fc2
=
self
.
_makeOne
(
g
,
im
=
1
)
self
.
failUnless
(
cmp
(
fc
,
fc2
)
<
0
)
self
.
assertTrue
(
cmp
(
fc
,
fc2
)
<
0
)
class
_TempdirBase
:
...
...
@@ -317,14 +317,14 @@ class Test_getObject(_TempdirBase, unittest.TestCase):
obj
=
object
()
MODULES
=
{
'somemodule'
:
{
'name'
:
obj
}}
found
=
self
.
_callFUT
(
'somemodule'
,
'name'
,
modules
=
MODULES
)
self
.
failUnless
(
found
is
obj
)
self
.
assertTrue
(
found
is
obj
)
def
test_no_such_module
(
self
):
from
zExceptions
import
NotFound
MODULES
=
{}
self
.
assertRaises
(
NotFound
,
self
.
_callFUT
,
'nonesuch'
,
'name'
,
modules
=
MODULES
)
self
.
failIf
(
'nonesuch'
in
MODULES
)
self
.
assertFalse
(
'nonesuch'
in
MODULES
)
def
test_not_found_in_module
(
self
):
from
zExceptions
import
NotFound
...
...
@@ -333,8 +333,8 @@ class Test_getObject(_TempdirBase, unittest.TestCase):
ext
=
self
.
_makeFile
(
extdir
,
'extension.py'
)
self
.
assertRaises
(
NotFound
,
self
.
_callFUT
,
'foo.extension'
,
'name'
,
modules
=
MODULES
)
self
.
failUnless
(
'foo.extension'
in
MODULES
)
self
.
failIf
(
'named'
in
MODULES
[
'foo.extension'
])
self
.
assertTrue
(
'foo.extension'
in
MODULES
)
self
.
assertFalse
(
'named'
in
MODULES
[
'foo.extension'
])
def
test_found_in_module
(
self
):
MODULES
=
{}
...
...
@@ -342,7 +342,7 @@ class Test_getObject(_TempdirBase, unittest.TestCase):
ext
=
self
.
_makeFile
(
extdir
,
'extension.py'
,
EXTENSION_PY
)
found
=
self
.
_callFUT
(
'foo.extension'
,
'named'
,
modules
=
MODULES
)
self
.
assertEqual
(
found
,
'NAMED'
)
self
.
failUnless
(
'foo.extension'
in
MODULES
)
self
.
assertTrue
(
'foo.extension'
in
MODULES
)
self
.
assertEqual
(
MODULES
[
'foo.extension'
][
'named'
],
'NAMED'
)
def
test_found_in_module_pyc
(
self
):
...
...
@@ -355,7 +355,7 @@ class Test_getObject(_TempdirBase, unittest.TestCase):
os
.
remove
(
ext
)
found
=
self
.
_callFUT
(
'foo.extension'
,
'named'
,
modules
=
MODULES
)
self
.
assertEqual
(
found
,
'NAMED'
)
self
.
failUnless
(
'foo.extension'
in
MODULES
)
self
.
assertTrue
(
'foo.extension'
in
MODULES
)
self
.
assertEqual
(
MODULES
[
'foo.extension'
][
'named'
],
'NAMED'
)
def
test_found_in_module_after_cache_miss
(
self
):
...
...
@@ -388,26 +388,26 @@ class Test_getBrain(_TempdirBase, unittest.TestCase):
def
test_no_module_no_class_yields_NoBrains
(
self
):
from
App.Extensions
import
NoBrains
self
.
failUnless
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
self
.
assertTrue
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
def
test_missing_name
(
self
):
from
App.Extensions
import
NoBrains
from
zExceptions
import
NotFound
self
.
failUnless
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
self
.
assertTrue
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
MODULES
=
{
'somemodule'
:
{}}
self
.
assertRaises
(
NotFound
,
self
.
_callFUT
,
'somemodule'
,
'name'
,
modules
=
MODULES
)
def
test_not_a_class
(
self
):
from
App.Extensions
import
NoBrains
self
.
failUnless
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
self
.
assertTrue
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
MODULES
=
{
'somemodule'
:
{
'name'
:
object
()}}
self
.
assertRaises
(
ValueError
,
self
.
_callFUT
,
'somemodule'
,
'name'
,
modules
=
MODULES
)
def
test_found_class
(
self
):
from
App.Extensions
import
NoBrains
self
.
failUnless
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
self
.
assertTrue
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
MODULES
=
{
'somemodule'
:
{
'name'
:
self
.
__class__
}}
self
.
assertEqual
(
self
.
_callFUT
(
'somemodule'
,
'name'
,
modules
=
MODULES
),
self
.
__class__
)
...
...
src/OFS/tests/testAppInitializer.py
View file @
6220f215
...
...
@@ -98,9 +98,9 @@ class TestInitialization( unittest.TestCase ):
i
=
self
.
getOne
()
app
=
i
.
getApp
()
i
.
install_cp_and_products
()
self
.
failUnless
(
hasattr
(
app
,
'Control_Panel'
))
self
.
assertTrue
(
hasattr
(
app
,
'Control_Panel'
))
self
.
assertEqual
(
app
.
Control_Panel
.
meta_type
,
'Control Panel'
)
self
.
failUnless
(
hasattr
(
app
.
Control_Panel
,
'Products'
))
self
.
assertTrue
(
hasattr
(
app
.
Control_Panel
,
'Products'
))
self
.
assertEqual
(
app
.
Control_Panel
.
Products
.
meta_type
,
'Product Management'
)
...
...
@@ -112,13 +112,13 @@ class TestInitialization( unittest.TestCase ):
self
.
assertEqual
(
app
.
temp_folder
.
meta_type
,
'Temporary Folder'
)
self
.
assertEqual
(
app
.
temp_folder
.
session_data
.
meta_type
,
'Transient Object Container'
)
self
.
failUnless
(
app
.
_getInitializerFlag
(
'temp_folder'
))
self
.
assertTrue
(
app
.
_getInitializerFlag
(
'temp_folder'
))
def
test_install_tempfolder_and_sdc_status
(
self
):
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
status
=
i
.
install_tempfolder_and_sdc
()
self
.
failUnless
(
status
)
self
.
assertTrue
(
status
)
i
=
self
.
getOne
()
self
.
configure
(
bad_cfg
)
...
...
@@ -128,7 +128,7 @@ class TestInitialization( unittest.TestCase ):
status
=
i
.
install_tempfolder_and_sdc
()
finally
:
logger
.
disabled
=
0
self
.
failIf
(
status
)
self
.
assertFalse
(
status
)
def
test_install_tempfolder_and_sdc_unlimited_sessions
(
self
):
unlimited_cfg
=
good_cfg
+
"""
...
...
@@ -137,7 +137,7 @@ class TestInitialization( unittest.TestCase ):
self
.
configure
(
unlimited_cfg
)
i
=
self
.
getOne
()
status
=
i
.
install_tempfolder_and_sdc
()
self
.
failUnless
(
status
)
self
.
assertTrue
(
status
)
sdc
=
i
.
getApp
().
temp_folder
.
session_data
self
.
assertEqual
(
sdc
.
getSubobjectLimit
(),
0
)
...
...
@@ -148,7 +148,7 @@ class TestInitialization( unittest.TestCase ):
app
=
i
.
getApp
()
i
.
install_browser_id_manager
()
self
.
assertEqual
(
app
.
browser_id_manager
.
meta_type
,
'Browser Id Manager'
)
self
.
failUnless
(
app
.
_getInitializerFlag
(
'browser_id_manager'
))
self
.
assertTrue
(
app
.
_getInitializerFlag
(
'browser_id_manager'
))
def
test_install_virtual_hosting
(
self
):
self
.
configure
(
good_cfg
)
...
...
@@ -156,7 +156,7 @@ class TestInitialization( unittest.TestCase ):
app
=
i
.
getApp
()
i
.
install_virtual_hosting
()
self
.
assertEqual
(
app
.
virtual_hosting
.
meta_type
,
'Virtual Host Monster'
)
self
.
failUnless
(
app
.
_getInitializerFlag
(
'virtual_hosting'
))
self
.
assertTrue
(
app
.
_getInitializerFlag
(
'virtual_hosting'
))
def
test_install_session_data_manager
(
self
):
self
.
configure
(
good_cfg
)
...
...
@@ -165,15 +165,15 @@ class TestInitialization( unittest.TestCase ):
app
=
i
.
getApp
()
self
.
assertEqual
(
app
.
session_data_manager
.
meta_type
,
'Session Data Manager'
)
self
.
failUnless
(
app
.
_getInitializerFlag
(
'session_data_manager'
))
self
.
assertTrue
(
app
.
_getInitializerFlag
(
'session_data_manager'
))
def
test_install_required_roles
(
self
):
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
i
.
install_required_roles
()
app
=
i
.
getApp
()
self
.
failUnless
(
'Owner'
in
app
.
__ac_roles__
)
self
.
failUnless
(
'Authenticated'
in
app
.
__ac_roles__
)
self
.
assertTrue
(
'Owner'
in
app
.
__ac_roles__
)
self
.
assertTrue
(
'Authenticated'
in
app
.
__ac_roles__
)
def
test_install_inituser
(
self
):
fname
=
os
.
path
.
join
(
TEMPNAME
,
'inituser'
)
...
...
@@ -185,7 +185,7 @@ class TestInitialization( unittest.TestCase ):
i
=
self
.
getOne
()
i
.
install_inituser
()
app
=
i
.
getApp
()
self
.
failUnless
(
app
.
acl_users
.
getUser
(
'theuser'
))
self
.
assertTrue
(
app
.
acl_users
.
getUser
(
'theuser'
))
finally
:
if
os
.
path
.
exists
(
fname
):
os
.
unlink
(
fname
)
...
...
@@ -196,13 +196,13 @@ class TestInitialization( unittest.TestCase ):
i
.
install_errorlog
()
app
=
i
.
getApp
()
self
.
assertEqual
(
app
.
error_log
.
meta_type
,
'Site Error Log'
)
self
.
failUnless
(
app
.
_getInitializerFlag
(
'error_log'
))
self
.
assertTrue
(
app
.
_getInitializerFlag
(
'error_log'
))
def
test_install_products
(
self
):
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
i
.
install_products
()
self
.
failUnless
(
Application
.
misc_
.
__dict__
.
has_key
(
'OFSP'
))
self
.
assertTrue
(
Application
.
misc_
.
__dict__
.
has_key
(
'OFSP'
))
def
test_install_standards
(
self
):
self
.
configure
(
good_cfg
)
...
...
@@ -212,7 +212,7 @@ class TestInitialization( unittest.TestCase ):
app
=
i
.
getApp
()
self
.
assertEqual
(
app
.
index_html
.
meta_type
,
'Page Template'
)
self
.
assertEqual
(
app
.
standard_error_message
.
meta_type
,
'DTML Method'
)
self
.
failUnless
(
hasattr
(
app
,
'_standard_objects_have_been_added'
))
self
.
assertTrue
(
hasattr
(
app
,
'_standard_objects_have_been_added'
))
def
test_suite
():
...
...
src/OFS/tests/testApplication.py
View file @
6220f215
...
...
@@ -24,7 +24,7 @@ class ApplicationTests(unittest.TestCase):
def
test_instance_attributes
(
self
):
app
=
self
.
_makeOne
()
self
.
failUnless
(
app
.
isTopLevelPrincipiaApplicationObject
)
self
.
assertTrue
(
app
.
isTopLevelPrincipiaApplicationObject
)
self
.
assertEqual
(
app
.
title
,
'Zope'
)
def
test_id_no_request
(
self
):
...
...
@@ -99,8 +99,8 @@ class ApplicationTests(unittest.TestCase):
result
=
app
.
__bobo_traverse__
(
request
,
'OTHER'
)
self
.
failUnless
(
isinstance
(
result
,
NullResource
))
self
.
failUnless
(
aq_parent
(
aq_inner
(
result
))
is
app
)
self
.
assertTrue
(
isinstance
(
result
,
NullResource
))
self
.
assertTrue
(
aq_parent
(
aq_inner
(
result
))
is
app
)
def
_noWay
(
self
,
key
,
default
=
None
):
raise
KeyError
(
key
)
...
...
src/OFS/tests/testCache.py
View file @
6220f215
...
...
@@ -25,13 +25,13 @@ class CacheTests(unittest.TestCase):
# To begin with, cache managers will be found correctly
# using managersExist
self
.
failUnless
(
managersExist
(
root
.
child
.
child_content
))
self
.
assertTrue
(
managersExist
(
root
.
child
.
child_content
))
# Now we delete the cache in the child folder
root
.
child
.
manage_delObjects
([
'child_cache'
])
# The parent_cache should still trigger managersExist
self
.
failUnless
(
managersExist
(
root
.
child
.
child_content
))
self
.
assertTrue
(
managersExist
(
root
.
child
.
child_content
))
def
test_suite
():
...
...
src/OFS/tests/testCopySupport.py
View file @
6220f215
...
...
@@ -140,56 +140,56 @@ class TestCopySupport( CopySupportTestBase ):
verifyClass
(
ICopySource
,
CopySource
)
def
testRename
(
self
):
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
folder1
.
manage_renameObject
(
id
=
'file'
,
new_id
=
'filex'
)
self
.
failIf
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failUnless
(
'filex'
in
self
.
folder1
.
objectIds
()
)
self
.
assertFalse
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'filex'
in
self
.
folder1
.
objectIds
()
)
def
testCopy
(
self
):
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failIf
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertFalse
(
'file'
in
self
.
folder2
.
objectIds
()
)
cookie
=
self
.
folder1
.
manage_copyObjects
(
ids
=
(
'file'
,)
)
self
.
folder2
.
manage_pasteObjects
(
cookie
)
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failUnless
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder2
.
objectIds
()
)
def
testCut
(
self
):
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failIf
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertFalse
(
'file'
in
self
.
folder2
.
objectIds
()
)
cookie
=
self
.
folder1
.
manage_cutObjects
(
ids
=
(
'file'
,)
)
self
.
folder2
.
manage_pasteObjects
(
cookie
)
self
.
failIf
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failUnless
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
assertFalse
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder2
.
objectIds
()
)
def
testCopyNewObject
(
self
):
self
.
failIf
(
'newfile'
in
self
.
folder1
.
objectIds
())
self
.
assertFalse
(
'newfile'
in
self
.
folder1
.
objectIds
())
manage_addFile
(
self
.
folder1
,
'newfile'
,
file
=
''
,
content_type
=
'text/plain'
)
cookie
=
self
.
folder1
.
manage_copyObjects
(
ids
=
(
'newfile'
,))
self
.
folder2
.
manage_pasteObjects
(
cookie
)
self
.
failUnless
(
'newfile'
in
self
.
folder1
.
objectIds
())
self
.
failUnless
(
'newfile'
in
self
.
folder2
.
objectIds
())
self
.
assertTrue
(
'newfile'
in
self
.
folder1
.
objectIds
())
self
.
assertTrue
(
'newfile'
in
self
.
folder2
.
objectIds
())
def
testPasteSingleNotSameID
(
self
):
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failIf
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertFalse
(
'file'
in
self
.
folder2
.
objectIds
()
)
cookie
=
self
.
folder1
.
manage_copyObjects
(
ids
=
(
'file'
,)
)
result
=
self
.
folder2
.
manage_pasteObjects
(
cookie
)
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failUnless
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
failUnless
(
result
==
[{
'id'
:
'file'
,
'new_id'
:
'file'
}])
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
result
==
[{
'id'
:
'file'
,
'new_id'
:
'file'
}])
def
testPasteSingleSameID
(
self
):
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failIf
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertFalse
(
'file'
in
self
.
folder2
.
objectIds
()
)
manage_addFile
(
self
.
folder2
,
'file'
,
file
=
''
,
content_type
=
'text/plain'
)
cookie
=
self
.
folder1
.
manage_copyObjects
(
ids
=
(
'file'
,)
)
result
=
self
.
folder2
.
manage_pasteObjects
(
cookie
)
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failUnless
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
failUnless
(
'copy_of_file'
in
self
.
folder2
.
objectIds
()
)
self
.
failUnless
(
result
==
[{
'id'
:
'file'
,
'new_id'
:
'copy_of_file'
}])
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
'copy_of_file'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
result
==
[{
'id'
:
'file'
,
'new_id'
:
'copy_of_file'
}])
def
testPasteSingleSameIDMultipleTimes
(
self
):
cookie
=
self
.
folder1
.
manage_copyObjects
(
ids
=
(
'file'
,))
...
...
@@ -229,57 +229,57 @@ class TestCopySupport( CopySupportTestBase ):
self
.
assertEqual
(
result
,
[{
'id'
:
'copy_of_'
,
'new_id'
:
'copy2_of_'
}])
def
testPasteMultiNotSameID
(
self
):
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failIf
(
'file1'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertFalse
(
'file1'
in
self
.
folder1
.
objectIds
()
)
manage_addFile
(
self
.
folder1
,
'file1'
,
file
=
''
,
content_type
=
'text/plain'
)
self
.
failIf
(
'file2'
in
self
.
folder1
.
objectIds
()
)
self
.
assertFalse
(
'file2'
in
self
.
folder1
.
objectIds
()
)
manage_addFile
(
self
.
folder1
,
'file2'
,
file
=
''
,
content_type
=
'text/plain'
)
self
.
failIf
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
failIf
(
'file1'
in
self
.
folder2
.
objectIds
()
)
self
.
failIf
(
'file2'
in
self
.
folder2
.
objectIds
()
)
self
.
assertFalse
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
assertFalse
(
'file1'
in
self
.
folder2
.
objectIds
()
)
self
.
assertFalse
(
'file2'
in
self
.
folder2
.
objectIds
()
)
cookie
=
self
.
folder1
.
manage_copyObjects
(
ids
=
(
'file'
,
'file1'
,
'file2'
,)
)
result
=
self
.
folder2
.
manage_pasteObjects
(
cookie
)
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failUnless
(
'file1'
in
self
.
folder1
.
objectIds
()
)
self
.
failUnless
(
'file2'
in
self
.
folder1
.
objectIds
()
)
self
.
failUnless
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
failUnless
(
'file1'
in
self
.
folder2
.
objectIds
()
)
self
.
failUnless
(
'file2'
in
self
.
folder2
.
objectIds
()
)
self
.
failUnless
(
result
==
[{
'id'
:
'file'
,
'new_id'
:
'file'
},
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file1'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file2'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
'file1'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
'file2'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
result
==
[{
'id'
:
'file'
,
'new_id'
:
'file'
},
{
'id'
:
'file1'
,
'new_id'
:
'file1'
},
{
'id'
:
'file2'
,
'new_id'
:
'file2'
}])
def
testPasteMultiSameID
(
self
):
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failIf
(
'file1'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertFalse
(
'file1'
in
self
.
folder1
.
objectIds
()
)
manage_addFile
(
self
.
folder1
,
'file1'
,
file
=
''
,
content_type
=
'text/plain'
)
self
.
failIf
(
'file2'
in
self
.
folder1
.
objectIds
()
)
self
.
assertFalse
(
'file2'
in
self
.
folder1
.
objectIds
()
)
manage_addFile
(
self
.
folder1
,
'file2'
,
file
=
''
,
content_type
=
'text/plain'
)
self
.
failIf
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
assertFalse
(
'file'
in
self
.
folder2
.
objectIds
()
)
manage_addFile
(
self
.
folder2
,
'file'
,
file
=
''
,
content_type
=
'text/plain'
)
self
.
failIf
(
'file1'
in
self
.
folder2
.
objectIds
()
)
self
.
assertFalse
(
'file1'
in
self
.
folder2
.
objectIds
()
)
manage_addFile
(
self
.
folder2
,
'file1'
,
file
=
''
,
content_type
=
'text/plain'
)
self
.
failIf
(
'file2'
in
self
.
folder2
.
objectIds
()
)
self
.
assertFalse
(
'file2'
in
self
.
folder2
.
objectIds
()
)
manage_addFile
(
self
.
folder2
,
'file2'
,
file
=
''
,
content_type
=
'text/plain'
)
cookie
=
self
.
folder1
.
manage_copyObjects
(
ids
=
(
'file'
,
'file1'
,
'file2'
,)
)
result
=
self
.
folder2
.
manage_pasteObjects
(
cookie
)
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failUnless
(
'file1'
in
self
.
folder1
.
objectIds
()
)
self
.
failUnless
(
'file2'
in
self
.
folder1
.
objectIds
()
)
self
.
failUnless
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
failUnless
(
'file1'
in
self
.
folder2
.
objectIds
()
)
self
.
failUnless
(
'file2'
in
self
.
folder2
.
objectIds
()
)
self
.
failUnless
(
'copy_of_file'
in
self
.
folder2
.
objectIds
()
)
self
.
failUnless
(
'copy_of_file1'
in
self
.
folder2
.
objectIds
()
)
self
.
failUnless
(
'copy_of_file2'
in
self
.
folder2
.
objectIds
()
)
self
.
failUnless
(
result
==
[{
'id'
:
'file'
,
'new_id'
:
'copy_of_file'
},
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file1'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file2'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
'file1'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
'file2'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
'copy_of_file'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
'copy_of_file1'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
'copy_of_file2'
in
self
.
folder2
.
objectIds
()
)
self
.
assertTrue
(
result
==
[{
'id'
:
'file'
,
'new_id'
:
'copy_of_file'
},
{
'id'
:
'file1'
,
'new_id'
:
'copy_of_file1'
},
{
'id'
:
'file2'
,
'new_id'
:
'copy_of_file2'
}])
...
...
@@ -386,14 +386,14 @@ class TestCopySupportSecurity( CopySupportTestBase ):
self
.
_initPolicyAndUser
()
self
.
failUnless
(
'file'
in
folder1
.
objectIds
()
)
self
.
failIf
(
'file'
in
folder2
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
folder1
.
objectIds
()
)
self
.
assertFalse
(
'file'
in
folder2
.
objectIds
()
)
cookie
=
folder1
.
manage_copyObjects
(
ids
=
(
'file'
,
)
)
folder2
.
manage_pasteObjects
(
cookie
)
self
.
failUnless
(
'file'
in
folder1
.
objectIds
()
)
self
.
failUnless
(
'file'
in
folder2
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
folder2
.
objectIds
()
)
def
test_copy_cant_read_source
(
self
):
...
...
@@ -433,16 +433,16 @@ class TestCopySupportSecurity( CopySupportTestBase ):
folder1
,
folder2
=
self
.
_initFolders
()
folder2
.
all_meta_types
=
FILE_META_TYPES
self
.
failUnless
(
'file'
in
folder1
.
objectIds
()
)
self
.
failIf
(
'file'
in
folder2
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
folder1
.
objectIds
()
)
self
.
assertFalse
(
'file'
in
folder2
.
objectIds
()
)
self
.
_initPolicyAndUser
()
cookie
=
folder1
.
manage_cutObjects
(
ids
=
(
'file'
,
)
)
folder2
.
manage_pasteObjects
(
cookie
)
self
.
failIf
(
'file'
in
folder1
.
objectIds
()
)
self
.
failUnless
(
'file'
in
folder2
.
objectIds
()
)
self
.
assertFalse
(
'file'
in
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
folder2
.
objectIds
()
)
def
test_move_cant_read_source
(
self
):
...
...
src/OFS/tests/testFileAndImage.py
View file @
6220f215
...
...
@@ -152,10 +152,10 @@ class FileTests(unittest.TestCase):
# Since we do the create here, let's test the events here too
self
.
assertEquals
(
1
,
len
(
self
.
eventCatcher
.
created
))
self
.
failUnless
(
aq_base
(
self
.
eventCatcher
.
created
[
0
].
object
)
is
aq_base
(
self
.
file
))
self
.
assertTrue
(
aq_base
(
self
.
eventCatcher
.
created
[
0
].
object
)
is
aq_base
(
self
.
file
))
self
.
assertEquals
(
1
,
len
(
self
.
eventCatcher
.
modified
))
self
.
failUnless
(
aq_base
(
self
.
eventCatcher
.
created
[
0
].
object
)
is
aq_base
(
self
.
file
))
self
.
assertTrue
(
aq_base
(
self
.
eventCatcher
.
created
[
0
].
object
)
is
aq_base
(
self
.
file
))
self
.
eventCatcher
.
reset
()
...
...
@@ -178,14 +178,14 @@ class FileTests(unittest.TestCase):
self
.
file
.
update_data
(
'foo'
)
self
.
assertEqual
(
self
.
file
.
size
,
3
)
self
.
assertEqual
(
self
.
file
.
data
,
'foo'
)
self
.
failUnless
(
ADummyCache
.
invalidated
)
self
.
failUnless
(
ADummyCache
.
set
)
self
.
assertTrue
(
ADummyCache
.
invalidated
)
self
.
assertTrue
(
ADummyCache
.
set
)
def
testReadData
(
self
):
s
=
"a"
*
(
2
<<
16
)
f
=
StringIO
(
s
)
data
,
size
=
self
.
file
.
_read_data
(
f
)
self
.
failUnless
(
isinstance
(
data
,
Pdata
))
self
.
assertTrue
(
isinstance
(
data
,
Pdata
))
self
.
assertEqual
(
str
(
data
),
s
)
self
.
assertEqual
(
len
(
s
),
len
(
str
(
data
)))
self
.
assertEqual
(
len
(
s
),
size
)
...
...
@@ -204,18 +204,18 @@ class FileTests(unittest.TestCase):
self
.
file
.
manage_edit
(
'foobar'
,
'text/plain'
,
filedata
=
'ASD'
)
self
.
assertEqual
(
self
.
file
.
title
,
'foobar'
)
self
.
assertEqual
(
self
.
file
.
content_type
,
'text/plain'
)
self
.
failUnless
(
ADummyCache
.
invalidated
)
self
.
failUnless
(
ADummyCache
.
set
)
self
.
assertTrue
(
ADummyCache
.
invalidated
)
self
.
assertTrue
(
ADummyCache
.
set
)
self
.
assertEquals
(
1
,
len
(
self
.
eventCatcher
.
modified
))
self
.
failUnless
(
self
.
eventCatcher
.
modified
[
0
].
object
is
self
.
file
)
self
.
assertTrue
(
self
.
eventCatcher
.
modified
[
0
].
object
is
self
.
file
)
def
testManageEditWithoutFileData
(
self
):
self
.
file
.
manage_edit
(
'foobar'
,
'text/plain'
)
self
.
assertEqual
(
self
.
file
.
title
,
'foobar'
)
self
.
assertEqual
(
self
.
file
.
content_type
,
'text/plain'
)
self
.
failUnless
(
ADummyCache
.
invalidated
)
self
.
assertTrue
(
ADummyCache
.
invalidated
)
self
.
assertEquals
(
1
,
len
(
self
.
eventCatcher
.
modified
))
self
.
failUnless
(
self
.
eventCatcher
.
modified
[
0
].
object
is
self
.
file
)
self
.
assertTrue
(
self
.
eventCatcher
.
modified
[
0
].
object
is
self
.
file
)
def
testManageUpload
(
self
):
f
=
StringIO
(
'jammyjohnson'
)
...
...
@@ -223,7 +223,7 @@ class FileTests(unittest.TestCase):
self
.
assertEqual
(
self
.
file
.
data
,
'jammyjohnson'
)
self
.
assertEqual
(
self
.
file
.
content_type
,
'application/octet-stream'
)
self
.
assertEquals
(
1
,
len
(
self
.
eventCatcher
.
modified
))
self
.
failUnless
(
self
.
eventCatcher
.
modified
[
0
].
object
is
self
.
file
)
self
.
assertTrue
(
self
.
eventCatcher
.
modified
[
0
].
object
is
self
.
file
)
def
testIfModSince
(
self
):
now
=
time
.
time
()
...
...
@@ -292,7 +292,7 @@ class FileTests(unittest.TestCase):
self
.
file
.
manage_edit
(
'foobar'
,
'text/plain'
,
filedata
=
'Now is the time for all good men to '
'come to the aid of the Party.'
)
self
.
failUnless
(
'Party'
in
self
.
file
.
PrincipiaSearchSource
())
self
.
assertTrue
(
'Party'
in
self
.
file
.
PrincipiaSearchSource
())
def
testFindFile
(
self
):
self
.
file
.
manage_edit
(
'foobar'
,
'text/plain'
,
...
...
@@ -328,8 +328,8 @@ class ImageTests(FileTests):
self
.
assertEqual
(
self
.
file
.
data
,
self
.
data
)
self
.
assertEqual
(
self
.
file
.
width
,
16
)
self
.
assertEqual
(
self
.
file
.
height
,
16
)
self
.
failUnless
(
ADummyCache
.
invalidated
)
self
.
failUnless
(
ADummyCache
.
set
)
self
.
assertTrue
(
ADummyCache
.
invalidated
)
self
.
assertTrue
(
ADummyCache
.
set
)
def
testStr
(
self
):
self
.
assertEqual
(
str
(
self
.
file
),
...
...
src/OFS/tests/testHistory.py
View file @
6220f215
...
...
@@ -70,14 +70,14 @@ class HistoryTests(unittest.TestCase):
self
.
assertEqual
(
len
(
entry
.
keys
()),
6
)
# the transactions are in newest-first order
self
.
assertEqual
(
entry
[
'description'
],
'Change %i'
%
(
3
-
i
))
self
.
failUnless
(
'key'
in
entry
)
self
.
assertTrue
(
'key'
in
entry
)
# lets not assume the size will stay the same forever
self
.
failUnless
(
'size'
in
entry
)
self
.
failUnless
(
'tid'
in
entry
)
self
.
failUnless
(
'time'
in
entry
)
self
.
assertTrue
(
'size'
in
entry
)
self
.
assertTrue
(
'tid'
in
entry
)
self
.
assertTrue
(
'time'
in
entry
)
if
i
:
# check times are increasing
self
.
failUnless
(
entry
[
'time'
]
<
r
[
i
-
1
][
'time'
])
self
.
assertTrue
(
entry
[
'time'
]
<
r
[
i
-
1
][
'time'
])
self
.
assertEqual
(
entry
[
'user_name'
],
''
)
def
test_manage_historyCopy
(
self
):
...
...
src/OFS/tests/testObjectManager.py
View file @
6220f215
...
...
@@ -284,20 +284,20 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
def
test_hasObject
(
self
):
om
=
self
.
_makeOne
()
self
.
failIf
(
om
.
hasObject
(
'_properties'
))
self
.
failIf
(
om
.
hasObject
(
'_getOb'
))
self
.
failIf
(
om
.
hasObject
(
'__of__'
))
self
.
failIf
(
om
.
hasObject
(
'.'
))
self
.
failIf
(
om
.
hasObject
(
'..'
))
self
.
failIf
(
om
.
hasObject
(
'aq_base'
))
self
.
assertFalse
(
om
.
hasObject
(
'_properties'
))
self
.
assertFalse
(
om
.
hasObject
(
'_getOb'
))
self
.
assertFalse
(
om
.
hasObject
(
'__of__'
))
self
.
assertFalse
(
om
.
hasObject
(
'.'
))
self
.
assertFalse
(
om
.
hasObject
(
'..'
))
self
.
assertFalse
(
om
.
hasObject
(
'aq_base'
))
om
.
zap__
=
True
self
.
failIf
(
om
.
hasObject
(
'zap__'
))
self
.
failIf
(
om
.
hasObject
(
'foo'
))
self
.
assertFalse
(
om
.
hasObject
(
'zap__'
))
self
.
assertFalse
(
om
.
hasObject
(
'foo'
))
si
=
SimpleItem
(
'foo'
)
om
.
_setObject
(
'foo'
,
si
)
self
.
assert_
(
om
.
hasObject
(
'foo'
))
om
.
_delObject
(
'foo'
)
self
.
failIf
(
om
.
hasObject
(
'foo'
))
self
.
assertFalse
(
om
.
hasObject
(
'foo'
))
def
test_setObject_checkId_ok
(
self
):
om
=
self
.
_makeOne
()
...
...
@@ -338,13 +338,13 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
si1
=
SimpleItem
(
'1'
)
si2
=
SimpleItem
(
'2'
)
om
[
'1'
]
=
si1
self
.
failUnless
(
'1'
in
om
)
self
.
failUnless
(
si1
in
om
.
objectValues
())
self
.
failUnless
(
'1'
in
om
.
objectIds
())
self
.
assertTrue
(
'1'
in
om
)
self
.
assertTrue
(
si1
in
om
.
objectValues
())
self
.
assertTrue
(
'1'
in
om
.
objectIds
())
om
[
'2'
]
=
si2
self
.
failUnless
(
'2'
in
om
)
self
.
failUnless
(
si2
in
om
.
objectValues
())
self
.
failUnless
(
'2'
in
om
.
objectIds
())
self
.
assertTrue
(
'2'
in
om
)
self
.
assertTrue
(
si2
in
om
.
objectValues
())
self
.
assertTrue
(
'2'
in
om
.
objectIds
())
self
.
assertRaises
(
BadRequest
,
om
.
_setObject
,
'1'
,
si2
)
self
.
assertRaises
(
BadRequest
,
om
.
__setitem__
,
'1'
,
si2
)
...
...
@@ -354,13 +354,13 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
si2
=
SimpleItem
(
'2'
)
om
[
'1'
]
=
si1
om
[
'2'
]
=
si2
self
.
failUnless
(
'1'
in
om
)
self
.
failUnless
(
'2'
in
om
)
self
.
assertTrue
(
'1'
in
om
)
self
.
assertTrue
(
'2'
in
om
)
del
om
[
'1'
]
self
.
failIf
(
'1'
in
om
)
self
.
failUnless
(
'2'
in
om
)
self
.
assertFalse
(
'1'
in
om
)
self
.
assertTrue
(
'2'
in
om
)
om
.
_delObject
(
'2'
)
self
.
failIf
(
'2'
in
om
)
self
.
assertFalse
(
'2'
in
om
)
def
test_iterator
(
self
):
om
=
self
.
_makeOne
()
...
...
@@ -369,11 +369,11 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
om
[
'1'
]
=
si1
om
[
'2'
]
=
si2
iterator
=
iter
(
om
)
self
.
failUnless
(
hasattr
(
iterator
,
'__iter__'
))
self
.
failUnless
(
hasattr
(
iterator
,
'next'
))
self
.
assertTrue
(
hasattr
(
iterator
,
'__iter__'
))
self
.
assertTrue
(
hasattr
(
iterator
,
'next'
))
result
=
[
i
for
i
in
iterator
]
self
.
failUnless
(
'1'
in
result
)
self
.
failUnless
(
'2'
in
result
)
self
.
assertTrue
(
'1'
in
result
)
self
.
assertTrue
(
'2'
in
result
)
def
test_len
(
self
):
om
=
self
.
_makeOne
()
...
...
@@ -381,80 +381,80 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
si2
=
SimpleItem
(
'2'
)
om
[
'1'
]
=
si1
om
[
'2'
]
=
si2
self
.
failUnless
(
len
(
om
)
==
2
)
self
.
assertTrue
(
len
(
om
)
==
2
)
def
test_nonzero
(
self
):
om
=
self
.
_makeOne
()
self
.
failUnless
(
om
)
self
.
assertTrue
(
om
)
def
test_get
(
self
):
om
=
self
.
_makeOne
()
si1
=
SimpleItem
(
'1'
)
self
.
assertRaises
(
BadRequest
,
om
.
__setitem__
,
'get'
,
si1
)
om
[
'1'
]
=
si1
self
.
failUnless
(
om
.
get
(
'1'
)
==
si1
)
self
.
assertTrue
(
om
.
get
(
'1'
)
==
si1
)
# A contained item overwrites the method
self
.
failUnless
(
hasattr
(
om
.
get
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
get
,
'im_func'
))
om
.
__dict__
[
'get'
]
=
si1
self
.
failUnless
(
aq_base
(
om
.
get
)
is
si1
)
self
.
failUnless
(
aq_base
(
om
[
'get'
])
is
si1
)
self
.
assertTrue
(
aq_base
(
om
.
get
)
is
si1
)
self
.
assertTrue
(
aq_base
(
om
[
'get'
])
is
si1
)
# Once the object is gone, the method is back
del
om
[
'get'
]
self
.
failUnless
(
hasattr
(
om
.
get
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
get
,
'im_func'
))
def
test_items
(
self
):
om
=
self
.
_makeOne
()
si1
=
SimpleItem
(
'1'
)
self
.
assertRaises
(
BadRequest
,
om
.
__setitem__
,
'items'
,
si1
)
om
[
'1'
]
=
si1
self
.
failUnless
((
'1'
,
si1
)
in
om
.
items
())
self
.
assertTrue
((
'1'
,
si1
)
in
om
.
items
())
# A contained item overwrites the method
self
.
failUnless
(
hasattr
(
om
.
items
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
items
,
'im_func'
))
om
.
__dict__
[
'items'
]
=
si1
self
.
failUnless
(
aq_base
(
om
.
items
)
is
si1
)
self
.
failUnless
(
aq_base
(
om
[
'items'
])
is
si1
)
self
.
assertTrue
(
aq_base
(
om
.
items
)
is
si1
)
self
.
assertTrue
(
aq_base
(
om
[
'items'
])
is
si1
)
# Once the object is gone, the method is back
del
om
[
'items'
]
self
.
failUnless
(
hasattr
(
om
.
items
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
items
,
'im_func'
))
def
test_keys
(
self
):
om
=
self
.
_makeOne
()
si1
=
SimpleItem
(
'1'
)
self
.
assertRaises
(
BadRequest
,
om
.
__setitem__
,
'keys'
,
si1
)
om
[
'1'
]
=
si1
self
.
failUnless
(
'1'
in
om
.
keys
())
self
.
assertTrue
(
'1'
in
om
.
keys
())
# A contained item overwrites the method
self
.
failUnless
(
hasattr
(
om
.
keys
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
keys
,
'im_func'
))
om
.
__dict__
[
'keys'
]
=
si1
self
.
failUnless
(
aq_base
(
om
.
keys
)
is
si1
)
self
.
failUnless
(
aq_base
(
om
[
'keys'
])
is
si1
)
self
.
assertTrue
(
aq_base
(
om
.
keys
)
is
si1
)
self
.
assertTrue
(
aq_base
(
om
[
'keys'
])
is
si1
)
# Once the object is gone, the method is back
del
om
[
'keys'
]
self
.
failUnless
(
hasattr
(
om
.
keys
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
keys
,
'im_func'
))
def
test_values
(
self
):
om
=
self
.
_makeOne
()
si1
=
SimpleItem
(
'1'
)
self
.
assertRaises
(
BadRequest
,
om
.
__setitem__
,
'values'
,
si1
)
om
[
'1'
]
=
si1
self
.
failUnless
(
si1
in
om
.
values
())
self
.
assertTrue
(
si1
in
om
.
values
())
# A contained item overwrites the method
self
.
failUnless
(
hasattr
(
om
.
values
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
values
,
'im_func'
))
om
.
__dict__
[
'values'
]
=
si1
self
.
failUnless
(
aq_base
(
om
.
values
)
is
si1
)
self
.
failUnless
(
aq_base
(
om
[
'values'
])
is
si1
)
self
.
assertTrue
(
aq_base
(
om
.
values
)
is
si1
)
self
.
assertTrue
(
aq_base
(
om
[
'values'
])
is
si1
)
# Once the object is gone, the method is back
del
om
[
'values'
]
self
.
failUnless
(
hasattr
(
om
.
values
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
values
,
'im_func'
))
def
test_list_imports
(
self
):
om
=
self
.
_makeOne
()
# This must work whether we've done "make instance" or not.
# So list_imports() may return an empty list, or whatever's
# in skel/import. Tolerate both cases.
self
.
failUnless
(
isinstance
(
om
.
list_imports
(),
list
))
self
.
assertTrue
(
isinstance
(
om
.
list_imports
(),
list
))
for
filename
in
om
.
list_imports
():
self
.
failUnless
(
filename
.
endswith
(
'.zexp'
)
or
self
.
assertTrue
(
filename
.
endswith
(
'.zexp'
)
or
filename
.
endswith
(
'.xml'
))
def
test_suite
():
...
...
src/OFS/tests/testProperties.py
View file @
6220f215
...
...
@@ -37,20 +37,20 @@ class TestPropertyManager(unittest.TestCase):
inst
=
self
.
_makeOne
()
inst
.
_setProperty
(
'prop'
,
[
'xxx'
,
'yyy'
],
'lines'
)
self
.
failUnless
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
failUnless
(
type
(
inst
.
prop
)
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
prop
)
==
type
(()))
inst
.
_setPropValue
(
'prop'
,
[
'xxx'
,
'yyy'
])
self
.
failUnless
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
failUnless
(
type
(
inst
.
prop
)
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
prop
)
==
type
(()))
inst
.
_updateProperty
(
'prop'
,
[
'xxx'
,
'yyy'
])
self
.
failUnless
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
failUnless
(
type
(
inst
.
prop
)
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
prop
)
==
type
(()))
inst
.
manage_addProperty
(
'prop2'
,
[
'xxx'
,
'yyy'
],
'lines'
)
self
.
failUnless
(
type
(
inst
.
getProperty
(
'prop2'
))
==
type
(()))
self
.
failUnless
(
type
(
inst
.
prop2
)
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
getProperty
(
'prop2'
))
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
prop2
)
==
type
(()))
def
test_propertyLabel_no_label_falls_back_to_id
(
self
):
class
NoLabel
(
self
.
_getTargetClass
()):
...
...
@@ -99,16 +99,16 @@ class TestPropertySheet(unittest.TestCase):
inst
=
self
.
_makeOne
(
'foo'
)
inst
.
_setProperty
(
'prop'
,
[
'xxx'
,
'yyy'
],
'lines'
)
self
.
failUnless
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
failUnless
(
type
(
inst
.
prop
)
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
prop
)
==
type
(()))
inst
.
_updateProperty
(
'prop'
,
[
'xxx'
,
'yyy'
])
self
.
failUnless
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
failUnless
(
type
(
inst
.
prop
)
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
prop
)
==
type
(()))
inst
.
manage_addProperty
(
'prop2'
,
[
'xxx'
,
'yyy'
],
'lines'
)
self
.
failUnless
(
type
(
inst
.
getProperty
(
'prop2'
))
==
type
(()))
self
.
failUnless
(
type
(
inst
.
prop2
)
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
getProperty
(
'prop2'
))
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
prop2
)
==
type
(()))
def
test_dav__propstat_nullns
(
self
):
# Tests 15 (propnullns) and 16 (propget) from the props suite
...
...
src/OFS/tests/testRanges.py
View file @
6220f215
...
...
@@ -121,17 +121,17 @@ class TestRequestRange(unittest.TestCase):
body
=
self
.
doGET
(
req
,
rsp
)
self
.
failUnless
(
rsp
.
getStatus
()
==
416
,
self
.
assertTrue
(
rsp
.
getStatus
()
==
416
,
'Expected a 416 status, got %s'
%
rsp
.
getStatus
())
expect_content_range
=
'bytes */%d'
%
len
(
self
.
data
)
content_range
=
rsp
.
getHeader
(
'content-range'
)
self
.
failIf
(
content_range
is
None
,
'No Content-Range header was set!'
)
self
.
failUnless
(
content_range
==
expect_content_range
,
self
.
assertFalse
(
content_range
is
None
,
'No Content-Range header was set!'
)
self
.
assertTrue
(
content_range
==
expect_content_range
,
'Received incorrect Content-Range header. Expected %s, got %s'
%
(
`expect_content_range`
,
`content_range`
))
self
.
failUnless
(
body
==
''
,
'index_html returned %s'
%
`body`
)
self
.
assertTrue
(
body
==
''
,
'index_html returned %s'
%
`body`
)
def
expectOK
(
self
,
rangeHeader
,
if_range
=
None
):
req
=
self
.
app
.
REQUEST
...
...
@@ -144,7 +144,7 @@ class TestRequestRange(unittest.TestCase):
body
=
self
.
doGET
(
req
,
rsp
)
self
.
failUnless
(
rsp
.
getStatus
()
==
200
,
self
.
assertTrue
(
rsp
.
getStatus
()
==
200
,
'Expected a 200 status, got %s'
%
rsp
.
getStatus
())
def
expectSingleRange
(
self
,
range
,
start
,
end
,
if_range
=
None
):
...
...
@@ -158,21 +158,21 @@ class TestRequestRange(unittest.TestCase):
body
=
self
.
doGET
(
req
,
rsp
)
self
.
failUnless
(
rsp
.
getStatus
()
==
206
,
self
.
assertTrue
(
rsp
.
getStatus
()
==
206
,
'Expected a 206 status, got %s'
%
rsp
.
getStatus
())
expect_content_range
=
'bytes %d-%d/%d'
%
(
start
,
end
-
1
,
len
(
self
.
data
))
content_range
=
rsp
.
getHeader
(
'content-range'
)
self
.
failIf
(
content_range
is
None
,
'No Content-Range header was set!'
)
self
.
failUnless
(
content_range
==
expect_content_range
,
self
.
assertFalse
(
content_range
is
None
,
'No Content-Range header was set!'
)
self
.
assertTrue
(
content_range
==
expect_content_range
,
'Received incorrect Content-Range header. Expected %s, got %s'
%
(
`expect_content_range`
,
`content_range`
))
self
.
failIf
(
rsp
.
getHeader
(
'content-length'
)
!=
str
(
len
(
body
)),
self
.
assertFalse
(
rsp
.
getHeader
(
'content-length'
)
!=
str
(
len
(
body
)),
'Incorrect Content-Length is set! Expected %s, got %s.'
%
(
str
(
len
(
body
)),
rsp
.
getHeader
(
'content-length'
)))
self
.
failUnless
(
body
==
self
.
data
[
start
:
end
],
self
.
assertTrue
(
body
==
self
.
data
[
start
:
end
],
'Incorrect range returned, expected %s, got %s'
%
(
`self.data[start:end]`
,
`body`
))
...
...
@@ -192,18 +192,18 @@ class TestRequestRange(unittest.TestCase):
body
=
self
.
doGET
(
req
,
rsp
)
self
.
failUnless
(
rsp
.
getStatus
()
==
206
,
self
.
assertTrue
(
rsp
.
getStatus
()
==
206
,
'Expected a 206 status, got %s'
%
rsp
.
getStatus
())
self
.
failIf
(
rsp
.
getHeader
(
'content-range'
),
self
.
assertFalse
(
rsp
.
getHeader
(
'content-range'
),
'The Content-Range header should not be set!'
)
ct
=
rsp
.
getHeader
(
'content-type'
).
split
(
';'
)[
0
]
draftprefix
=
draft
and
'x-'
or
''
self
.
failIf
(
ct
!=
'multipart/%sbyteranges'
%
draftprefix
,
self
.
assertFalse
(
ct
!=
'multipart/%sbyteranges'
%
draftprefix
,
"Incorrect Content-Type set. Expected 'multipart/%sbyteranges', "
"got %s"
%
(
draftprefix
,
ct
))
if
rsp
.
getHeader
(
'content-length'
):
self
.
failIf
(
rsp
.
getHeader
(
'content-length'
)
!=
str
(
len
(
body
)),
self
.
assertFalse
(
rsp
.
getHeader
(
'content-length'
)
!=
str
(
len
(
body
)),
'Incorrect Content-Length is set! Expected %s, got %s.'
%
(
str
(
len
(
body
)),
rsp
.
getHeader
(
'content-length'
)))
...
...
@@ -224,23 +224,23 @@ class TestRequestRange(unittest.TestCase):
start
,
end
,
size
=
int
(
start
),
int
(
end
),
int
(
size
)
end
=
end
+
1
self
.
failIf
(
size
!=
len
(
self
.
data
),
self
.
assertFalse
(
size
!=
len
(
self
.
data
),
'Part Content-Range header reported incorrect length. '
'Expected %d, got %d.'
%
(
len
(
self
.
data
),
size
))
body
=
part
.
get_payload
()
self
.
failIf
(
len
(
body
)
!=
end
-
start
,
self
.
assertFalse
(
len
(
body
)
!=
end
-
start
,
'Part (%d, %d) is of wrong length, expected %d, got %d.'
%
(
start
,
end
,
end
-
start
,
len
(
body
)))
self
.
failIf
(
body
!=
self
.
data
[
start
:
end
],
self
.
assertFalse
(
body
!=
self
.
data
[
start
:
end
],
'Part (%d, %d) has incorrect data. Expected %s, got %s.'
%
(
start
,
end
,
`self.data[start:end]`
,
`body`
))
add
((
start
,
end
))
# Copmare the ranges used with the expected range sets.
self
.
failIf
(
returnedRanges
!=
sets
,
self
.
assertFalse
(
returnedRanges
!=
sets
,
'Got unexpected sets, expected %s, got %s'
%
(
sets
,
returnedRanges
))
...
...
src/OFS/tests/testSimpleItem.py
View file @
6220f215
...
...
@@ -40,8 +40,8 @@ class TestItem(unittest.TestCase):
import
sys
self
.
assertEqual
(
sys
.
exc_info
()[
0
],
OverflowError
)
value
=
sys
.
exc_info
()[
1
]
self
.
failUnless
(
value
.
message
.
startswith
(
"'simple'"
))
self
.
failUnless
(
'full details: testing'
in
value
.
message
)
self
.
assertTrue
(
value
.
message
.
startswith
(
"'simple'"
))
self
.
assertTrue
(
'full details: testing'
in
value
.
message
)
def
test_raise_StandardErrorMessage_TaintedString_errorValue
(
self
):
from
AccessControl.tainted
import
TaintedString
...
...
@@ -62,7 +62,7 @@ class TestItem(unittest.TestCase):
import
sys
self
.
assertEqual
(
sys
.
exc_info
()[
0
],
OverflowError
)
value
=
sys
.
exc_info
()[
1
]
self
.
failIf
(
'<'
in
value
.
message
)
self
.
assertFalse
(
'<'
in
value
.
message
)
class
TestItem_w__name__
(
unittest
.
TestCase
):
...
...
src/OFS/tests/testTraverse.py
View file @
6220f215
...
...
@@ -229,23 +229,23 @@ class TestTraverse( unittest.TestCase ):
verifyClass
(
ITraversable
,
Traversable
)
def
testTraversePath
(
self
):
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failUnless
(
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
self
.
folder1
.
unrestrictedTraverse
(
(
''
,
'folder1'
,
'file'
)
))
self
.
failUnless
(
self
.
assertTrue
(
self
.
folder1
.
unrestrictedTraverse
(
(
''
,
'folder1'
)
))
def
testTraverseURLNoSlash
(
self
):
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failUnless
(
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
self
.
folder1
.
unrestrictedTraverse
(
'/folder1/file'
))
self
.
failUnless
(
self
.
assertTrue
(
self
.
folder1
.
unrestrictedTraverse
(
'/folder1'
))
def
testTraverseURLSlash
(
self
):
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
())
self
.
failUnless
(
self
.
folder1
.
unrestrictedTraverse
(
'/folder1/file/'
))
self
.
failUnless
(
self
.
folder1
.
unrestrictedTraverse
(
'/folder1/'
))
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
())
self
.
assertTrue
(
self
.
folder1
.
unrestrictedTraverse
(
'/folder1/file/'
))
self
.
assertTrue
(
self
.
folder1
.
unrestrictedTraverse
(
'/folder1/'
))
def
testTraverseToNone
(
self
):
self
.
failUnlessRaises
(
...
...
@@ -279,7 +279,7 @@ class TestTraverse( unittest.TestCase ):
# Verify it's possible to use __bobo_traverse__ to a method.
self
.
_setupSecurity
()
bb
=
self
.
_makeBoboTraversable
()
self
.
failUnless
(
self
.
assertTrue
(
bb
.
restrictedTraverse
(
'bb_method'
)
is
not
bb
.
bb_method
)
def
testBoboTraverseToSimpleAttrValue
(
self
):
...
...
@@ -296,7 +296,7 @@ class TestTraverse( unittest.TestCase ):
# is fine, but to test the code branch we sub in the forgiving one
self
.
_setupSecurity
(
UnitTestSecurityPolicy
())
bb
=
self
.
_makeBoboTraversable
()
self
.
failUnless
(
self
.
assertTrue
(
bb
.
restrictedTraverse
(
'manufactured'
)
is
42
)
def
testBoboTraverseToAcquiredObject
(
self
):
...
...
@@ -412,13 +412,13 @@ class TestTraverse( unittest.TestCase ):
def
testTraverseUp
(
self
):
# Test that we can traverse upwards
from
Acquisition
import
aq_base
self
.
failUnless
(
self
.
assertTrue
(
aq_base
(
self
.
root
.
folder1
.
file
.
restrictedTraverse
(
'../..'
))
is
aq_base
(
self
.
root
))
def
testTraverseToNameStartingWithPlus
(
self
):
# Verify it's possible to traverse to a name such as +something
self
.
failUnless
(
self
.
assertTrue
(
self
.
folder1
.
unrestrictedTraverse
(
'+something'
)
is
'plus'
)
...
...
src/OFS/tests/test_DTMLDocument.py
View file @
6220f215
...
...
@@ -24,9 +24,9 @@ class FactoryTests(unittest.TestCase):
dispatcher
=
DummyDispatcher
()
addDTMLDocument
(
dispatcher
,
'id'
)
method
=
dispatcher
.
_set
[
'id'
]
self
.
failUnless
(
isinstance
(
method
,
DTMLDocument
))
self
.
failIf
(
'standard_html_header'
in
method
.
read
())
self
.
failIf
(
'standard_html_footer'
in
method
.
read
())
self
.
assertTrue
(
isinstance
(
method
,
DTMLDocument
))
self
.
assertFalse
(
'standard_html_header'
in
method
.
read
())
self
.
assertFalse
(
'standard_html_footer'
in
method
.
read
())
class
DummyDispatcher
:
...
...
src/OFS/tests/test_DTMLMethod.py
View file @
6220f215
...
...
@@ -33,9 +33,9 @@ class FactoryTests(unittest.TestCase):
dispatcher
=
DummyDispatcher
()
addDTMLMethod
(
dispatcher
,
'id'
)
method
=
dispatcher
.
_set
[
'id'
]
self
.
failUnless
(
isinstance
(
method
,
DTMLMethod
))
self
.
failIf
(
'standard_html_header'
in
method
.
read
())
self
.
failIf
(
'standard_html_footer'
in
method
.
read
())
self
.
assertTrue
(
isinstance
(
method
,
DTMLMethod
))
self
.
assertFalse
(
'standard_html_header'
in
method
.
read
())
self
.
assertFalse
(
'standard_html_footer'
in
method
.
read
())
class
DummyDispatcher
:
...
...
src/OFS/tests/test_Uninstalled.py
View file @
6220f215
...
...
@@ -52,7 +52,7 @@ class TestsOfBroken(unittest.TestCase):
klass
=
Broken
(
self
,
None
,
(
'some.python.module'
,
'MyClass'
))
self
.
failUnless
(
issubclass
(
klass
,
BrokenClass
))
self
.
assertTrue
(
issubclass
(
klass
,
BrokenClass
))
self
.
assertEqual
(
klass
.
__name__
,
'MyClass'
)
self
.
assertEqual
(
klass
.
__module__
,
'some.python.module'
)
self
.
assertEqual
(
klass
.
product_name
,
'unknown'
)
...
...
@@ -63,7 +63,7 @@ class TestsOfBroken(unittest.TestCase):
klass
=
Broken
(
self
,
None
,
(
'Products.MyProduct.MyClass'
,
'MyClass'
))
self
.
failUnless
(
issubclass
(
klass
,
BrokenClass
))
self
.
assertTrue
(
issubclass
(
klass
,
BrokenClass
))
self
.
assertEqual
(
klass
.
__name__
,
'MyClass'
)
self
.
assertEqual
(
klass
.
__module__
,
'Products.MyProduct.MyClass'
)
self
.
assertEqual
(
klass
.
product_name
,
'MyProduct'
)
...
...
@@ -75,8 +75,8 @@ class TestsOfBroken(unittest.TestCase):
inst
=
Broken
(
self
,
OID
,
(
'Products.MyProduct.MyClass'
,
'MyClass'
))
self
.
failUnless
(
isinstance
(
inst
,
BrokenClass
))
self
.
failUnless
(
inst
.
_p_jar
is
self
)
self
.
assertTrue
(
isinstance
(
inst
,
BrokenClass
))
self
.
assertTrue
(
inst
.
_p_jar
is
self
)
self
.
assertEqual
(
inst
.
_p_oid
,
OID
)
klass
=
inst
.
__class__
...
...
@@ -130,7 +130,7 @@ class TestsIntegratedBroken(base.TestCase):
# get new connection that will give access to broken object
app
=
base
.
app
()
inst
=
aq_base
(
app
.
tr
)
self
.
failUnless
(
isinstance
(
inst
,
BrokenClass
))
self
.
assertTrue
(
isinstance
(
inst
,
BrokenClass
))
state
=
inst
.
__getstate__
()
self
.
assertEqual
(
state
,
{
'id'
:
'tr'
})
...
...
@@ -139,7 +139,7 @@ class TestsIntegratedBroken(base.TestCase):
transaction
.
commit
()
# check that object is not left over
app
=
base
.
app
()
self
.
failIf
(
'tr'
in
app
.
objectIds
())
self
.
assertFalse
(
'tr'
in
app
.
objectIds
())
def
test_suite
():
...
...
src/OFS/tests/test_XMLExportImport.py
View file @
6220f215
...
...
@@ -63,7 +63,7 @@ class XMLExportImportTests(unittest.TestCase):
stream
.
seek
(
0
)
newobj
=
importXML
(
connection
,
stream
)
self
.
failUnless
(
isinstance
(
newobj
,
DTMLMethod
))
self
.
assertTrue
(
isinstance
(
newobj
,
DTMLMethod
))
self
.
assertEqual
(
newobj
.
read
(),
dm
.
read
())
def
test_export_import_as_file_idempotent
(
self
):
...
...
@@ -84,7 +84,7 @@ class XMLExportImportTests(unittest.TestCase):
data
=
exportXML
(
connection
,
oid
,
ostream
)
ostream
.
close
()
newobj
=
importXML
(
connection
,
path
)
self
.
failUnless
(
isinstance
(
newobj
,
DTMLMethod
))
self
.
assertTrue
(
isinstance
(
newobj
,
DTMLMethod
))
self
.
assertEqual
(
newobj
.
read
(),
dm
.
read
())
finally
:
# if this operaiton fails with a 'Permission Denied' error,
...
...
src/OFS/tests/test_userfolder.py
View file @
6220f215
...
...
@@ -80,29 +80,29 @@ class UserFolderTests(unittest.TestCase):
user
=
uf
.
getUser
(
'user1'
)
app
.
manage_addLocalRoles
(
'user1'
,
[
'Owner'
])
roles
=
user
.
getRolesInContext
(
app
)
self
.
failUnless
(
'role1'
in
roles
)
self
.
failUnless
(
'Owner'
in
roles
)
self
.
assertTrue
(
'role1'
in
roles
)
self
.
assertTrue
(
'Owner'
in
roles
)
def
testHasRole
(
self
):
app
=
self
.
_makeApp
()
uf
=
self
.
_makeOne
(
app
)
user
=
uf
.
getUser
(
'user1'
)
self
.
failUnless
(
user
.
has_role
(
'role1'
,
app
))
self
.
assertTrue
(
user
.
has_role
(
'role1'
,
app
))
def
testHasLocalRole
(
self
):
app
=
self
.
_makeApp
()
uf
=
self
.
_makeOne
(
app
)
user
=
uf
.
getUser
(
'user1'
)
app
.
manage_addLocalRoles
(
'user1'
,
[
'Owner'
])
self
.
failUnless
(
user
.
has_role
(
'Owner'
,
app
))
self
.
assertTrue
(
user
.
has_role
(
'Owner'
,
app
))
def
testHasPermission
(
self
):
app
=
self
.
_makeApp
()
uf
=
self
.
_makeOne
(
app
)
user
=
uf
.
getUser
(
'user1'
)
self
.
failUnless
(
user
.
has_permission
(
'View'
,
app
))
self
.
assertTrue
(
user
.
has_permission
(
'View'
,
app
))
app
.
manage_role
(
'role1'
,
[
'Add Folders'
])
self
.
failUnless
(
user
.
has_permission
(
'Add Folders'
,
app
))
self
.
assertTrue
(
user
.
has_permission
(
'Add Folders'
,
app
))
def
testHasLocalRolePermission
(
self
):
app
=
self
.
_makeApp
()
...
...
@@ -110,13 +110,13 @@ class UserFolderTests(unittest.TestCase):
user
=
uf
.
getUser
(
'user1'
)
app
.
manage_role
(
'Owner'
,
[
'Add Folders'
])
app
.
manage_addLocalRoles
(
'user1'
,
[
'Owner'
])
self
.
failUnless
(
user
.
has_permission
(
'Add Folders'
,
app
))
self
.
assertTrue
(
user
.
has_permission
(
'Add Folders'
,
app
))
def
testAuthenticate
(
self
):
app
=
self
.
_makeApp
()
uf
=
self
.
_makeOne
(
app
)
user
=
uf
.
getUser
(
'user1'
)
self
.
failUnless
(
user
.
authenticate
(
'secret'
,
app
.
REQUEST
))
self
.
assertTrue
(
user
.
authenticate
(
'secret'
,
app
.
REQUEST
))
def
testValidate
(
self
):
app
=
self
.
_makeApp
()
...
...
src/Products/Five/browser/tests/pages_ftest.txt
View file @
6220f215
...
...
@@ -79,7 +79,7 @@ Unauthorized:
... response = self.publish('/test_folder_1_/testoid/%s' % view_name,
... basic='viewer:secret')
... status = response.getStatus()
... self.
failUnless
(status == 401, (status, 401, view_name))
... self.
assertTrue
(status == 401, (status, 401, view_name))
Methods of views which were not explicitly declared as allowed should not be
accessible TTW, even if we have the permission to render the view:
...
...
@@ -101,7 +101,7 @@ except 'View management screens':
... response = self.publish('/test_folder_1_/testoid/%s' % view_name,
... basic='viewer:secret')
... status = response.getStatus()
... self.
failUnless
(status == 401, (status, 401, view_name))
... self.
assertTrue
(status == 401, (status, 401, view_name))
If we grant 'View management screens' now, the protected views should
become viewable:
...
...
@@ -111,7 +111,7 @@ become viewable:
... response = self.publish('/test_folder_1_/testoid/%s' % view_name,
... basic='viewer:secret')
... status = response.getStatus()
... self.
failUnless
(status == 200, (status, 200, view_name))
... self.
assertTrue
(status == 200, (status, 200, view_name))
Managers should always be able to view anything, including proctected
stuff:
...
...
@@ -126,7 +126,7 @@ All public views should always be accessible by anyone:
>>> for view_name in public_view_names:
... response = self.publish('/test_folder_1_/testoid/%s' % view_name)
... status = response.getStatus()
... self.
failUnless
(status == 200, (status, 200, view_name))
... self.
assertTrue
(status == 200, (status, 200, view_name))
...
...
src/Products/Five/browser/tests/test_metaconfigure.py
View file @
6220f215
...
...
@@ -33,47 +33,47 @@ class ViewMixinForTemplatesTests(unittest.TestCase):
request
=
DummyRequest
()
view
=
self
.
_makeOne
(
request
=
request
)
index
=
view
.
index
=
DummyTemplate
()
self
.
failUnless
(
view
.
publishTraverse
(
request
,
'index.html'
)
is
index
)
self
.
assertTrue
(
view
.
publishTraverse
(
request
,
'index.html'
)
is
index
)
def
test___getitem___uses_index_macros
(
self
):
view
=
self
.
_makeOne
()
view
.
index
=
index
=
DummyTemplate
()
index
.
macros
=
{}
index
.
macros
[
'aaa'
]
=
aaa
=
object
()
self
.
failUnless
(
view
[
'aaa'
]
is
aaa
)
self
.
assertTrue
(
view
[
'aaa'
]
is
aaa
)
def
test__getitem__gives_shortcut_to_index_macros
(
self
):
view
=
self
.
_makeOne
()
view
.
index
=
index
=
DummyTemplate
()
index
.
macros
=
{}
self
.
failUnless
(
view
[
'macros'
]
is
index
.
macros
)
self
.
assertTrue
(
view
[
'macros'
]
is
index
.
macros
)
def
test___call___no_args_no_kw
(
self
):
view
=
self
.
_makeOne
()
view
.
index
=
index
=
DummyTemplate
()
result
=
view
()
self
.
failUnless
(
result
is
index
)
self
.
assertTrue
(
result
is
index
)
self
.
assertEqual
(
index
.
_called_with
,
((),
{}))
def
test___call___w_args_no_kw
(
self
):
view
=
self
.
_makeOne
()
view
.
index
=
index
=
DummyTemplate
()
result
=
view
(
'abc'
)
self
.
failUnless
(
result
is
index
)
self
.
assertTrue
(
result
is
index
)
self
.
assertEqual
(
index
.
_called_with
,
((
'abc'
,),
{}))
def
test___call___no_args_w_kw
(
self
):
view
=
self
.
_makeOne
()
view
.
index
=
index
=
DummyTemplate
()
result
=
view
(
foo
=
'bar'
)
self
.
failUnless
(
result
is
index
)
self
.
assertTrue
(
result
is
index
)
self
.
assertEqual
(
index
.
_called_with
,
((),
{
'foo'
:
'bar'
}))
def
test___call___w_args_w_kw
(
self
):
view
=
self
.
_makeOne
()
view
.
index
=
index
=
DummyTemplate
()
result
=
view
(
'abc'
,
foo
=
'bar'
)
self
.
failUnless
(
result
is
index
)
self
.
assertTrue
(
result
is
index
)
self
.
assertEqual
(
index
.
_called_with
,
((
'abc'
,),
{
'foo'
:
'bar'
}))
...
...
src/Products/Five/browser/tests/test_pagetemplatefile.py
View file @
6220f215
...
...
@@ -69,17 +69,17 @@ class ViewPageTemplateFileTests(unittest.TestCase):
view
=
self
.
_makeView
(
context
,
request
)
vptf
=
self
.
_makeOne
(
'seagull.pt'
)
namespace
=
vptf
.
pt_getContext
(
view
,
request
)
self
.
failUnless
(
namespace
[
'context'
]
is
context
)
self
.
failUnless
(
namespace
[
'request'
]
is
request
)
self
.
assertTrue
(
namespace
[
'context'
]
is
context
)
self
.
assertTrue
(
namespace
[
'request'
]
is
request
)
views
=
namespace
[
'views'
]
self
.
failUnless
(
isinstance
(
views
,
ViewMapper
))
self
.
assertTrue
(
isinstance
(
views
,
ViewMapper
))
self
.
assertEqual
(
views
.
ob
,
context
)
self
.
assertEqual
(
views
.
request
,
request
)
self
.
failUnless
(
namespace
[
'here'
]
is
context
)
self
.
failUnless
(
namespace
[
'container'
]
is
context
)
self
.
failUnless
(
namespace
[
'root'
]
is
None
)
self
.
assertTrue
(
namespace
[
'here'
]
is
context
)
self
.
assertTrue
(
namespace
[
'container'
]
is
context
)
self
.
assertTrue
(
namespace
[
'root'
]
is
None
)
modules
=
namespace
[
'modules'
]
self
.
failUnless
(
modules
is
SecureModuleImporter
)
self
.
assertTrue
(
modules
is
SecureModuleImporter
)
self
.
assertEqual
(
namespace
[
'traverse_subpath'
],
[])
self
.
assertEqual
(
namespace
[
'user'
].
getId
(),
'a_user'
)
...
...
@@ -95,7 +95,7 @@ class ViewPageTemplateFileTests(unittest.TestCase):
view
=
self
.
_makeView
(
context
,
request
)
vptf
=
self
.
_makeOne
(
'seagull.pt'
)
namespace
=
vptf
.
pt_getContext
(
view
,
request
)
self
.
failUnless
(
namespace
[
'root'
]
is
root
)
self
.
assertTrue
(
namespace
[
'root'
]
is
root
)
def
test_pt_getContext_w_ignored_kw
(
self
):
from
Products.Five.browser.pagetemplatefile
import
ViewMapper
...
...
@@ -107,8 +107,8 @@ class ViewPageTemplateFileTests(unittest.TestCase):
view
=
self
.
_makeView
(
context
,
request
)
vptf
=
self
.
_makeOne
(
'seagull.pt'
)
namespace
=
vptf
.
pt_getContext
(
view
,
request
,
foo
=
'bar'
)
self
.
failIf
(
'foo'
in
namespace
)
self
.
failIf
(
'foo'
in
namespace
[
'options'
])
self
.
assertFalse
(
'foo'
in
namespace
)
self
.
assertFalse
(
'foo'
in
namespace
[
'options'
])
def
test_pt_getContext_w_args_kw
(
self
):
from
Products.Five.browser.pagetemplatefile
import
ViewMapper
...
...
@@ -166,9 +166,9 @@ class ViewPageTemplateFileTests(unittest.TestCase):
request
=
DummyRequest
()
foo
=
Foo
(
context
,
request
)
bound
=
foo
.
bar
self
.
failUnless
(
isinstance
(
bound
,
BoundPageTemplate
))
self
.
failUnless
(
bound
.
im_func
is
template
)
self
.
failUnless
(
bound
.
im_self
is
foo
)
self
.
assertTrue
(
isinstance
(
bound
,
BoundPageTemplate
))
self
.
assertTrue
(
bound
.
im_func
is
template
)
self
.
assertTrue
(
bound
.
im_self
is
foo
)
class
ViewMapperTests
(
unittest
.
TestCase
):
...
...
@@ -203,7 +203,7 @@ class ViewMapperTests(unittest.TestCase):
return
self
provideAdapter
(
_adapt
,
(
None
,
None
),
Interface
,
name
=
'test'
)
mapper
=
self
.
_makeOne
()
self
.
failUnless
(
mapper
[
'test'
]
is
self
)
self
.
assertTrue
(
mapper
[
'test'
]
is
self
)
_marker
=
object
()
...
...
@@ -224,9 +224,9 @@ class BoundPageTemplateTests(unittest.TestCase):
pt
=
DummyTemplate
({
'foo'
:
'bar'
})
ob
=
DummyContext
()
bpt
=
self
.
_makeOne
(
pt
,
ob
)
self
.
failUnless
(
bpt
.
im_func
is
pt
)
self
.
failUnless
(
bpt
.
im_self
is
ob
)
self
.
failUnless
(
bpt
.
__parent__
is
ob
)
self
.
assertTrue
(
bpt
.
im_func
is
pt
)
self
.
assertTrue
(
bpt
.
im_self
is
ob
)
self
.
assertTrue
(
bpt
.
__parent__
is
ob
)
self
.
assertEqual
(
bpt
.
macros
[
'foo'
],
'bar'
)
self
.
assertEqual
(
bpt
.
filename
,
'dummy.pt'
)
...
...
src/Products/PageTemplates/tests/testExpressions.py
View file @
6220f215
...
...
@@ -95,7 +95,7 @@ class EngineTestsBase(PlacelessSetup):
def
test_evaluate_alternative_first_missing
(
self
):
ec
=
self
.
_makeContext
()
self
.
failUnless
(
ec
.
evaluate
(
'x | nothing'
)
is
None
)
self
.
assertTrue
(
ec
.
evaluate
(
'x | nothing'
)
is
None
)
def
test_evaluate_dict_key_as_underscore
(
self
):
ec
=
self
.
_makeContext
()
...
...
@@ -123,26 +123,26 @@ class EngineTestsBase(PlacelessSetup):
def
test_hybrid_with_compound_expression_int_value
(
self
):
ec
=
self
.
_makeContext
()
self
.
failUnless
(
ec
.
evaluate
(
'x | not:exists:x'
))
self
.
assertTrue
(
ec
.
evaluate
(
'x | not:exists:x'
))
def
test_access_iterator_from_python_expression
(
self
):
ec
=
self
.
_makeContext
()
ec
.
beginScope
()
ec
.
setRepeat
(
'loop'
,
"python:[1,2,3]"
)
self
.
failUnless
(
ec
.
evaluate
(
"python:repeat['loop'].odd()"
))
self
.
assertTrue
(
ec
.
evaluate
(
"python:repeat['loop'].odd()"
))
ec
.
endScope
()
def
test_defer_expression_returns_wrapper
(
self
):
from
zope.tales.expressions
import
DeferWrapper
ec
=
self
.
_makeContext
()
defer
=
ec
.
evaluate
(
'defer: b'
)
self
.
failUnless
(
isinstance
(
defer
,
DeferWrapper
))
self
.
assertTrue
(
isinstance
(
defer
,
DeferWrapper
))
def
test_lazy_expression_returns_wrapper
(
self
):
from
zope.tales.expressions
import
LazyWrapper
ec
=
self
.
_makeContext
()
lazy
=
ec
.
evaluate
(
'lazy: b'
)
self
.
failUnless
(
isinstance
(
lazy
,
LazyWrapper
))
self
.
assertTrue
(
isinstance
(
lazy
,
LazyWrapper
))
def
test_empty_path_expression_explicit
(
self
):
ec
=
self
.
_makeContext
()
...
...
@@ -168,7 +168,7 @@ class EngineTestsBase(PlacelessSetup):
# only bothers compiling true strings, not unicode strings
result
=
ec
.
evaluate
(
eng
.
compile
(
u'string:x'
))
self
.
assertEqual
(
result
,
u'x'
)
self
.
failUnless
(
isinstance
(
result
,
unicode
))
self
.
assertTrue
(
isinstance
(
result
,
unicode
))
def
test_mixed
(
self
):
# 8-bit strings in unicode string expressions cause UnicodeDecodeErrors
...
...
@@ -289,7 +289,7 @@ class ZopeContextTests(unittest.TestCase):
# See: https://bugs.launchpad.net/zope2/+bug/174705
context
=
self
.
_makeOne
()
info
=
context
.
createErrorInfo
(
AttributeError
(
'nonesuch'
),
(
12
,
3
))
self
.
failUnless
(
info
.
type
is
AttributeError
)
self
.
assertTrue
(
info
.
type
is
AttributeError
)
self
.
assertEqual
(
info
.
__allow_access_to_unprotected_subobjects__
,
1
)
def
test_suite
():
...
...
src/Products/PageTemplates/tests/testZRPythonExpr.py
View file @
6220f215
...
...
@@ -13,14 +13,14 @@ class MiscTests(unittest.TestCase):
request
=
{
'request'
:
1
}
names
=
{
'context'
:
context
,
'here'
:
here
,
'request'
:
request
}
result
=
call_with_ns
(
lambda
td
:
td
.
this
,
names
)
self
.
failUnless
(
result
is
context
,
result
)
self
.
assertTrue
(
result
is
context
,
result
)
def
test_call_with_ns_no_context_or_here
(
self
):
from
Products.PageTemplates.ZRPythonExpr
import
call_with_ns
request
=
{
'request'
:
1
}
names
=
{
'request'
:
request
}
result
=
call_with_ns
(
lambda
td
:
td
.
this
,
names
)
self
.
failUnless
(
result
is
None
,
result
)
self
.
assertTrue
(
result
is
None
,
result
)
def
test_call_with_ns_no_request
(
self
):
from
Products.PageTemplates.ZRPythonExpr
import
call_with_ns
...
...
src/Products/PageTemplates/tests/testZopePageTemplate.py
View file @
6220f215
...
...
@@ -135,7 +135,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
self
.
app
.
REQUEST
.
set
(
'HTTP_ACCEPT_CHARSET'
,
'ISO-8859-15,utf-8'
)
self
.
app
.
REQUEST
.
set
(
'data'
,
''
)
result
=
zpt
.
pt_render
()
self
.
failUnless
(
result
.
startswith
(
unicode
(
'<div></div>'
,
self
.
assertTrue
(
result
.
startswith
(
unicode
(
'<div></div>'
,
'iso-8859-15'
)))
def
testUTF8
(
self
):
...
...
@@ -148,7 +148,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
self
.
app
.
REQUEST
.
set
(
'data'
,
unicode
(
''
,
'iso-8859-15'
).
encode
(
'utf-8'
))
result
=
zpt
.
pt_render
()
self
.
failUnless
(
result
.
startswith
(
unicode
(
'<div></div>'
,
self
.
assertTrue
(
result
.
startswith
(
unicode
(
'<div></div>'
,
'iso-8859-15'
)))
def
testUTF8WrongPreferredCharset
(
self
):
...
...
@@ -161,7 +161,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
self
.
app
.
REQUEST
.
set
(
'data'
,
unicode
(
''
,
'iso-8859-15'
).
encode
(
'utf-8'
))
result
=
zpt
.
pt_render
()
self
.
failIf
(
result
.
startswith
(
unicode
(
'<div></div>'
,
self
.
assertFalse
(
result
.
startswith
(
unicode
(
'<div></div>'
,
'iso-8859-15'
)))
def
testStructureWithAccentedChars
(
self
):
...
...
@@ -174,7 +174,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
self
.
app
.
REQUEST
.
set
(
'data'
,
unicode
(
''
,
'iso-8859-15'
).
encode
(
'utf-8'
))
result
=
zpt
.
pt_render
()
self
.
failUnless
(
result
.
startswith
(
unicode
(
'<div></div>'
,
self
.
assertTrue
(
result
.
startswith
(
unicode
(
'<div></div>'
,
'iso-8859-15'
)))
def
testBug151020
(
self
):
...
...
@@ -188,7 +188,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
self
.
app
.
REQUEST
.
set
(
'data'
,
unicode
(
''
,
'iso-8859-15'
).
encode
(
'utf-8'
))
result
=
zpt
.
pt_render
()
self
.
failUnless
(
result
.
startswith
(
unicode
(
'<div></div>'
,
self
.
assertTrue
(
result
.
startswith
(
unicode
(
'<div></div>'
,
'iso-8859-15'
)))
def
test_bug_198274
(
self
):
...
...
@@ -268,7 +268,7 @@ class ZopePageTemplateFileTests(ZopeTestCase):
zpt
=
self
.
app
[
'test'
]
result
=
zpt
.
pt_render
()
# use startswith() because the renderer appends a trailing \n
self
.
failUnless
(
result
.
encode
(
'iso-8859-15'
self
.
assertTrue
(
result
.
encode
(
'iso-8859-15'
).
startswith
(
iso885915_str
))
self
.
assertEqual
(
zpt
.
output_encoding
,
'iso-8859-15'
)
...
...
src/Products/PageTemplates/tests/test_ptfile.py
View file @
6220f215
...
...
@@ -206,7 +206,7 @@ class LazyLoadingTestCase(unittest.TestCase):
print
>>
f
,
'Lazyness'
f
.
close
()
pt
=
PageTemplateFile
(
self
.
TEMPFILENAME
)
self
.
failUnless
(
not
pt
.
_text
and
not
pt
.
_v_program
)
self
.
assertTrue
(
not
pt
.
_text
and
not
pt
.
_v_program
)
def
test_suite
():
...
...
src/Products/PluginIndexes/DateIndex/tests/test_DateIndex.py
View file @
6220f215
...
...
@@ -140,7 +140,7 @@ class DI_Tests(unittest.TestCase):
self
.
failUnlessEqual
(
len
(
result
),
len
(
expectedValues
),
'%s | %s'
%
(
result
,
expectedValues
))
for
k
,
v
in
expectedValues
:
self
.
failUnless
(
k
in
result
)
self
.
assertTrue
(
k
in
result
)
def
_convert
(
self
,
dt
):
from
time
import
gmtime
...
...
@@ -178,16 +178,16 @@ class DI_Tests(unittest.TestCase):
self
.
failUnlessEqual
(
len
(
index
),
0
)
self
.
failUnlessEqual
(
len
(
index
.
referencedObjects
()),
0
)
self
.
failUnless
(
index
.
getEntryForObject
(
1234
)
is
None
)
self
.
assertTrue
(
index
.
getEntryForObject
(
1234
)
is
None
)
marker
=
[]
self
.
failUnless
(
index
.
getEntryForObject
(
1234
,
marker
)
is
marker
)
self
.
assertTrue
(
index
.
getEntryForObject
(
1234
,
marker
)
is
marker
)
index
.
unindex_object
(
1234
)
# shouldn't throw
self
.
failUnless
(
index
.
hasUniqueValuesFor
(
'date'
))
self
.
failIf
(
index
.
hasUniqueValuesFor
(
'foo'
))
self
.
assertTrue
(
index
.
hasUniqueValuesFor
(
'date'
))
self
.
assertFalse
(
index
.
hasUniqueValuesFor
(
'foo'
))
self
.
failUnlessEqual
(
len
(
index
.
uniqueValues
(
'date'
)),
0
)
self
.
failUnless
(
index
.
_apply_index
({
'zed'
:
12345
})
is
None
)
self
.
assertTrue
(
index
.
_apply_index
({
'zed'
:
12345
})
is
None
)
self
.
_checkApply
(
index
,
{
'date'
:
DateTime
(
0
)},
[])
...
...
@@ -215,9 +215,9 @@ class DI_Tests(unittest.TestCase):
self
.
failUnlessEqual
(
len
(
index
.
referencedObjects
()),
len
(
values
)
-
1
)
# One empty
self
.
failUnless
(
index
.
getEntryForObject
(
1234
)
is
None
)
self
.
assertTrue
(
index
.
getEntryForObject
(
1234
)
is
None
)
marker
=
[]
self
.
failUnless
(
index
.
getEntryForObject
(
1234
,
marker
)
is
marker
)
self
.
assertTrue
(
index
.
getEntryForObject
(
1234
,
marker
)
is
marker
)
index
.
unindex_object
(
1234
)
# shouldn't throw
for
k
,
v
in
values
:
...
...
@@ -226,7 +226,7 @@ class DI_Tests(unittest.TestCase):
self
.
_convert
(
v
.
date
()))
self
.
failUnlessEqual
(
len
(
index
.
uniqueValues
(
'date'
)),
len
(
values
)
-
2
)
self
.
failUnless
(
index
.
_apply_index
({
'bar'
:
123
})
is
None
)
self
.
assertTrue
(
index
.
_apply_index
({
'bar'
:
123
})
is
None
)
self
.
_checkApply
(
index
,
{
'date'
:
DateTime
(
0
)},
values
[
1
:
2
])
...
...
@@ -273,7 +273,7 @@ class DI_Tests(unittest.TestCase):
self
.
_checkApply
(
index
,
{
'date'
:
1072742900
},
[
values
[
7
]])
index
.
index_object
(
7
,
None
)
self
.
failIf
(
7
in
index
.
documentToKeyMap
().
keys
())
self
.
assertFalse
(
7
in
index
.
documentToKeyMap
().
keys
())
def
test_suite
():
...
...
src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
View file @
6220f215
...
...
@@ -97,17 +97,17 @@ class DRI_Tests( unittest.TestCase ):
empty
=
self
.
_makeOne
(
'empty'
)
self
.
failUnless
(
empty
.
getEntryForObject
(
1234
)
is
None
)
self
.
assertTrue
(
empty
.
getEntryForObject
(
1234
)
is
None
)
empty
.
unindex_object
(
1234
)
# shouldn't throw
self
.
failIf
(
empty
.
uniqueValues
(
'foo'
))
self
.
failIf
(
empty
.
uniqueValues
(
'foo'
,
1
))
self
.
assertFalse
(
empty
.
uniqueValues
(
'foo'
))
self
.
assertFalse
(
empty
.
uniqueValues
(
'foo'
,
1
))
self
.
failUnless
(
empty
.
_apply_index
(
{
'zed'
:
12345
}
)
is
None
)
self
.
assertTrue
(
empty
.
_apply_index
(
{
'zed'
:
12345
}
)
is
None
)
result
,
used
=
empty
.
_apply_index
(
{
'empty'
:
12345
}
)
self
.
failIf
(
result
)
self
.
assertFalse
(
result
)
self
.
assertEqual
(
used
,
(
None
,
None
))
def
test_retrieval
(
self
):
...
...
src/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
View file @
6220f215
...
...
@@ -243,8 +243,8 @@ class TestKeywordIndex( unittest.TestCase ):
def
test_noindexing_when_noattribute
(
self
):
to_index
=
Dummy
([
'hello'
])
self
.
_index
.
_index_object
(
10
,
to_index
,
attr
=
'UNKNOWN'
)
self
.
failIf
(
self
.
_index
.
_unindex
.
get
(
10
))
self
.
failIf
(
self
.
_index
.
getEntryForObject
(
10
))
self
.
assertFalse
(
self
.
_index
.
_unindex
.
get
(
10
))
self
.
assertFalse
(
self
.
_index
.
getEntryForObject
(
10
))
def
test_noindexing_when_raising_attribute
(
self
):
class
FauxObject
:
...
...
@@ -252,18 +252,18 @@ class TestKeywordIndex( unittest.TestCase ):
raise
AttributeError
to_index
=
FauxObject
()
self
.
_index
.
_index_object
(
10
,
to_index
,
attr
=
'foo'
)
self
.
failIf
(
self
.
_index
.
_unindex
.
get
(
10
))
self
.
failIf
(
self
.
_index
.
getEntryForObject
(
10
))
self
.
assertFalse
(
self
.
_index
.
_unindex
.
get
(
10
))
self
.
assertFalse
(
self
.
_index
.
getEntryForObject
(
10
))
def
test_value_removes
(
self
):
to_index
=
Dummy
([
'hello'
])
self
.
_index
.
_index_object
(
10
,
to_index
,
attr
=
'foo'
)
self
.
failUnless
(
self
.
_index
.
_unindex
.
get
(
10
))
self
.
assertTrue
(
self
.
_index
.
_unindex
.
get
(
10
))
to_index
=
Dummy
(
''
)
self
.
_index
.
_index_object
(
10
,
to_index
,
attr
=
'foo'
)
self
.
failIf
(
self
.
_index
.
_unindex
.
get
(
10
))
self
.
assertFalse
(
self
.
_index
.
_unindex
.
get
(
10
))
def
test_suite
():
...
...
src/Products/PluginIndexes/PathIndex/tests/testPathIndex.py
View file @
6220f215
...
...
@@ -121,7 +121,7 @@ class PathIndexTests(unittest.TestCase):
def
test_getEntryForObject_miss_w_default
(
self
):
index
=
self
.
_makeOne
()
default
=
object
()
self
.
failUnless
(
index
.
getEntryForObject
(
1234
,
default
)
is
default
)
self
.
assertTrue
(
index
.
getEntryForObject
(
1234
,
default
)
is
default
)
def
test_getEntryForObject_hit
(
self
):
index
=
self
.
_makeOne
()
...
...
@@ -402,11 +402,11 @@ class PathIndexTests(unittest.TestCase):
def
test_hasUniqueValuesFor_miss
(
self
):
index
=
self
.
_makeOne
()
self
.
failIf
(
index
.
hasUniqueValuesFor
(
'miss'
))
self
.
assertFalse
(
index
.
hasUniqueValuesFor
(
'miss'
))
def
test_hasUniqueValuesFor_hit
(
self
):
index
=
self
.
_makeOne
()
self
.
failUnless
(
index
.
hasUniqueValuesFor
(
'path'
))
self
.
assertTrue
(
index
.
hasUniqueValuesFor
(
'path'
))
def
test_uniqueValues_empty
(
self
):
index
=
self
.
_makeOne
()
...
...
src/Products/Sessions/tests/testBrowserIdManager.py
View file @
6220f215
...
...
@@ -30,25 +30,25 @@ class TestBrowserIdManager(unittest.TestCase):
def
test_hasBrowserId_already_set_on_request_invalid
(
self
):
request
=
DummyRequest
(
browser_id_
=
'xxx'
)
mgr
=
self
.
_makeOne
(
request
)
self
.
failIf
(
mgr
.
hasBrowserId
())
self
.
assertFalse
(
mgr
.
hasBrowserId
())
def
test_hasBrowserId_already_set_on_request
(
self
):
from
Products.Sessions.BrowserIdManager
import
getNewBrowserId
request
=
DummyRequest
(
browser_id_
=
getNewBrowserId
())
mgr
=
self
.
_makeOne
(
request
)
self
.
failUnless
(
mgr
.
hasBrowserId
())
self
.
assertTrue
(
mgr
.
hasBrowserId
())
def
test_hasBrowserId_namespace_hit
(
self
):
from
Products.Sessions.BrowserIdManager
import
getNewBrowserId
request
=
DummyRequest
(
cookies
=
{
'bid'
:
getNewBrowserId
()})
mgr
=
self
.
_makeOne
(
request
)
mgr
.
setBrowserIdName
(
'bid'
)
self
.
failUnless
(
mgr
.
hasBrowserId
())
self
.
assertTrue
(
mgr
.
hasBrowserId
())
def
test_hasBrowserId_namespace_miss
(
self
):
request
=
DummyRequest
()
mgr
=
self
.
_makeOne
(
request
)
self
.
failIf
(
mgr
.
hasBrowserId
())
self
.
assertFalse
(
mgr
.
hasBrowserId
())
self
.
assertRaises
(
AttributeError
,
getattr
,
request
,
'browser_id_'
)
self
.
assertRaises
(
AttributeError
,
getattr
,
request
,
'browser_id_ns_'
)
...
...
@@ -70,7 +70,7 @@ class TestBrowserIdManager(unittest.TestCase):
request
=
DummyRequest
(
cookies
=
{
'bid'
:
bid
})
mgr
=
self
.
_makeOne
(
request
)
mgr
.
setBrowserIdName
(
'bid'
)
self
.
failUnless
(
mgr
.
hasBrowserId
())
self
.
assertTrue
(
mgr
.
hasBrowserId
())
self
.
assertEqual
(
request
.
browser_id_
,
bid
)
self
.
assertEqual
(
request
.
browser_id_ns_
,
'cookies'
)
...
...
@@ -89,7 +89,7 @@ class TestBrowserIdManager(unittest.TestCase):
mgr
.
setBrowserIdName
(
'bid'
)
mgr
.
setBrowserIdNamespaces
(())
bid
=
mgr
.
getBrowserId
()
self
.
failUnless
(
isAWellFormedBrowserId
(
bid
))
self
.
assertTrue
(
isAWellFormedBrowserId
(
bid
))
self
.
assertEqual
(
request
.
browser_id_
,
bid
)
self
.
assertEqual
(
request
.
browser_id_ns_
,
None
)
...
...
@@ -101,7 +101,7 @@ class TestBrowserIdManager(unittest.TestCase):
mgr
.
setBrowserIdName
(
'bid'
)
mgr
.
setBrowserIdNamespaces
((
'cookies'
,))
bid
=
mgr
.
getBrowserId
()
self
.
failUnless
(
isAWellFormedBrowserId
(
bid
))
self
.
assertTrue
(
isAWellFormedBrowserId
(
bid
))
self
.
assertEqual
(
request
.
browser_id_
,
bid
)
self
.
assertEqual
(
request
.
browser_id_ns_
,
None
)
self
.
assertEqual
(
response
.
cookies
[
'bid'
],
{
'path'
:
'/'
,
'value'
:
bid
})
...
...
@@ -116,14 +116,14 @@ class TestBrowserIdManager(unittest.TestCase):
bid
=
getNewBrowserId
()
request
=
DummyRequest
(
browser_id_
=
bid
,
browser_id_ns_
=
None
)
mgr
=
self
.
_makeOne
(
request
)
self
.
failUnless
(
mgr
.
isBrowserIdNew
())
self
.
assertTrue
(
mgr
.
isBrowserIdNew
())
def
test_isBrowserIdNew_w_ns
(
self
):
from
Products.Sessions.BrowserIdManager
import
getNewBrowserId
bid
=
getNewBrowserId
()
request
=
DummyRequest
(
browser_id_
=
bid
,
browser_id_ns_
=
'url'
)
mgr
=
self
.
_makeOne
(
request
)
self
.
failIf
(
mgr
.
isBrowserIdNew
())
self
.
assertFalse
(
mgr
.
isBrowserIdNew
())
def
test_isBrowserIdFromCookie_nonesuch_raises
(
self
):
request
=
DummyRequest
()
...
...
@@ -135,14 +135,14 @@ class TestBrowserIdManager(unittest.TestCase):
bid
=
getNewBrowserId
()
request
=
DummyRequest
(
browser_id_
=
bid
,
browser_id_ns_
=
'url'
)
mgr
=
self
.
_makeOne
(
request
)
self
.
failIf
(
mgr
.
isBrowserIdFromCookie
())
self
.
assertFalse
(
mgr
.
isBrowserIdFromCookie
())
def
test_isBrowserIdFromCookie_right_ns
(
self
):
from
Products.Sessions.BrowserIdManager
import
getNewBrowserId
bid
=
getNewBrowserId
()
request
=
DummyRequest
(
browser_id_
=
bid
,
browser_id_ns_
=
'cookies'
)
mgr
=
self
.
_makeOne
(
request
)
self
.
failUnless
(
mgr
.
isBrowserIdFromCookie
())
self
.
assertTrue
(
mgr
.
isBrowserIdFromCookie
())
def
test_isBrowserIdFromForm_nonesuch_raises
(
self
):
request
=
DummyRequest
()
...
...
@@ -154,14 +154,14 @@ class TestBrowserIdManager(unittest.TestCase):
bid
=
getNewBrowserId
()
request
=
DummyRequest
(
browser_id_
=
bid
,
browser_id_ns_
=
'url'
)
mgr
=
self
.
_makeOne
(
request
)
self
.
failIf
(
mgr
.
isBrowserIdFromForm
())
self
.
assertFalse
(
mgr
.
isBrowserIdFromForm
())
def
test_isBrowserIdFromForm_right_ns
(
self
):
from
Products.Sessions.BrowserIdManager
import
getNewBrowserId
bid
=
getNewBrowserId
()
request
=
DummyRequest
(
browser_id_
=
bid
,
browser_id_ns_
=
'form'
)
mgr
=
self
.
_makeOne
(
request
)
self
.
failUnless
(
mgr
.
isBrowserIdFromForm
())
self
.
assertTrue
(
mgr
.
isBrowserIdFromForm
())
def
test_isBrowserIdFromUrl_nonesuch_raises
(
self
):
request
=
DummyRequest
()
...
...
@@ -173,14 +173,14 @@ class TestBrowserIdManager(unittest.TestCase):
bid
=
getNewBrowserId
()
request
=
DummyRequest
(
browser_id_
=
bid
,
browser_id_ns_
=
'form'
)
mgr
=
self
.
_makeOne
(
request
)
self
.
failIf
(
mgr
.
isBrowserIdFromUrl
())
self
.
assertFalse
(
mgr
.
isBrowserIdFromUrl
())
def
test_isBrowserIdFromUrl_right_ns
(
self
):
from
Products.Sessions.BrowserIdManager
import
getNewBrowserId
bid
=
getNewBrowserId
()
request
=
DummyRequest
(
browser_id_
=
bid
,
browser_id_ns_
=
'url'
)
mgr
=
self
.
_makeOne
(
request
)
self
.
failUnless
(
mgr
.
isBrowserIdFromUrl
())
self
.
assertTrue
(
mgr
.
isBrowserIdFromUrl
())
def
test_flushBrowserIdCookie_wrong_ns_raises
(
self
):
mgr
=
self
.
_makeOne
()
...
...
@@ -341,37 +341,37 @@ class TestBrowserIdManager(unittest.TestCase):
def
test_setCookieSecure_int
(
self
):
mgr
=
self
.
_makeOne
()
mgr
.
setCookieSecure
(
1
)
self
.
failUnless
(
mgr
.
getCookieSecure
())
self
.
assertTrue
(
mgr
.
getCookieSecure
())
mgr
.
setCookieSecure
(
0
)
self
.
failIf
(
mgr
.
getCookieSecure
())
self
.
assertFalse
(
mgr
.
getCookieSecure
())
def
test_setCookieSecure_bool
(
self
):
mgr
=
self
.
_makeOne
()
mgr
.
setCookieSecure
(
True
)
self
.
failUnless
(
mgr
.
getCookieSecure
())
self
.
assertTrue
(
mgr
.
getCookieSecure
())
mgr
.
setCookieSecure
(
False
)
self
.
failIf
(
mgr
.
getCookieSecure
())
self
.
assertFalse
(
mgr
.
getCookieSecure
())
def
test_setCookieHTTPOnly_bool
(
self
):
mgr
=
self
.
_makeOne
()
mgr
.
setCookieHTTPOnly
(
True
)
self
.
failUnless
(
mgr
.
getCookieHTTPOnly
())
self
.
assertTrue
(
mgr
.
getCookieHTTPOnly
())
mgr
.
setCookieHTTPOnly
(
False
)
self
.
failIf
(
mgr
.
getCookieHTTPOnly
())
self
.
assertFalse
(
mgr
.
getCookieHTTPOnly
())
def
test_setAutoUrlEncoding_bool
(
self
):
mgr
=
self
.
_makeOne
()
mgr
.
setAutoUrlEncoding
(
True
)
self
.
failUnless
(
mgr
.
getAutoUrlEncoding
())
self
.
assertTrue
(
mgr
.
getAutoUrlEncoding
())
mgr
.
setAutoUrlEncoding
(
False
)
self
.
failIf
(
mgr
.
getAutoUrlEncoding
())
self
.
assertFalse
(
mgr
.
getAutoUrlEncoding
())
def
test_isUrlInBidNamespaces
(
self
):
mgr
=
self
.
_makeOne
()
mgr
.
setBrowserIdNamespaces
((
'cookies'
,
'url'
,
'form'
))
self
.
failUnless
(
mgr
.
isUrlInBidNamespaces
())
self
.
assertTrue
(
mgr
.
isUrlInBidNamespaces
())
mgr
.
setBrowserIdNamespaces
((
'cookies'
,
'form'
))
self
.
failIf
(
mgr
.
isUrlInBidNamespaces
())
self
.
assertFalse
(
mgr
.
isUrlInBidNamespaces
())
def
test__setCookie_remove
(
self
):
response
=
DummyResponse
(
cookies
=
{})
...
...
@@ -484,13 +484,13 @@ class TestBrowserIdManager(unittest.TestCase):
def
test_hasTraversalHook_missing
(
self
):
mgr
=
self
.
_makeOne
()
parent
=
DummyObject
()
self
.
failIf
(
mgr
.
hasTraversalHook
(
parent
))
self
.
assertFalse
(
mgr
.
hasTraversalHook
(
parent
))
def
test_hasTraversalHook_present
(
self
):
mgr
=
self
.
_makeOne
()
parent
=
DummyObject
()
parent
.
__before_traverse__
=
{(
0
,
'BrowserIdManager'
):
object
()}
self
.
failUnless
(
mgr
.
hasTraversalHook
(
parent
))
self
.
assertTrue
(
mgr
.
hasTraversalHook
(
parent
))
def
test_updateTraversalData_w_url_ns
(
self
):
from
Acquisition
import
Implicit
...
...
@@ -506,7 +506,7 @@ class TestBrowserIdManager(unittest.TestCase):
hooks
=
queryBeforeTraverse
(
parent
,
'BrowserIdManager'
)
self
.
assertEqual
(
len
(
hooks
),
1
)
self
.
assertEqual
(
hooks
[
0
][
0
],
40
)
self
.
failUnless
(
isinstance
(
hooks
[
0
][
1
],
BrowserIdManagerTraverser
))
self
.
assertTrue
(
isinstance
(
hooks
[
0
][
1
],
BrowserIdManagerTraverser
))
def
test_updateTraversalData_not_url_ns
(
self
):
from
Acquisition
import
Implicit
...
...
@@ -519,7 +519,7 @@ class TestBrowserIdManager(unittest.TestCase):
parent
.
__before_traverse__
=
{(
0
,
'BrowserIdManager'
):
object
()}
parent
.
browser_id_manager
=
mgr
parent
.
browser_id_manager
.
updateTraversalData
()
# needs wrapper
self
.
failIf
(
queryBeforeTraverse
(
mgr
,
'BrowserIdManager'
))
self
.
assertFalse
(
queryBeforeTraverse
(
mgr
,
'BrowserIdManager'
))
def
test_registerTraversalHook_doesnt_replace_existing
(
self
):
from
Acquisition
import
Implicit
...
...
@@ -535,7 +535,7 @@ class TestBrowserIdManager(unittest.TestCase):
hooks
=
queryBeforeTraverse
(
parent
,
'BrowserIdManager'
)
self
.
assertEqual
(
len
(
hooks
),
1
)
self
.
assertEqual
(
hooks
[
0
][
0
],
0
)
self
.
failUnless
(
hooks
[
0
][
1
]
is
hook
)
self
.
assertTrue
(
hooks
[
0
][
1
]
is
hook
)
def
test_registerTraversalHook_normal
(
self
):
from
Acquisition
import
Implicit
...
...
@@ -550,7 +550,7 @@ class TestBrowserIdManager(unittest.TestCase):
hooks
=
queryBeforeTraverse
(
parent
,
'BrowserIdManager'
)
self
.
assertEqual
(
len
(
hooks
),
1
)
self
.
assertEqual
(
hooks
[
0
][
0
],
40
)
self
.
failUnless
(
isinstance
(
hooks
[
0
][
1
],
BrowserIdManagerTraverser
))
self
.
assertTrue
(
isinstance
(
hooks
[
0
][
1
],
BrowserIdManagerTraverser
))
def
test_unregisterTraversalHook_nonesuch_doesnt_raise
(
self
):
from
Acquisition
import
Implicit
...
...
@@ -571,7 +571,7 @@ class TestBrowserIdManager(unittest.TestCase):
parent
.
__before_traverse__
=
{(
0
,
'BrowserIdManager'
):
object
()}
parent
.
browser_id_manager
=
mgr
parent
.
browser_id_manager
.
unregisterTraversalHook
()
# needs wrapper
self
.
failIf
(
queryBeforeTraverse
(
mgr
,
'BrowserIdManager'
))
self
.
assertFalse
(
queryBeforeTraverse
(
mgr
,
'BrowserIdManager'
))
class
TestBrowserIdManagerTraverser
(
unittest
.
TestCase
):
...
...
@@ -634,7 +634,7 @@ class TestBrowserIdManagerTraverser(unittest.TestCase):
request
=
DummyRequest
(
TraversalRequestNameStack
=
[],
_script
=
[])
traverser
(
container
,
request
)
bid
=
request
.
browser_id_
self
.
failUnless
(
isAWellFormedBrowserId
(
bid
))
self
.
assertTrue
(
isAWellFormedBrowserId
(
bid
))
self
.
assertEqual
(
request
.
browser_id_ns_
,
None
)
self
.
assertEqual
(
len
(
request
.
TraversalRequestNameStack
),
0
)
self
.
assertEqual
(
len
(
request
.
_script
),
2
)
...
...
src/Products/Sessions/tests/testSessionDataManager.py
View file @
6220f215
...
...
@@ -111,28 +111,28 @@ class TestSessionManager(unittest.TestCase):
del
self
.
app
def
testHasId
(
self
):
self
.
failUnless
(
self
.
app
.
session_data_manager
.
id
==
\
self
.
assertTrue
(
self
.
app
.
session_data_manager
.
id
==
\
sdm_name
)
def
testHasTitle
(
self
):
self
.
failUnless
(
self
.
app
.
session_data_manager
.
title
\
self
.
assertTrue
(
self
.
app
.
session_data_manager
.
title
\
==
'Session Data Manager'
)
def
testGetSessionDataNoCreate
(
self
):
sd
=
self
.
app
.
session_data_manager
.
getSessionData
(
0
)
self
.
failUnless
(
sd
is
None
)
self
.
assertTrue
(
sd
is
None
)
def
testGetSessionDataCreate
(
self
):
from
Products.Transience.Transience
import
TransientObject
sd
=
self
.
app
.
session_data_manager
.
getSessionData
(
1
)
self
.
failUnless
(
sd
.
__class__
is
TransientObject
)
self
.
assertTrue
(
sd
.
__class__
is
TransientObject
)
def
testHasSessionData
(
self
):
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
self
.
failUnless
(
self
.
app
.
session_data_manager
.
hasSessionData
())
self
.
assertTrue
(
self
.
app
.
session_data_manager
.
hasSessionData
())
def
testNotHasSessionData
(
self
):
self
.
failUnless
(
not
self
.
app
.
session_data_manager
.
hasSessionData
())
self
.
assertTrue
(
not
self
.
app
.
session_data_manager
.
hasSessionData
())
def
testSessionDataWrappedInSDMandTOC
(
self
):
from
Acquisition
import
aq_base
...
...
@@ -140,28 +140,28 @@ class TestSessionManager(unittest.TestCase):
sdm
=
aq_base
(
getattr
(
self
.
app
,
sdm_name
))
toc
=
aq_base
(
getattr
(
self
.
app
.
temp_folder
,
toc_name
))
self
.
failUnless
(
aq_base
(
sd
.
aq_parent
)
is
sdm
)
self
.
failUnless
(
aq_base
(
sd
.
aq_parent
.
aq_parent
)
is
toc
)
self
.
assertTrue
(
aq_base
(
sd
.
aq_parent
)
is
sdm
)
self
.
assertTrue
(
aq_base
(
sd
.
aq_parent
.
aq_parent
)
is
toc
)
def
testNewSessionDataObjectIsValid
(
self
):
from
Acquisition
import
aq_base
from
Products.Transience.Transience
import
TransientObject
sdType
=
type
(
TransientObject
(
1
))
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
self
.
failUnless
(
type
(
aq_base
(
sd
))
is
sdType
)
self
.
failUnless
(
not
hasattr
(
sd
,
'_invalid'
))
self
.
assertTrue
(
type
(
aq_base
(
sd
))
is
sdType
)
self
.
assertTrue
(
not
hasattr
(
sd
,
'_invalid'
))
def
testBrowserIdIsSet
(
self
):
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
mgr
=
getattr
(
self
.
app
,
idmgr_name
)
self
.
failUnless
(
mgr
.
hasBrowserId
())
self
.
assertTrue
(
mgr
.
hasBrowserId
())
def
testGetSessionDataByKey
(
self
):
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
mgr
=
getattr
(
self
.
app
,
idmgr_name
)
token
=
mgr
.
getBrowserId
()
bykeysd
=
self
.
app
.
session_data_manager
.
getSessionDataByKey
(
token
)
self
.
failUnless
(
sd
==
bykeysd
)
self
.
assertTrue
(
sd
==
bykeysd
)
def
testBadExternalSDCPath
(
self
):
from
Products.Sessions.SessionDataManager
import
SessionDataManagerErr
...
...
@@ -179,7 +179,7 @@ class TestSessionManager(unittest.TestCase):
sd
=
sdm
.
getSessionData
()
sd
[
'test'
]
=
'Its alive! Alive!'
sd
.
invalidate
()
self
.
failUnless
(
not
sdm
.
getSessionData
().
has_key
(
'test'
))
self
.
assertTrue
(
not
sdm
.
getSessionData
().
has_key
(
'test'
))
def
testGhostUnghostSessionManager
(
self
):
import
transaction
...
...
@@ -189,7 +189,7 @@ class TestSessionManager(unittest.TestCase):
sd
.
set
(
'foo'
,
'bar'
)
sdm
.
_p_changed
=
None
transaction
.
commit
()
self
.
failUnless
(
sdm
.
getSessionData
().
get
(
'foo'
)
==
'bar'
)
self
.
assertTrue
(
sdm
.
getSessionData
().
get
(
'foo'
)
==
'bar'
)
def
testSubcommitAssignsPJar
(
self
):
global
DummyPersistent
# so pickle can find it
...
...
@@ -200,9 +200,9 @@ class TestSessionManager(unittest.TestCase):
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
dummy
=
DummyPersistent
()
sd
.
set
(
'dp'
,
dummy
)
self
.
failUnless
(
sd
[
'dp'
].
_p_jar
is
None
)
self
.
assertTrue
(
sd
[
'dp'
].
_p_jar
is
None
)
transaction
.
savepoint
(
optimistic
=
True
)
self
.
failIf
(
sd
[
'dp'
].
_p_jar
is
None
)
self
.
assertFalse
(
sd
[
'dp'
].
_p_jar
is
None
)
def
testForeignObject
(
self
):
from
ZODB.POSException
import
InvalidObjectReference
...
...
@@ -237,7 +237,7 @@ class TestSessionManager(unittest.TestCase):
self
.
app
.
REQUEST
[
'PARENTS'
]
=
[
self
.
app
]
self
.
app
.
REQUEST
[
'URL'
]
=
'a'
self
.
app
.
REQUEST
.
traverse
(
'/'
)
self
.
failUnless
(
self
.
app
.
REQUEST
.
has_key
(
'TESTOFSESSION'
))
self
.
assertTrue
(
self
.
app
.
REQUEST
.
has_key
(
'TESTOFSESSION'
))
def
testUnlazifyAutoPopulated
(
self
):
from
Acquisition
import
aq_base
...
...
@@ -247,7 +247,7 @@ class TestSessionManager(unittest.TestCase):
self
.
app
.
REQUEST
.
traverse
(
'/'
)
sess
=
self
.
app
.
REQUEST
[
'TESTOFSESSION'
]
sdType
=
type
(
TransientObject
(
1
))
self
.
failUnless
(
type
(
aq_base
(
sess
))
is
sdType
)
self
.
assertTrue
(
type
(
aq_base
(
sess
))
is
sdType
)
def
test_suite
():
...
...
src/Products/SiteAccess/tests/testAccessRule.py
View file @
6220f215
...
...
@@ -34,7 +34,7 @@ class AccessRuleTests(unittest.TestCase):
request
=
DummyRequest
(
TraversalRequestNameStack
=
[])
container
=
DummyContainer
(
testing
=
_func
)
rule
(
container
,
request
)
self
.
failIf
(
_called
)
self
.
assertFalse
(
_called
)
def
test___call___w_SUPPRESS_ACCESSRULE_in_URL
(
self
):
# This behavior changed in landing lp:142878.
...
...
@@ -47,7 +47,7 @@ class AccessRuleTests(unittest.TestCase):
request
.
steps
=
[]
container
=
DummyContainer
(
testing
=
_func
)
rule
(
container
,
request
)
self
.
failUnless
(
_called
)
self
.
assertTrue
(
_called
)
self
.
assertEqual
(
request
.
_virtual_root
,
None
)
def
test___call___wo_SUPPRESS_ACCESSRULE
(
self
):
...
...
@@ -59,7 +59,7 @@ class AccessRuleTests(unittest.TestCase):
request
.
steps
=
[]
container
=
DummyContainer
(
testing
=
_func
)
rule
(
container
,
request
)
self
.
failUnless
(
_called
)
self
.
assertTrue
(
_called
)
self
.
assertEqual
(
request
.
_virtual_root
,
None
)
...
...
@@ -72,15 +72,15 @@ class Test_manage_addAccessRule(unittest.TestCase):
def
test_no_method_id_no_existing_rules_no_request
(
self
):
container
=
DummyContainer
()
result
=
self
.
_callFUT
(
container
,
None
,
None
)
self
.
failUnless
(
result
is
None
)
self
.
failIf
(
container
.
__dict__
)
self
.
assertTrue
(
result
is
None
)
self
.
assertFalse
(
container
.
__dict__
)
def
test_no_method_id_no_existing_rules_w_request
(
self
):
container
=
DummyContainer
()
result
=
self
.
_callFUT
(
container
,
None
,
{
'URL1'
:
'http://example.com/'
})
self
.
failUnless
(
isinstance
(
result
,
str
))
self
.
failUnless
(
'<TITLE>No Access Rule</TITLE>'
in
result
)
self
.
failIf
(
container
.
__dict__
)
self
.
assertTrue
(
isinstance
(
result
,
str
))
self
.
assertTrue
(
'<TITLE>No Access Rule</TITLE>'
in
result
)
self
.
assertFalse
(
container
.
__dict__
)
def
test_no_method_id_w_existing_rules_no_request
(
self
):
from
ZPublisher.BeforeTraverse
import
registerBeforeTraverse
...
...
@@ -89,9 +89,9 @@ class Test_manage_addAccessRule(unittest.TestCase):
icon
=
'rule_icon.jpg'
)
registerBeforeTraverse
(
container
,
old_rule
,
'AccessRule'
)
result
=
self
.
_callFUT
(
container
,
None
,
None
)
self
.
failUnless
(
result
is
None
)
self
.
failIf
(
container
.
__before_traverse__
)
self
.
failIf
(
'icon'
in
old_rule
.
__dict__
)
self
.
assertTrue
(
result
is
None
)
self
.
assertFalse
(
container
.
__before_traverse__
)
self
.
assertFalse
(
'icon'
in
old_rule
.
__dict__
)
def
test_w_method_id_w_existing_rules_w_request_none
(
self
):
from
ZPublisher.BeforeTraverse
import
registerBeforeTraverse
...
...
@@ -102,10 +102,10 @@ class Test_manage_addAccessRule(unittest.TestCase):
request
=
DummyRequest
(
URL1
=
'http://example.com/'
)
request
.
form
=
{
'none'
:
'1'
}
result
=
self
.
_callFUT
(
container
,
None
,
request
)
self
.
failUnless
(
isinstance
(
result
,
str
))
self
.
failUnless
(
'<TITLE>No Access Rule</TITLE>'
in
result
)
self
.
failIf
(
container
.
__before_traverse__
)
self
.
failIf
(
'icon'
in
old_rule
.
__dict__
)
self
.
assertTrue
(
isinstance
(
result
,
str
))
self
.
assertTrue
(
'<TITLE>No Access Rule</TITLE>'
in
result
)
self
.
assertFalse
(
container
.
__before_traverse__
)
self
.
assertFalse
(
'icon'
in
old_rule
.
__dict__
)
def
test_w_invalid_method_id_w_existing_rules_no_request
(
self
):
from
ZPublisher.BeforeTraverse
import
registerBeforeTraverse
...
...
@@ -114,8 +114,8 @@ class Test_manage_addAccessRule(unittest.TestCase):
icon
=
'rule_icon.jpg'
)
registerBeforeTraverse
(
container
,
old_rule
,
'AccessRule'
)
result
=
self
.
_callFUT
(
container
,
'nonesuch'
,
None
)
self
.
failUnless
(
result
is
None
)
self
.
failUnless
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
assertTrue
(
result
is
None
)
self
.
assertTrue
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
rule
=
container
.
__before_traverse__
[(
99
,
'AccessRule'
)]
self
.
assertEqual
(
rule
.
name
,
'old_rule'
)
self
.
assertEqual
(
old_rule
.
icon
,
'rule_icon.jpg'
)
...
...
@@ -129,9 +129,9 @@ class Test_manage_addAccessRule(unittest.TestCase):
request
=
DummyRequest
(
URL1
=
'http://example.com/'
)
request
.
form
=
{}
result
=
self
.
_callFUT
(
container
,
'nonesuch'
,
request
)
self
.
failUnless
(
isinstance
(
result
,
str
))
self
.
failUnless
(
'<TITLE>Invalid Method Id</TITLE>'
in
result
)
self
.
failUnless
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
assertTrue
(
isinstance
(
result
,
str
))
self
.
assertTrue
(
'<TITLE>Invalid Method Id</TITLE>'
in
result
)
self
.
assertTrue
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
rule
=
container
.
__before_traverse__
[(
99
,
'AccessRule'
)]
self
.
assertEqual
(
rule
.
name
,
'old_rule'
)
self
.
assertEqual
(
old_rule
.
icon
,
'rule_icon.jpg'
)
...
...
@@ -144,12 +144,12 @@ class Test_manage_addAccessRule(unittest.TestCase):
new_rule
=
container
.
new_rule
=
DummyObject
(
name
=
'new_rule'
)
registerBeforeTraverse
(
container
,
old_rule
,
'AccessRule'
)
result
=
self
.
_callFUT
(
container
,
'new_rule'
,
None
)
self
.
failUnless
(
result
is
None
)
self
.
failIf
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
failUnless
((
1
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
assertTrue
(
result
is
None
)
self
.
assertFalse
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
assertTrue
((
1
,
'AccessRule'
)
in
container
.
__before_traverse__
)
rule
=
container
.
__before_traverse__
[(
1
,
'AccessRule'
)]
self
.
assertEqual
(
rule
.
name
,
'new_rule'
)
self
.
failIf
(
'icon'
in
old_rule
.
__dict__
)
self
.
assertFalse
(
'icon'
in
old_rule
.
__dict__
)
self
.
assertEqual
(
new_rule
.
icon
,
'misc_/SiteAccess/AccessRule.gif'
)
def
test_w_valid_method_id_w_existing_rules_w_request
(
self
):
...
...
@@ -162,13 +162,13 @@ class Test_manage_addAccessRule(unittest.TestCase):
request
=
DummyRequest
(
URL1
=
'http://example.com/'
)
request
.
form
=
{}
result
=
self
.
_callFUT
(
container
,
'new_rule'
,
request
)
self
.
failUnless
(
isinstance
(
result
,
str
))
self
.
failUnless
(
'<TITLE>Access Rule Set</TITLE>'
in
result
)
self
.
failIf
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
failUnless
((
1
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
assertTrue
(
isinstance
(
result
,
str
))
self
.
assertTrue
(
'<TITLE>Access Rule Set</TITLE>'
in
result
)
self
.
assertFalse
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
assertTrue
((
1
,
'AccessRule'
)
in
container
.
__before_traverse__
)
rule
=
container
.
__before_traverse__
[(
1
,
'AccessRule'
)]
self
.
assertEqual
(
rule
.
name
,
'new_rule'
)
self
.
failIf
(
'icon'
in
old_rule
.
__dict__
)
self
.
assertFalse
(
'icon'
in
old_rule
.
__dict__
)
self
.
assertEqual
(
new_rule
.
icon
,
'misc_/SiteAccess/AccessRule.gif'
)
...
...
@@ -186,7 +186,7 @@ class Test_getAccessRule(unittest.TestCase):
from
ZPublisher.BeforeTraverse
import
registerBeforeTraverse
container
=
DummyContainer
()
registerBeforeTraverse
(
container
,
DummyObject
(),
'AccessRule'
)
self
.
failUnless
(
self
.
_callFUT
(
container
).
startswith
(
self
.
assertTrue
(
self
.
_callFUT
(
container
).
startswith
(
'Invalid BeforeTraverse data: '
))
def
test_w_rule_valid
(
self
):
...
...
src/Products/SiteAccess/tests/testSiteRoot.py
View file @
6220f215
...
...
@@ -23,7 +23,7 @@ class TraverserTests(unittest.TestCase):
traverser
=
self
.
_makeOne
()
container
=
DummyContainer
()
traverser
.
addToContainer
(
container
)
self
.
failUnless
(
container
.
testing
is
traverser
)
self
.
assertTrue
(
container
.
testing
is
traverser
)
hook
=
container
.
__before_traverse__
[(
100
,
'Traverser'
)]
self
.
assertEqual
(
hook
.
name
,
'testing'
)
...
...
@@ -31,8 +31,8 @@ class TraverserTests(unittest.TestCase):
traverser
=
self
.
_makeOne
()
container
=
DummyContainer
()
result
=
traverser
.
manage_addToContainer
(
container
)
self
.
failUnless
(
result
is
None
)
self
.
failUnless
(
container
.
testing
is
traverser
)
self
.
assertTrue
(
result
is
None
)
self
.
assertTrue
(
container
.
testing
is
traverser
)
hook
=
container
.
__before_traverse__
[(
100
,
'Traverser'
)]
self
.
assertEqual
(
hook
.
name
,
'testing'
)
...
...
@@ -42,16 +42,16 @@ class TraverserTests(unittest.TestCase):
container
=
DummyContainer
()
container
.
testing
=
object
()
result
=
traverser
.
manage_addToContainer
(
container
,
nextURL
=
NEXTURL
)
self
.
failUnless
(
'<TITLE>Item Exists</TITLE>'
in
result
)
self
.
failIf
(
container
.
testing
is
traverser
)
self
.
assertTrue
(
'<TITLE>Item Exists</TITLE>'
in
result
)
self
.
assertFalse
(
container
.
testing
is
traverser
)
def
test_manage_addToContainer_w_nextUrl_wo_name_collision
(
self
):
NEXTURL
=
'http://example.com/manage_main'
traverser
=
self
.
_makeOne
()
container
=
DummyContainer
()
result
=
traverser
.
manage_addToContainer
(
container
,
nextURL
=
NEXTURL
)
self
.
failUnless
(
'<TITLE>Item Added</TITLE>'
in
result
)
self
.
failUnless
(
container
.
testing
is
traverser
)
self
.
assertTrue
(
'<TITLE>Item Added</TITLE>'
in
result
)
self
.
assertTrue
(
container
.
testing
is
traverser
)
hook
=
container
.
__before_traverse__
[(
100
,
'Traverser'
)]
self
.
assertEqual
(
hook
.
name
,
'testing'
)
...
...
@@ -73,14 +73,14 @@ class TraverserTests(unittest.TestCase):
other
=
container
.
other
=
DummyObject
(
name
=
'other'
)
registerBeforeTraverse
(
container
,
other
,
'Traverser'
,
100
)
traverser
.
manage_beforeDelete
(
traverser
,
container
)
self
.
failIf
(
container
.
__before_traverse__
)
self
.
assertFalse
(
container
.
__before_traverse__
)
def
test_manage_afterAdd_item_not_self
(
self
):
traverser
=
self
.
_makeOne
()
container
=
DummyContainer
()
item
=
object
()
traverser
.
manage_afterAdd
(
item
,
container
)
self
.
failIf
(
'__before_traverse__'
in
container
.
__dict__
)
self
.
assertFalse
(
'__before_traverse__'
in
container
.
__dict__
)
def
test_manage_afterAdd_item_is_self
(
self
):
traverser
=
self
.
_makeOne
()
...
...
@@ -140,7 +140,7 @@ class SiteRootTests(unittest.TestCase):
path
=
'/before'
)
result
=
siteroot
.
manage_edit
(
'After'
,
'http://after.example.com '
,
'/after '
)
self
.
failUnless
(
result
is
None
)
self
.
assertTrue
(
result
is
None
)
self
.
assertEqual
(
siteroot
.
title
,
'After'
)
self
.
assertEqual
(
siteroot
.
base
,
'http://after.example.com'
)
self
.
assertEqual
(
siteroot
.
path
,
'/after'
)
...
...
@@ -153,7 +153,7 @@ class SiteRootTests(unittest.TestCase):
'/after '
,
REQUEST
=
{
'URL1'
:
'http://localhost:8080/manage_main'
})
self
.
failUnless
(
'<TITLE>SiteRoot changed.</TITLE>'
in
result
)
self
.
assertTrue
(
'<TITLE>SiteRoot changed.</TITLE>'
in
result
)
self
.
assertEqual
(
siteroot
.
title
,
'After'
)
self
.
assertEqual
(
siteroot
.
base
,
'http://after.example.com'
)
self
.
assertEqual
(
siteroot
.
path
,
'/after'
)
...
...
@@ -183,7 +183,7 @@ class SiteRootTests(unittest.TestCase):
self
.
assertEqual
(
request
[
'ACTUAL_URL'
],
'http://example.com/example/folder/'
)
self
.
assertEqual
(
request
.
_virtual_root
,
'/example'
)
self
.
failUnless
(
request
.
_urls_reset
)
self
.
assertTrue
(
request
.
_urls_reset
)
def
test___call___wo_SUPPRESS_SITEROOT_w_base_wo_path
(
self
):
URL
=
'http://localhost:8080/example/folder/'
...
...
@@ -201,7 +201,7 @@ class SiteRootTests(unittest.TestCase):
self
.
assertEqual
(
request
[
'ACTUAL_URL'
],
'http://example.com/example/folder/'
)
self
.
assertEqual
(
request
.
_virtual_root
,
None
)
self
.
failUnless
(
request
.
_urls_reset
)
self
.
assertTrue
(
request
.
_urls_reset
)
def
test___call___wo_SUPPRESS_SITEROOT_wo_base_w_path
(
self
):
URL
=
'http://localhost:8080/example/folder/'
...
...
@@ -218,7 +218,7 @@ class SiteRootTests(unittest.TestCase):
self
.
assertEqual
(
request
[
'SERVER_URL'
],
'http://localhost:8080'
)
self
.
assertEqual
(
request
[
'ACTUAL_URL'
],
URL
)
self
.
assertEqual
(
request
.
_virtual_root
,
'/example'
)
self
.
failIf
(
request
.
_urls_reset
)
self
.
assertFalse
(
request
.
_urls_reset
)
def
test___call___wo_SUPPRESS_SITEROOT_w_base_w_path
(
self
):
URL
=
'http://localhost:8080/example/folder/'
...
...
@@ -236,7 +236,7 @@ class SiteRootTests(unittest.TestCase):
self
.
assertEqual
(
request
[
'ACTUAL_URL'
],
'http://example.com/example/folder/'
)
self
.
assertEqual
(
request
.
_virtual_root
,
'/example'
)
self
.
failUnless
(
request
.
_urls_reset
)
self
.
assertTrue
(
request
.
_urls_reset
)
def
test_get_size
(
self
):
siteroot
=
self
.
_makeOne
()
...
...
src/Products/SiteAccess/tests/testVirtualHostMonster.py
View file @
6220f215
...
...
@@ -184,8 +184,8 @@ class VHMAddingTests(unittest.TestCase):
vhm1
=
self
.
_makeOne
()
vhm1
.
manage_addToContainer
(
self
.
root
)
self
.
failUnless
(
vhm1
.
getId
()
in
self
.
root
.
objectIds
())
self
.
failUnless
(
queryBeforeTraverse
(
self
.
root
,
vhm1
.
meta_type
))
self
.
assertTrue
(
vhm1
.
getId
()
in
self
.
root
.
objectIds
())
self
.
assertTrue
(
queryBeforeTraverse
(
self
.
root
,
vhm1
.
meta_type
))
def
test_add_manage_addVirtualHostMonster
(
self
):
from
Products.SiteAccess.VirtualHostMonster
import
\
...
...
@@ -194,9 +194,9 @@ class VHMAddingTests(unittest.TestCase):
from
ZPublisher.BeforeTraverse
import
queryBeforeTraverse
manage_addVirtualHostMonster
(
self
.
root
)
self
.
failUnless
(
VirtualHostMonster
.
id
in
self
.
root
.
objectIds
())
self
.
assertTrue
(
VirtualHostMonster
.
id
in
self
.
root
.
objectIds
())
hook
=
queryBeforeTraverse
(
self
.
root
,
VirtualHostMonster
.
meta_type
)
self
.
failUnless
(
hook
)
self
.
assertTrue
(
hook
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
...
...
src/Products/Transience/tests/testTransientObject.py
View file @
6220f215
...
...
@@ -43,7 +43,7 @@ class TestTransientObject(TestCase):
t
=
self
.
t
.
new
(
'xyzzy'
)
self
.
assert_
(
t
.
isValid
())
t
.
invalidate
()
self
.
failIf
(
t
.
isValid
())
self
.
assertFalse
(
t
.
isValid
())
def
test_getLastAccessed
(
self
):
t
=
self
.
t
.
new
(
'xyzzy'
)
...
...
@@ -98,7 +98,7 @@ class TestTransientObject(TestCase):
self
.
assertRaises
(
AttributeError
,
self
.
_genLenError
,
t
)
self
.
assertEqual
(
t
.
get
(
'foobie'
,
None
),
None
)
self
.
assert_
(
t
.
has_key
(
'a'
))
self
.
failIf
(
t
.
has_key
(
'foobie'
))
self
.
assertFalse
(
t
.
has_key
(
'foobie'
))
t
.
clear
()
self
.
assertEqual
(
len
(
t
.
keys
()),
0
)
...
...
@@ -116,7 +116,7 @@ class TestTransientObject(TestCase):
# information being visible in e.g. the ErrorLog object.
t
=
self
.
t
.
new
(
'password-storing-session'
)
t
.
set
(
'__ac_password__'
,
'secret'
)
self
.
failIf
(
repr
(
t
).
find
(
'secret'
)
!=
-
1
self
.
assertFalse
(
repr
(
t
).
find
(
'secret'
)
!=
-
1
,
'__repr__ leaks: %s'
%
repr
(
t
)
)
...
...
src/Products/Transience/tests/testTransientObjectContainer.py
View file @
6220f215
...
...
@@ -65,7 +65,7 @@ class TestTransientObjectContainer(TestCase):
def
testHasKeyWorks
(
self
):
self
.
t
[
10
]
=
1
self
.
failUnless
(
self
.
t
.
has_key
(
10
))
self
.
assertTrue
(
self
.
t
.
has_key
(
10
))
def
testValuesWorks
(
self
):
for
x
in
range
(
10
,
110
):
...
...
@@ -234,7 +234,7 @@ class TestTransientObjectContainer(TestCase):
for
x
in
delete_order
:
try
:
del
self
.
t
[
x
]
except
KeyError
:
self
.
failIf
(
self
.
t
.
has_key
(
x
))
self
.
assertFalse
(
self
.
t
.
has_key
(
x
))
def
testGetDelaysTimeout
(
self
):
for
x
in
range
(
10
,
110
):
...
...
@@ -283,7 +283,7 @@ class TestTransientObjectContainer(TestCase):
def
testResetWorks
(
self
):
self
.
t
[
10
]
=
1
self
.
t
.
_reset
()
self
.
failIf
(
self
.
t
.
get
(
10
))
self
.
assertFalse
(
self
.
t
.
get
(
10
))
def
testGetTimeoutMinutesWorks
(
self
):
self
.
assertEqual
(
self
.
t
.
getTimeoutMinutes
(),
self
.
timeout
/
60
)
...
...
@@ -293,7 +293,7 @@ class TestTransientObjectContainer(TestCase):
def
test_new
(
self
):
t
=
self
.
t
.
new
(
'foobieblech'
)
self
.
failUnless
(
issubclass
(
t
.
__class__
,
TransientObject
))
self
.
assertTrue
(
issubclass
(
t
.
__class__
,
TransientObject
))
def
_dupNewItem
(
self
):
self
.
t
.
new
(
'foobieblech'
)
...
...
src/Products/ZCatalog/tests/test_brains.py
View file @
6220f215
...
...
@@ -115,9 +115,9 @@ class TestBrains(unittest.TestCase):
def
testHasKey
(
self
):
b
=
self
.
_makeBrain
(
1
)
self
.
failUnless
(
'test_field'
in
b
)
self
.
failUnless
(
'data_record_id_'
in
b
)
self
.
failIf
(
'godel'
in
b
)
self
.
assertTrue
(
'test_field'
in
b
)
self
.
assertTrue
(
'data_record_id_'
in
b
)
self
.
assertFalse
(
'godel'
in
b
)
def
testGetPath
(
self
):
b
=
[
self
.
_makeBrain
(
rid
)
for
rid
in
range
(
3
)]
...
...
@@ -141,7 +141,7 @@ class TestBrains(unittest.TestCase):
def
testGetObjectHappy
(
self
):
b
=
self
.
_makeBrain
(
1
)
self
.
assertEqual
(
b
.
getPath
(),
'/happy'
)
self
.
failUnless
(
aq_base
(
b
.
getObject
())
is
self
.
assertTrue
(
aq_base
(
b
.
getObject
())
is
aq_base
(
self
.
cat
.
getobject
(
1
)))
def
testGetObjectPropagatesConflictErrors
(
self
):
...
...
src/Products/ZCatalog/tests/test_zcatalog.py
View file @
6220f215
...
...
@@ -390,7 +390,7 @@ class TestZCatalogGetObject(ZCatalogBase, unittest.TestCase):
pickySecurityManager
=
PickySecurityManager
([
'fold'
])
setSecurityManager
(
pickySecurityManager
)
ob
=
brain
.
getObject
()
self
.
failIf
(
ob
is
None
)
self
.
assertFalse
(
ob
is
None
)
self
.
assertEqual
(
ob
.
getId
(),
'ob'
)
# Now test _unrestrictedGetObject
...
...
src/Products/ZReST/tests/test_ZReST.py
View file @
6220f215
...
...
@@ -57,7 +57,7 @@ class TestZReST(unittest.TestCase):
resty
=
self
.
_makeOne
()
resty
.
formatted
=
'IGNORE ME'
self
.
failIf
(
'IGNORE ME'
in
resty
.
index_html
())
self
.
assertFalse
(
'IGNORE ME'
in
resty
.
index_html
())
def
testConversion
(
self
):
resty
=
self
.
_makeOne
()
...
...
@@ -129,7 +129,7 @@ class TestZReST(unittest.TestCase):
csv_file
=
self
.
_csvfile
()
resty
.
source
=
'.. csv-table::
\
n
:file: %s'
%
csv_file
result
=
resty
.
render
()
self
.
failUnless
(
'daemon'
not
in
result
,
self
.
assertTrue
(
'daemon'
not
in
result
,
'csv-table/file directive is not disabled!'
)
def
test_csv_table_url_option_raise
(
self
):
...
...
@@ -137,7 +137,7 @@ class TestZReST(unittest.TestCase):
csv_file
=
self
.
_csvfile
()
resty
.
source
=
'.. csv-table::
\
n
:url: file://%s'
%
csv_file
result
=
resty
.
render
()
self
.
failUnless
(
'daemon'
not
in
result
,
self
.
assertTrue
(
'daemon'
not
in
result
,
'csv-table/url directive is not disabled!'
)
...
...
src/Testing/ZopeTestCase/testFunctional.py
View file @
6220f215
...
...
@@ -134,7 +134,7 @@ class TestFunctional(ZopeTestCase.FunctionalTestCase):
basic
=
self
.
basic_auth
)
self
.
assertEqual
(
response
.
getStatus
(),
201
)
self
.
failUnless
(
'new_document'
in
self
.
folder
.
objectIds
())
self
.
assertTrue
(
'new_document'
in
self
.
folder
.
objectIds
())
self
.
assertEqual
(
self
.
folder
.
new_document
.
meta_type
,
'DTML Document'
)
self
.
assertEqual
(
self
.
folder
.
new_document
(),
'foo'
)
...
...
src/Testing/ZopeTestCase/testInterfaces.py
View file @
6220f215
...
...
@@ -23,14 +23,14 @@ from zope.interface.verify import verifyObject
class
TestAbstractClasses
(
TestCase
):
def
testIFunctional
(
self
):
self
.
failUnless
(
verifyClass
(
IFunctional
,
Functional
))
self
.
assertTrue
(
verifyClass
(
IFunctional
,
Functional
))
class
TestBaseTestCase
(
TestCase
):
def
testIZopeTestCase
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeTestCase
,
TestCase
))
self
.
failUnless
(
verifyObject
(
IZopeTestCase
,
self
))
self
.
assertTrue
(
verifyClass
(
IZopeTestCase
,
TestCase
))
self
.
assertTrue
(
verifyObject
(
IZopeTestCase
,
self
))
class
TestZopeTestCase
(
ZopeTestCase
):
...
...
@@ -38,12 +38,12 @@ class TestZopeTestCase(ZopeTestCase):
_setup_fixture
=
0
def
testIZopeTestCase
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeTestCase
,
ZopeTestCase
))
self
.
failUnless
(
verifyObject
(
IZopeTestCase
,
self
))
self
.
assertTrue
(
verifyClass
(
IZopeTestCase
,
ZopeTestCase
))
self
.
assertTrue
(
verifyObject
(
IZopeTestCase
,
self
))
def
testIZopeSecurity
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeSecurity
,
ZopeTestCase
))
self
.
failUnless
(
verifyObject
(
IZopeSecurity
,
self
))
self
.
assertTrue
(
verifyClass
(
IZopeSecurity
,
ZopeTestCase
))
self
.
assertTrue
(
verifyObject
(
IZopeSecurity
,
self
))
class
TestFunctionalTestCase
(
FunctionalTestCase
):
...
...
@@ -51,16 +51,16 @@ class TestFunctionalTestCase(FunctionalTestCase):
_setup_fixture
=
0
def
testIFunctional
(
self
):
self
.
failUnless
(
verifyClass
(
IFunctional
,
FunctionalTestCase
))
self
.
failUnless
(
verifyObject
(
IFunctional
,
self
))
self
.
assertTrue
(
verifyClass
(
IFunctional
,
FunctionalTestCase
))
self
.
assertTrue
(
verifyObject
(
IFunctional
,
self
))
def
testIZopeTestCase
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeTestCase
,
FunctionalTestCase
))
self
.
failUnless
(
verifyObject
(
IZopeTestCase
,
self
))
self
.
assertTrue
(
verifyClass
(
IZopeTestCase
,
FunctionalTestCase
))
self
.
assertTrue
(
verifyObject
(
IZopeTestCase
,
self
))
def
testIZopeSecurity
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeSecurity
,
FunctionalTestCase
))
self
.
failUnless
(
verifyObject
(
IZopeSecurity
,
self
))
self
.
assertTrue
(
verifyClass
(
IZopeSecurity
,
FunctionalTestCase
))
self
.
assertTrue
(
verifyObject
(
IZopeSecurity
,
self
))
class
TestPortalTestCase
(
PortalTestCase
):
...
...
@@ -71,16 +71,16 @@ class TestPortalTestCase(PortalTestCase):
return
None
def
testIZopeTestCase
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeTestCase
,
PortalTestCase
))
self
.
failUnless
(
verifyObject
(
IZopeTestCase
,
self
))
self
.
assertTrue
(
verifyClass
(
IZopeTestCase
,
PortalTestCase
))
self
.
assertTrue
(
verifyObject
(
IZopeTestCase
,
self
))
def
testIPortalTestCase
(
self
):
self
.
failUnless
(
verifyClass
(
IPortalTestCase
,
PortalTestCase
))
self
.
failUnless
(
verifyObject
(
IPortalTestCase
,
self
))
self
.
assertTrue
(
verifyClass
(
IPortalTestCase
,
PortalTestCase
))
self
.
assertTrue
(
verifyObject
(
IPortalTestCase
,
self
))
def
testIPortalSecurity
(
self
):
self
.
failUnless
(
verifyClass
(
IPortalSecurity
,
PortalTestCase
))
self
.
failUnless
(
verifyObject
(
IPortalSecurity
,
self
))
self
.
assertTrue
(
verifyClass
(
IPortalSecurity
,
PortalTestCase
))
self
.
assertTrue
(
verifyObject
(
IPortalSecurity
,
self
))
def
test_suite
():
...
...
src/Testing/ZopeTestCase/testPortalTestCase.py
View file @
6220f215
...
...
@@ -109,18 +109,18 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
# Portal should be set up
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
_portal
()
self
.
failUnless
(
hasattr_
(
self
.
app
,
portal_name
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'Members'
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'portal_membership'
))
self
.
failUnless
(
'Member'
in
self
.
portal
.
userdefined_roles
())
self
.
assertTrue
(
hasattr_
(
self
.
app
,
portal_name
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
,
'Members'
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
,
'portal_membership'
))
self
.
assertTrue
(
'Member'
in
self
.
portal
.
userdefined_roles
())
def
test_setupUserFolder
(
self
):
# User folder should be set up.
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
_portal
()
self
.
failIf
(
hasattr_
(
self
.
portal
,
'acl_users'
))
self
.
assertFalse
(
hasattr_
(
self
.
portal
,
'acl_users'
))
self
.
_setupUserFolder
()
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'acl_users'
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
,
'acl_users'
))
# Must not complain if UF already exists
self
.
_setupUserFolder
()
...
...
@@ -131,7 +131,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self
.
_setupUserFolder
()
self
.
_setupUser
()
acl_user
=
self
.
portal
.
acl_users
.
getUserById
(
user_name
)
self
.
failUnless
(
acl_user
)
self
.
assertTrue
(
acl_user
)
self
.
assertEqual
(
acl_user
.
getRoles
(),
(
'Member'
,
'Authenticated'
))
self
.
assertEqual
(
type
(
acl_user
.
roles
),
ListType
)
...
...
@@ -143,8 +143,8 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self
.
_setupUser
()
self
.
login
()
self
.
_setupHomeFolder
()
self
.
failUnless
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
self
.
failIf
(
self
.
folder
is
None
)
self
.
assertTrue
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
self
.
assertFalse
(
self
.
folder
is
None
)
# Shut up deprecation warnings
try
:
owner_info
=
self
.
folder
.
getOwnerTuple
()
except
AttributeError
:
...
...
@@ -298,7 +298,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self
.
_setupUser
()
self
.
_setupHomeFolder
()
self
.
_clear
(
1
)
self
.
failIf
(
self
.
app
.
__dict__
.
has_key
(
portal_name
))
self
.
assertFalse
(
self
.
app
.
__dict__
.
has_key
(
portal_name
))
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
self
.
assertEqual
(
self
.
_called
,
[
'beforeClose'
,
'afterClear'
])
...
...
@@ -308,14 +308,14 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setUp
(
self
):
# Everything should be set up
self
.
_setUp
()
self
.
failUnless
(
hasattr_
(
self
.
app
,
portal_name
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'acl_users'
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'Members'
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'portal_membership'
))
self
.
failUnless
(
'Member'
in
self
.
portal
.
userdefined_roles
())
self
.
failUnless
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
self
.
assertTrue
(
hasattr_
(
self
.
app
,
portal_name
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
,
'acl_users'
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
,
'Members'
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
,
'portal_membership'
))
self
.
assertTrue
(
'Member'
in
self
.
portal
.
userdefined_roles
())
self
.
assertTrue
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
acl_user
=
self
.
portal
.
acl_users
.
getUserById
(
user_name
)
self
.
failUnless
(
acl_user
)
self
.
assertTrue
(
acl_user
)
self
.
assertEqual
(
acl_user
.
getRoles
(),
(
'Member'
,
'Authenticated'
))
self
.
assertEqual
(
type
(
acl_user
.
roles
),
ListType
)
auth_name
=
getSecurityManager
().
getUser
().
getId
()
...
...
@@ -329,7 +329,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self
.
_setUp
()
self
.
_called
=
[]
self
.
_tearDown
()
self
.
failIf
(
self
.
app
.
__dict__
.
has_key
(
portal_name
))
self
.
assertFalse
(
self
.
app
.
__dict__
.
has_key
(
portal_name
))
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
self
.
assertEqual
(
self
.
_called
,
[
'beforeTearDown'
,
'beforeClose'
,
'afterClear'
])
...
...
@@ -339,7 +339,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self
.
_configure_portal
=
0
self
.
_setUp
()
self
.
assertEqual
(
self
.
portal
.
acl_users
.
getUserById
(
user_name
),
None
)
self
.
failIf
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
self
.
assertFalse
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
# XXX: Changed in 0.9.0
...
...
@@ -355,7 +355,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self
.
login
()
self
.
createMemberarea
(
user_name
)
self
.
assertEqual
(
self
.
portal
.
portal_membership
.
_called
,
[
'createMemberarea'
])
self
.
failUnless
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
def
test_createMemberarea_NewTool
(
self
):
# Should call the membership tool's createMemberArea
...
...
@@ -368,7 +368,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self
.
login
()
self
.
createMemberarea
(
user_name
)
self
.
assertEqual
(
self
.
portal
.
portal_membership
.
_called
,
[
'createMemberArea'
])
self
.
failUnless
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
# Helpers
...
...
@@ -422,16 +422,16 @@ class TestPlainUserFolder(ZopeTestCase.PortalTestCase):
def
testGetUserDoesNotWrapUser
(
self
):
user
=
self
.
portal
.
acl_users
.
getUserById
(
user_name
)
self
.
failIf
(
hasattr
(
user
,
'aq_base'
))
self
.
failUnless
(
user
is
aq_base
(
user
))
self
.
assertFalse
(
hasattr
(
user
,
'aq_base'
))
self
.
assertTrue
(
user
is
aq_base
(
user
))
def
testLoggedInUserIsWrapped
(
self
):
user
=
getSecurityManager
().
getUser
()
self
.
assertEqual
(
user
.
getId
(),
user_name
)
self
.
failUnless
(
hasattr
(
user
,
'aq_base'
))
self
.
failUnless
(
user
.
__class__
.
__name__
,
'User'
)
self
.
failUnless
(
user
.
aq_parent
.
__class__
.
__name__
,
'UserFolder'
)
self
.
failUnless
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
self
.
assertTrue
(
hasattr
(
user
,
'aq_base'
))
self
.
assertTrue
(
user
.
__class__
.
__name__
,
'User'
)
self
.
assertTrue
(
user
.
aq_parent
.
__class__
.
__name__
,
'UserFolder'
)
self
.
assertTrue
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
class
TestWrappingUserFolder
(
ZopeTestCase
.
PortalTestCase
):
...
...
@@ -446,17 +446,17 @@ class TestWrappingUserFolder(ZopeTestCase.PortalTestCase):
def
testGetUserWrapsUser
(
self
):
user
=
self
.
portal
.
acl_users
.
getUserById
(
user_name
)
self
.
failUnless
(
hasattr
(
user
,
'aq_base'
))
self
.
failIf
(
user
is
aq_base
(
user
))
self
.
failUnless
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
self
.
assertTrue
(
hasattr
(
user
,
'aq_base'
))
self
.
assertFalse
(
user
is
aq_base
(
user
))
self
.
assertTrue
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
def
testLoggedInUserIsWrapped
(
self
):
user
=
getSecurityManager
().
getUser
()
self
.
assertEqual
(
user
.
getId
(),
user_name
)
self
.
failUnless
(
hasattr
(
user
,
'aq_base'
))
self
.
failUnless
(
user
.
__class__
.
__name__
,
'User'
)
self
.
failUnless
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
self
.
failUnless
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
self
.
assertTrue
(
hasattr
(
user
,
'aq_base'
))
self
.
assertTrue
(
user
.
__class__
.
__name__
,
'User'
)
self
.
assertTrue
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
self
.
assertTrue
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
# Because we override setUp we need to test again
...
...
src/Testing/ZopeTestCase/testZODBCompat.py
View file @
6220f215
...
...
@@ -75,24 +75,24 @@ class TestCopyPaste(ZopeTestCase.ZopeTestCase):
def
testCutPaste
(
self
):
cb
=
self
.
folder
.
manage_cutObjects
([
'doc'
])
self
.
folder
.
manage_pasteObjects
(
cb
)
self
.
failUnless
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
failIf
(
hasattr
(
self
.
folder
,
'copy_of_doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
assertFalse
(
hasattr
(
self
.
folder
,
'copy_of_doc'
))
def
testCopyPaste
(
self
):
cb
=
self
.
folder
.
manage_copyObjects
([
'doc'
])
self
.
folder
.
manage_pasteObjects
(
cb
)
self
.
failUnless
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'copy_of_doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'copy_of_doc'
))
def
testClone
(
self
):
self
.
folder
.
manage_clone
(
self
.
folder
.
doc
,
'new_doc'
)
self
.
failUnless
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'new_doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'new_doc'
))
def
testRename
(
self
):
self
.
folder
.
manage_renameObjects
([
'doc'
],
[
'new_doc'
])
self
.
failIf
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'new_doc'
))
self
.
assertFalse
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'new_doc'
))
def
testCOPY
(
self
):
# WebDAV COPY
...
...
@@ -100,8 +100,8 @@ class TestCopyPaste(ZopeTestCase.ZopeTestCase):
request
.
environ
[
'HTTP_DEPTH'
]
=
'infinity'
request
.
environ
[
'HTTP_DESTINATION'
]
=
'http://foo.com/%s/new_doc'
%
folder_name
self
.
folder
.
doc
.
COPY
(
request
,
request
.
RESPONSE
)
self
.
failUnless
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'new_doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'new_doc'
))
def
testMOVE
(
self
):
# WebDAV MOVE
...
...
@@ -109,8 +109,8 @@ class TestCopyPaste(ZopeTestCase.ZopeTestCase):
request
.
environ
[
'HTTP_DEPTH'
]
=
'infinity'
request
.
environ
[
'HTTP_DESTINATION'
]
=
'http://foo.com/%s/new_doc'
%
folder_name
self
.
folder
.
doc
.
MOVE
(
request
,
request
.
RESPONSE
)
self
.
failIf
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'new_doc'
))
self
.
assertFalse
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'new_doc'
))
class
TestImportExport
(
ZopeTestCase
.
ZopeTestCase
):
...
...
@@ -125,13 +125,13 @@ class TestImportExport(ZopeTestCase.ZopeTestCase):
def
testExport
(
self
):
self
.
folder
.
manage_exportObject
(
'doc'
)
self
.
failUnless
(
os
.
path
.
exists
(
self
.
zexp_file
))
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
zexp_file
))
def
testImport
(
self
):
self
.
folder
.
manage_exportObject
(
'doc'
)
self
.
folder
.
_delObject
(
'doc'
)
self
.
folder
.
manage_importObject
(
'doc.zexp'
)
self
.
failUnless
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'doc'
))
# To make export and import happy, we have to provide a file-
# system 'import' directory and adapt the configuration a bit:
...
...
@@ -322,48 +322,48 @@ class TestTransactionAbort(ZopeTestCase.ZopeTestCase):
def
testTransactionAbort
(
self
):
self
.
folder
.
foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'foo'
))
transaction
.
abort
()
# The foo attribute is still present
self
.
failUnless
(
hasattr
(
self
.
folder
,
'foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'foo'
))
def
testSubTransactionAbort
(
self
):
self
.
folder
.
foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'foo'
))
transaction
.
savepoint
(
optimistic
=
True
)
transaction
.
abort
()
# This time the abort nukes the foo attribute...
self
.
failIf
(
hasattr
(
self
.
folder
,
'foo'
))
self
.
assertFalse
(
hasattr
(
self
.
folder
,
'foo'
))
def
testTransactionAbortPersistent
(
self
):
self
.
folder
.
_p_foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_p_foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'_p_foo'
))
transaction
.
abort
()
# The _p_foo attribute is still present
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_p_foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'_p_foo'
))
def
testSubTransactionAbortPersistent
(
self
):
self
.
folder
.
_p_foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_p_foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'_p_foo'
))
transaction
.
savepoint
(
optimistic
=
True
)
transaction
.
abort
()
# This time the abort nukes the _p_foo attribute...
self
.
failIf
(
hasattr
(
self
.
folder
,
'_p_foo'
))
self
.
assertFalse
(
hasattr
(
self
.
folder
,
'_p_foo'
))
def
testTransactionAbortVolatile
(
self
):
self
.
folder
.
_v_foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_v_foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'_v_foo'
))
transaction
.
abort
()
# The _v_foo attribute is still present
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_v_foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'_v_foo'
))
def
testSubTransactionAbortVolatile
(
self
):
self
.
folder
.
_v_foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_v_foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'_v_foo'
))
transaction
.
savepoint
(
optimistic
=
True
)
transaction
.
abort
()
# This time the abort nukes the _v_foo attribute...
self
.
failIf
(
hasattr
(
self
.
folder
,
'_v_foo'
))
self
.
assertFalse
(
hasattr
(
self
.
folder
,
'_v_foo'
))
def
test_suite
():
...
...
src/Testing/ZopeTestCase/testZopeTestCase.py
View file @
6220f215
...
...
@@ -70,9 +70,9 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
# Folder should be set up
self
.
app
=
self
.
_app
()
self
.
_setupFolder
()
self
.
failUnless
(
hasattr_
(
self
.
app
,
folder_name
))
self
.
failUnless
(
hasattr_
(
self
,
'folder'
))
self
.
failUnless
(
user_role
in
self
.
folder
.
userdefined_roles
())
self
.
assertTrue
(
hasattr_
(
self
.
app
,
folder_name
))
self
.
assertTrue
(
hasattr_
(
self
,
'folder'
))
self
.
assertTrue
(
user_role
in
self
.
folder
.
userdefined_roles
())
self
.
assertPermissionsOfRole
(
standard_permissions
,
user_role
)
def
test_setupUserFolder
(
self
):
...
...
@@ -80,7 +80,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
self
.
app
=
self
.
_app
()
self
.
_setupFolder
()
self
.
_setupUserFolder
()
self
.
failUnless
(
hasattr_
(
self
.
folder
,
'acl_users'
))
self
.
assertTrue
(
hasattr_
(
self
.
folder
,
'acl_users'
))
def
test_setupUser
(
self
):
# User should be set up
...
...
@@ -89,7 +89,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
self
.
_setupUserFolder
()
self
.
_setupUser
()
acl_user
=
self
.
folder
.
acl_users
.
getUserById
(
user_name
)
self
.
failUnless
(
acl_user
)
self
.
assertTrue
(
acl_user
)
self
.
assertEqual
(
acl_user
.
getRoles
(),
(
user_role
,
'Authenticated'
))
self
.
assertEqual
(
type
(
acl_user
.
roles
),
ListType
)
...
...
@@ -235,7 +235,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
self
.
_setupUser
()
self
.
login
()
self
.
_clear
(
1
)
self
.
failIf
(
self
.
app
.
__dict__
.
has_key
(
folder_name
))
self
.
assertFalse
(
self
.
app
.
__dict__
.
has_key
(
folder_name
))
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
self
.
assertEqual
(
self
.
_called
,
[
'beforeClose'
,
'afterClear'
])
...
...
@@ -245,13 +245,13 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
def
test_setUp
(
self
):
# Everything should be set up
self
.
_setUp
()
self
.
failUnless
(
hasattr_
(
self
.
app
,
folder_name
))
self
.
failUnless
(
hasattr_
(
self
,
'folder'
))
self
.
failUnless
(
user_role
in
self
.
folder
.
userdefined_roles
())
self
.
assertTrue
(
hasattr_
(
self
.
app
,
folder_name
))
self
.
assertTrue
(
hasattr_
(
self
,
'folder'
))
self
.
assertTrue
(
user_role
in
self
.
folder
.
userdefined_roles
())
self
.
assertPermissionsOfRole
(
standard_permissions
,
user_role
)
self
.
failUnless
(
hasattr_
(
self
.
folder
,
'acl_users'
))
self
.
assertTrue
(
hasattr_
(
self
.
folder
,
'acl_users'
))
acl_user
=
self
.
folder
.
acl_users
.
getUserById
(
user_name
)
self
.
failUnless
(
acl_user
)
self
.
assertTrue
(
acl_user
)
self
.
assertEqual
(
acl_user
.
getRoles
(),
(
user_role
,
'Authenticated'
))
self
.
assertEqual
(
type
(
acl_user
.
roles
),
ListType
)
auth_name
=
getSecurityManager
().
getUser
().
getId
()
...
...
@@ -265,7 +265,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
self
.
_setUp
()
self
.
_called
=
[]
self
.
_tearDown
()
self
.
failIf
(
self
.
app
.
__dict__
.
has_key
(
folder_name
))
self
.
assertFalse
(
self
.
app
.
__dict__
.
has_key
(
folder_name
))
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
self
.
assertEqual
(
self
.
_called
,
[
'beforeTearDown'
,
'beforeClose'
,
'afterClear'
])
...
...
@@ -274,7 +274,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
# Nothing should be set up
self
.
_setup_fixture
=
0
self
.
_setUp
()
self
.
failIf
(
hasattr_
(
self
.
app
,
folder_name
))
self
.
assertFalse
(
hasattr_
(
self
.
app
,
folder_name
))
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
# XXX: Changed in 0.9.0
...
...
@@ -362,16 +362,16 @@ class TestPlainUserFolder(ZopeTestCase.ZopeTestCase):
def
testGetUserDoesNotWrapUser
(
self
):
user
=
self
.
folder
.
acl_users
.
getUserById
(
user_name
)
self
.
failIf
(
hasattr
(
user
,
'aq_base'
))
self
.
failUnless
(
user
is
aq_base
(
user
))
self
.
assertFalse
(
hasattr
(
user
,
'aq_base'
))
self
.
assertTrue
(
user
is
aq_base
(
user
))
def
testLoggedInUserIsWrapped
(
self
):
user
=
getSecurityManager
().
getUser
()
self
.
assertEqual
(
user
.
getId
(),
user_name
)
self
.
failUnless
(
hasattr
(
user
,
'aq_base'
))
self
.
failUnless
(
user
.
__class__
.
__name__
,
'User'
)
self
.
failUnless
(
user
.
aq_parent
.
__class__
.
__name__
,
'UserFolder'
)
self
.
failUnless
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
self
.
assertTrue
(
hasattr
(
user
,
'aq_base'
))
self
.
assertTrue
(
user
.
__class__
.
__name__
,
'User'
)
self
.
assertTrue
(
user
.
aq_parent
.
__class__
.
__name__
,
'UserFolder'
)
self
.
assertTrue
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
class
TestWrappingUserFolder
(
ZopeTestCase
.
ZopeTestCase
):
...
...
@@ -382,17 +382,17 @@ class TestWrappingUserFolder(ZopeTestCase.ZopeTestCase):
def
testGetUserWrapsUser
(
self
):
user
=
self
.
folder
.
acl_users
.
getUserById
(
user_name
)
self
.
failUnless
(
hasattr
(
user
,
'aq_base'
))
self
.
failIf
(
user
is
aq_base
(
user
))
self
.
failUnless
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
self
.
assertTrue
(
hasattr
(
user
,
'aq_base'
))
self
.
assertFalse
(
user
is
aq_base
(
user
))
self
.
assertTrue
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
def
testLoggedInUserIsWrapped
(
self
):
user
=
getSecurityManager
().
getUser
()
self
.
assertEqual
(
user
.
getId
(),
user_name
)
self
.
failUnless
(
hasattr
(
user
,
'aq_base'
))
self
.
failUnless
(
user
.
__class__
.
__name__
,
'User'
)
self
.
failUnless
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
self
.
failUnless
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
self
.
assertTrue
(
hasattr
(
user
,
'aq_base'
))
self
.
assertTrue
(
user
.
__class__
.
__name__
,
'User'
)
self
.
assertTrue
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
self
.
assertTrue
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
def
test_suite
():
...
...
src/Testing/tests/test_makerequest.py
View file @
6220f215
...
...
@@ -26,9 +26,9 @@ class MakerequestTests(unittest.TestCase):
self
.
assertRaises
(
AttributeError
,
makerequest
,
object
())
# After the call, it will have a REQUEST attribute.
item
=
Implicit
()
self
.
failIf
(
hasattr
(
item
,
'REQUEST'
))
self
.
assertFalse
(
hasattr
(
item
,
'REQUEST'
))
item
=
makerequest
(
item
)
self
.
failUnless
(
hasattr
(
item
,
'REQUEST'
))
self
.
assertTrue
(
hasattr
(
item
,
'REQUEST'
))
def
test_dont_break_getPhysicalPath
(
self
):
# see http://www.zope.org/Collectors/Zope/2057. If you want
...
...
@@ -49,8 +49,8 @@ class MakerequestTests(unittest.TestCase):
item
.
REQUEST
.
RESPONSE
.
write
(
'aaa'
)
out
.
seek
(
0
)
written
=
out
.
read
()
self
.
failUnless
(
written
.
startswith
(
'Status: 200 OK
\
r
\
n
'
))
self
.
failUnless
(
written
.
endswith
(
'
\
n
aaa'
))
self
.
assertTrue
(
written
.
startswith
(
'Status: 200 OK
\
r
\
n
'
))
self
.
assertTrue
(
written
.
endswith
(
'
\
n
aaa'
))
def
test_environ
(
self
):
# You can pass an environ argument to use in the request.
...
...
src/ZPublisher/tests/testHTTPRangeSupport.py
View file @
6220f215
...
...
@@ -21,11 +21,11 @@ class TestRangeHeaderParse(unittest.TestCase):
# Utility methods
def
expectNone
(
self
,
header
):
result
=
parseRange
(
header
)
self
.
failUnless
(
result
is
None
,
'Expected None, got %s'
%
`result`
)
self
.
assertTrue
(
result
is
None
,
'Expected None, got %s'
%
`result`
)
def
expectSets
(
self
,
header
,
sets
):
result
=
parseRange
(
header
)
self
.
failUnless
(
result
==
sets
,
self
.
assertTrue
(
result
==
sets
,
'Expected %s, got %s'
%
(
`sets`
,
`result`
))
# Syntactically incorrect headers
...
...
@@ -81,7 +81,7 @@ class TestExpandRanges(unittest.TestCase):
def
expectSets
(
self
,
sets
,
size
,
expect
):
result
=
expandRanges
(
sets
,
size
)
self
.
failUnless
(
result
==
expect
,
self
.
assertTrue
(
result
==
expect
,
'Expected %s, got %s'
%
(
`expect`
,
`result`
))
def
testExpandOpenEnd
(
self
):
...
...
src/ZPublisher/tests/testHTTPRequest.py
View file @
6220f215
...
...
@@ -72,7 +72,7 @@ class HTTPRequestTests(unittest.TestCase):
return
req
def
_noTaintedValues
(
self
,
req
):
self
.
failIf
(
req
.
taintedform
.
keys
())
self
.
assertFalse
(
req
.
taintedform
.
keys
())
def
_valueIsOrHoldsTainted
(
self
,
val
):
# Recursively searches a structure for a TaintedString and returns 1
...
...
@@ -85,7 +85,7 @@ class HTTPRequestTests(unittest.TestCase):
retval
=
0
if
isinstance
(
val
,
TaintedString
):
self
.
failIf
(
not
'<'
in
val
,
self
.
assertFalse
(
not
'<'
in
val
,
"%r is not dangerous, no taint required."
%
val
)
retval
=
1
...
...
@@ -102,18 +102,18 @@ class HTTPRequestTests(unittest.TestCase):
if
rval
:
retval
=
1
elif
type
(
val
)
in
(
str
,
unicode
):
self
.
failIf
(
'<'
in
val
,
self
.
assertFalse
(
'<'
in
val
,
"'%s' is dangerous and should have been tainted."
%
val
)
return
retval
def
_noFormValuesInOther
(
self
,
req
):
for
key
in
req
.
taintedform
.
keys
():
self
.
failIf
(
req
.
other
.
has_key
(
key
),
self
.
assertFalse
(
req
.
other
.
has_key
(
key
),
'REQUEST.other should not hold tainted values at first!'
)
for
key
in
req
.
form
.
keys
():
self
.
failIf
(
req
.
other
.
has_key
(
key
),
self
.
assertFalse
(
req
.
other
.
has_key
(
key
),
'REQUEST.other should not hold form values at first!'
)
def
_onlyTaintedformHoldsTaintedStrings
(
self
,
req
):
...
...
@@ -125,7 +125,7 @@ class HTTPRequestTests(unittest.TestCase):
for
key
,
val
in
req
.
form
.
items
():
if
req
.
taintedform
.
has_key
(
key
):
continue
self
.
failIf
(
self
.
_valueIsOrHoldsTainted
(
key
)
or
self
.
assertFalse
(
self
.
_valueIsOrHoldsTainted
(
key
)
or
self
.
_valueIsOrHoldsTainted
(
val
),
'Normal form holds item %s that is tainted'
%
key
)
...
...
@@ -579,10 +579,10 @@ class HTTPRequestTests(unittest.TestCase):
try
:
convert
(
'<html garbage>'
)
except
Exception
,
e
:
self
.
failIf
(
'<'
in
e
.
args
,
self
.
assertFalse
(
'<'
in
e
.
args
,
'%s converter does not quote unsafe value!'
%
type
)
except
DateTime
.
SyntaxError
,
e
:
self
.
failIf
(
'<'
in
e
,
self
.
assertFalse
(
'<'
in
e
,
'%s converter does not quote unsafe value!'
%
type
)
def
test_processInputs_w_dotted_name_as_tuple
(
self
):
...
...
@@ -977,7 +977,7 @@ class HTTPRequestTests(unittest.TestCase):
request
=
self
.
_makeOne
(
None
,
TEST_ENVIRON
.
copy
(),
DummyResponse
())
request
[
'PARENTS'
]
=
[
object
()]
clone
=
request
.
clone
()
self
.
failUnless
(
isinstance
(
clone
.
response
,
DummyResponse
))
self
.
assertTrue
(
isinstance
(
clone
.
response
,
DummyResponse
))
def
test_clone_preserves_request_subclass
(
self
):
class
SubRequest
(
self
.
_getTargetClass
()):
...
...
@@ -985,7 +985,7 @@ class HTTPRequestTests(unittest.TestCase):
request
=
SubRequest
(
None
,
TEST_ENVIRON
.
copy
(),
None
)
request
[
'PARENTS'
]
=
[
object
()]
clone
=
request
.
clone
()
self
.
failUnless
(
isinstance
(
clone
,
SubRequest
))
self
.
assertTrue
(
isinstance
(
clone
,
SubRequest
))
def
test_clone_preserves_direct_interfaces
(
self
):
from
zope.interface
import
directlyProvides
...
...
@@ -996,7 +996,7 @@ class HTTPRequestTests(unittest.TestCase):
request
[
'PARENTS'
]
=
[
object
()]
directlyProvides
(
request
,
IFoo
)
clone
=
request
.
clone
()
self
.
failUnless
(
IFoo
.
providedBy
(
clone
))
self
.
assertTrue
(
IFoo
.
providedBy
(
clone
))
def
test_resolve_url_doesnt_send_endrequestevent
(
self
):
import
zope.event
...
...
@@ -1008,7 +1008,7 @@ class HTTPRequestTests(unittest.TestCase):
request
.
resolve_url
(
request
.
script
+
'/'
)
finally
:
zope
.
event
.
subscribers
.
remove
(
events
.
append
)
self
.
failIf
(
len
(
events
),
self
.
assertFalse
(
len
(
events
),
"HTTPRequest.resolve_url should not emit events"
)
def
test_resolve_url_errorhandling
(
self
):
...
...
src/ZPublisher/tests/testHTTPResponse.py
View file @
6220f215
...
...
@@ -34,8 +34,8 @@ class HTTPResponseTests(unittest.TestCase):
self
.
assertEqual
(
response
.
base
,
''
)
self
.
assertEqual
(
response
.
body
,
''
)
self
.
assertEqual
(
response
.
cookies
,
{})
self
.
failUnless
(
response
.
stdout
is
sys
.
stdout
)
self
.
failUnless
(
response
.
stderr
is
sys
.
stderr
)
self
.
assertTrue
(
response
.
stdout
is
sys
.
stdout
)
self
.
assertTrue
(
response
.
stderr
is
sys
.
stderr
)
def
test_ctor_w_body
(
self
):
response
=
self
.
_makeOne
(
body
=
'ABC'
)
...
...
@@ -125,9 +125,9 @@ class HTTPResponseTests(unittest.TestCase):
STDOUT
,
STDERR
=
object
(),
object
()
response
=
self
.
_makeOne
(
stdout
=
STDOUT
,
stderr
=
STDERR
)
cloned
=
response
.
retry
()
self
.
failUnless
(
isinstance
(
cloned
,
self
.
_getTargetClass
()))
self
.
failUnless
(
cloned
.
stdout
is
STDOUT
)
self
.
failUnless
(
cloned
.
stderr
is
STDERR
)
self
.
assertTrue
(
isinstance
(
cloned
,
self
.
_getTargetClass
()))
self
.
assertTrue
(
cloned
.
stdout
is
STDOUT
)
self
.
assertTrue
(
cloned
.
stderr
is
STDERR
)
def
test_setStatus_code
(
self
):
response
=
self
.
_makeOne
()
...
...
@@ -216,7 +216,7 @@ class HTTPResponseTests(unittest.TestCase):
response
=
self
.
_makeOne
()
response
.
setCookie
(
'foo'
,
'bar'
,
expires
=
EXPIRES
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
self
.
failUnless
(
cookie
)
self
.
assertTrue
(
cookie
)
self
.
assertEqual
(
cookie
.
get
(
'value'
),
'bar'
)
self
.
assertEqual
(
cookie
.
get
(
'expires'
),
EXPIRES
)
self
.
assertEqual
(
cookie
.
get
(
'quoted'
),
True
)
...
...
@@ -336,7 +336,7 @@ class HTTPResponseTests(unittest.TestCase):
response
.
setCookie
(
'foo'
,
'bar'
,
path
=
'/'
)
response
.
appendCookie
(
'foo'
,
'baz'
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
self
.
failUnless
(
cookie
)
self
.
assertTrue
(
cookie
)
self
.
assertEqual
(
cookie
.
get
(
'value'
),
'bar:baz'
)
self
.
assertEqual
(
cookie
.
get
(
'path'
),
'/'
)
...
...
@@ -344,14 +344,14 @@ class HTTPResponseTests(unittest.TestCase):
response
=
self
.
_makeOne
()
response
.
appendCookie
(
'foo'
,
'baz'
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
self
.
failUnless
(
cookie
)
self
.
assertTrue
(
cookie
)
self
.
assertEqual
(
cookie
.
get
(
'value'
),
'baz'
)
def
test_expireCookie
(
self
):
response
=
self
.
_makeOne
()
response
.
expireCookie
(
'foo'
,
path
=
'/'
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
self
.
failUnless
(
cookie
)
self
.
assertTrue
(
cookie
)
self
.
assertEqual
(
cookie
.
get
(
'expires'
),
'Wed, 31-Dec-97 23:59:59 GMT'
)
self
.
assertEqual
(
cookie
.
get
(
'max_age'
),
0
)
self
.
assertEqual
(
cookie
.
get
(
'path'
),
'/'
)
...
...
@@ -363,7 +363,7 @@ class HTTPResponseTests(unittest.TestCase):
response
.
expireCookie
(
'foo'
,
path
=
'/'
,
expires
=
'Mon, 22-Mar-2004 17:59 GMT'
,
max_age
=
99
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
self
.
failUnless
(
cookie
)
self
.
assertTrue
(
cookie
)
self
.
assertEqual
(
cookie
.
get
(
'expires'
),
'Wed, 31-Dec-97 23:59:59 GMT'
)
self
.
assertEqual
(
cookie
.
get
(
'max_age'
),
0
)
self
.
assertEqual
(
cookie
.
get
(
'path'
),
'/'
)
...
...
@@ -539,14 +539,14 @@ class HTTPResponseTests(unittest.TestCase):
response
=
self
.
_makeOne
()
response
.
setBody
(
'BEFORE'
,
lock
=
True
)
result
=
response
.
setBody
(
'AFTER'
)
self
.
failIf
(
result
)
self
.
assertFalse
(
result
)
self
.
assertEqual
(
response
.
body
,
'BEFORE'
)
def
test_setBody_empty_unchanged
(
self
):
response
=
self
.
_makeOne
()
response
.
body
=
'BEFORE'
result
=
response
.
setBody
(
''
)
self
.
failUnless
(
result
)
self
.
assertTrue
(
result
)
self
.
assertEqual
(
response
.
body
,
'BEFORE'
)
self
.
assertEqual
(
response
.
getHeader
(
'Content-Type'
),
None
)
self
.
assertEqual
(
response
.
getHeader
(
'Content-Length'
),
None
)
...
...
@@ -559,7 +559,7 @@ class HTTPResponseTests(unittest.TestCase):
response
=
self
.
_makeOne
()
response
.
body
=
'BEFORE'
result
=
response
.
setBody
((
'TITLE'
,
'BODY'
))
self
.
failUnless
(
result
)
self
.
assertTrue
(
result
)
self
.
assertEqual
(
response
.
body
,
EXPECTED
)
self
.
assertEqual
(
response
.
getHeader
(
'Content-Type'
),
'text/html; charset=iso-8859-15'
)
...
...
@@ -570,18 +570,18 @@ class HTTPResponseTests(unittest.TestCase):
response
=
self
.
_makeOne
()
response
.
body
=
'BEFORE'
result
=
response
.
setBody
((
'TITLE'
,
'BODY'
),
is_error
=
True
)
self
.
failUnless
(
result
)
self
.
failIf
(
'BEFORE'
in
response
.
body
)
self
.
failUnless
(
'<h2>Site Error</h2>'
in
response
.
body
)
self
.
failUnless
(
'TITLE'
in
response
.
body
)
self
.
failUnless
(
'BODY'
in
response
.
body
)
self
.
assertTrue
(
result
)
self
.
assertFalse
(
'BEFORE'
in
response
.
body
)
self
.
assertTrue
(
'<h2>Site Error</h2>'
in
response
.
body
)
self
.
assertTrue
(
'TITLE'
in
response
.
body
)
self
.
assertTrue
(
'BODY'
in
response
.
body
)
self
.
assertEqual
(
response
.
getHeader
(
'Content-Type'
),
'text/html; charset=iso-8859-15'
)
def
test_setBody_string_not_HTML
(
self
):
response
=
self
.
_makeOne
()
result
=
response
.
setBody
(
'BODY'
)
self
.
failUnless
(
result
)
self
.
assertTrue
(
result
)
self
.
assertEqual
(
response
.
body
,
'BODY'
)
self
.
assertEqual
(
response
.
getHeader
(
'Content-Type'
),
'text/plain; charset=iso-8859-15'
)
...
...
@@ -591,7 +591,7 @@ class HTTPResponseTests(unittest.TestCase):
HTML
=
'<html><head></head><body></body></html>'
response
=
self
.
_makeOne
()
result
=
response
.
setBody
(
HTML
)
self
.
failUnless
(
result
)
self
.
assertTrue
(
result
)
self
.
assertEqual
(
response
.
body
,
HTML
)
self
.
assertEqual
(
response
.
getHeader
(
'Content-Type'
),
'text/html; charset=iso-8859-15'
)
...
...
@@ -604,7 +604,7 @@ class HTTPResponseTests(unittest.TestCase):
return
HTML
response
=
self
.
_makeOne
()
result
=
response
.
setBody
(
Dummy
())
self
.
failUnless
(
result
)
self
.
assertTrue
(
result
)
self
.
assertEqual
(
response
.
body
,
HTML
)
self
.
assertEqual
(
response
.
getHeader
(
'Content-Type'
),
'text/html; charset=iso-8859-15'
)
...
...
@@ -615,7 +615,7 @@ class HTTPResponseTests(unittest.TestCase):
ENCODED
=
HTML
.
encode
(
'iso-8859-15'
)
response
=
self
.
_makeOne
()
result
=
response
.
setBody
(
HTML
)
self
.
failUnless
(
result
)
self
.
assertTrue
(
result
)
self
.
assertEqual
(
response
.
body
,
ENCODED
)
self
.
assertEqual
(
response
.
getHeader
(
'Content-Type'
),
'text/html; charset=iso-8859-15'
)
...
...
@@ -640,7 +640,7 @@ class HTTPResponseTests(unittest.TestCase):
'<p>GT: ></p></body></html>'
)
response
.
setHeader
(
'Content-Type'
,
'text/html'
)
result
=
response
.
setBody
(
BEFORE
)
self
.
failUnless
(
result
)
self
.
assertTrue
(
result
)
self
.
assertEqual
(
response
.
body
,
AFTER
)
self
.
assertEqual
(
response
.
getHeader
(
'Content-Length'
),
str
(
len
(
AFTER
)))
...
...
@@ -652,7 +652,7 @@ class HTTPResponseTests(unittest.TestCase):
'<p>GT: ></p></body></html>'
)
response
.
setHeader
(
'Content-Type'
,
'text/html; charset=latin1'
)
result
=
response
.
setBody
(
BEFORE
)
self
.
failUnless
(
result
)
self
.
assertTrue
(
result
)
self
.
assertEqual
(
response
.
body
,
AFTER
)
self
.
assertEqual
(
response
.
getHeader
(
'Content-Length'
),
str
(
len
(
AFTER
)))
...
...
@@ -673,7 +673,7 @@ class HTTPResponseTests(unittest.TestCase):
response
.
setHeader
(
'Content-Type'
,
'image/jpeg'
)
response
.
enableHTTPCompression
({
'HTTP_ACCEPT_ENCODING'
:
'gzip'
})
response
.
setBody
(
BEFORE
)
self
.
failIf
(
response
.
getHeader
(
'Content-Encoding'
))
self
.
assertFalse
(
response
.
getHeader
(
'Content-Encoding'
))
self
.
assertEqual
(
response
.
body
,
BEFORE
)
def
test_setBody_compression_existing_encoding
(
self
):
...
...
@@ -690,7 +690,7 @@ class HTTPResponseTests(unittest.TestCase):
response
=
self
.
_makeOne
()
response
.
enableHTTPCompression
({
'HTTP_ACCEPT_ENCODING'
:
'gzip'
})
response
.
setBody
(
BEFORE
)
self
.
failIf
(
response
.
getHeader
(
'Content-Encoding'
))
self
.
assertFalse
(
response
.
getHeader
(
'Content-Encoding'
))
self
.
assertEqual
(
response
.
body
,
BEFORE
)
def
test_setBody_compression_no_prior_vary_header
(
self
):
...
...
@@ -698,7 +698,7 @@ class HTTPResponseTests(unittest.TestCase):
response
=
self
.
_makeOne
()
response
.
enableHTTPCompression
({
'HTTP_ACCEPT_ENCODING'
:
'gzip'
})
response
.
setBody
(
'foo'
*
100
)
# body must get smaller on compression
self
.
failUnless
(
'Accept-Encoding'
in
response
.
getHeader
(
'Vary'
))
self
.
assertTrue
(
'Accept-Encoding'
in
response
.
getHeader
(
'Vary'
))
def
test_setBody_compression_w_prior_vary_header_wo_encoding
(
self
):
# Vary header should be added here
...
...
@@ -706,7 +706,7 @@ class HTTPResponseTests(unittest.TestCase):
response
.
setHeader
(
'Vary'
,
'Cookie'
)
response
.
enableHTTPCompression
({
'HTTP_ACCEPT_ENCODING'
:
'gzip'
})
response
.
setBody
(
'foo'
*
100
)
# body must get smaller on compression
self
.
failUnless
(
'Accept-Encoding'
in
response
.
getHeader
(
'Vary'
))
self
.
assertTrue
(
'Accept-Encoding'
in
response
.
getHeader
(
'Vary'
))
def
test_setBody_compression_w_prior_vary_header_incl_encoding
(
self
):
# Vary header already had Accept-Ecoding', do'nt munge
...
...
@@ -732,7 +732,7 @@ class HTTPResponseTests(unittest.TestCase):
self
.
assertEqual
(
result
,
URL
)
self
.
assertEqual
(
response
.
status
,
302
)
self
.
assertEqual
(
response
.
getHeader
(
'Location'
),
URL
)
self
.
failIf
(
response
.
_locked_status
)
self
.
assertFalse
(
response
.
_locked_status
)
def
test_redirect_explicit_status
(
self
):
URL
=
'http://example.com'
...
...
@@ -740,7 +740,7 @@ class HTTPResponseTests(unittest.TestCase):
result
=
response
.
redirect
(
URL
,
status
=
307
)
self
.
assertEqual
(
response
.
status
,
307
)
self
.
assertEqual
(
response
.
getHeader
(
'Location'
),
URL
)
self
.
failIf
(
response
.
_locked_status
)
self
.
assertFalse
(
response
.
_locked_status
)
def
test_redirect_w_lock
(
self
):
URL
=
'http://example.com'
...
...
@@ -748,7 +748,7 @@ class HTTPResponseTests(unittest.TestCase):
result
=
response
.
redirect
(
URL
,
lock
=
True
)
self
.
assertEqual
(
response
.
status
,
302
)
self
.
assertEqual
(
response
.
getHeader
(
'Location'
),
URL
)
self
.
failUnless
(
response
.
_locked_status
)
self
.
assertTrue
(
response
.
_locked_status
)
def
test__encode_unicode_no_content_type_uses_default_encoding
(
self
):
self
.
_setDefaultEncoding
(
'UTF8'
)
...
...
@@ -801,7 +801,7 @@ class HTTPResponseTests(unittest.TestCase):
response
.
notFoundError
()
except
NotFound
,
raised
:
self
.
assertEqual
(
response
.
status
,
404
)
self
.
failUnless
(
"<p><b>Resource:</b> Unknown</p>"
in
str
(
raised
))
self
.
assertTrue
(
"<p><b>Resource:</b> Unknown</p>"
in
str
(
raised
))
else
:
self
.
fail
(
"Didn't raise NotFound"
)
...
...
@@ -812,7 +812,7 @@ class HTTPResponseTests(unittest.TestCase):
response
.
notFoundError
(
'ENTRY'
)
except
NotFound
,
raised
:
self
.
assertEqual
(
response
.
status
,
404
)
self
.
failUnless
(
"<p><b>Resource:</b> ENTRY</p>"
in
str
(
raised
))
self
.
assertTrue
(
"<p><b>Resource:</b> ENTRY</p>"
in
str
(
raised
))
else
:
self
.
fail
(
"Didn't raise NotFound"
)
...
...
@@ -823,7 +823,7 @@ class HTTPResponseTests(unittest.TestCase):
response
.
forbiddenError
()
except
NotFound
,
raised
:
self
.
assertEqual
(
response
.
status
,
404
)
self
.
failUnless
(
"<p><b>Resource:</b> Unknown</p>"
in
str
(
raised
))
self
.
assertTrue
(
"<p><b>Resource:</b> Unknown</p>"
in
str
(
raised
))
else
:
self
.
fail
(
"Didn't raise NotFound"
)
...
...
@@ -834,7 +834,7 @@ class HTTPResponseTests(unittest.TestCase):
response
.
forbiddenError
(
'ENTRY'
)
except
NotFound
,
raised
:
self
.
assertEqual
(
response
.
status
,
404
)
self
.
failUnless
(
"<p><b>Resource:</b> ENTRY</p>"
in
str
(
raised
))
self
.
assertTrue
(
"<p><b>Resource:</b> ENTRY</p>"
in
str
(
raised
))
else
:
self
.
fail
(
"Didn't raise NotFound"
)
...
...
@@ -845,7 +845,7 @@ class HTTPResponseTests(unittest.TestCase):
response
.
debugError
(
'testing'
)
except
NotFound
,
raised
:
self
.
assertEqual
(
response
.
status
,
200
)
self
.
failUnless
(
"Zope has encountered a problem publishing "
self
.
assertTrue
(
"Zope has encountered a problem publishing "
"your object.<p>
\
n
testing</p>"
in
str
(
raised
))
else
:
self
.
fail
(
"Didn't raise NotFound"
)
...
...
@@ -857,7 +857,7 @@ class HTTPResponseTests(unittest.TestCase):
response
.
badRequestError
(
'some_parameter'
)
except
BadRequest
,
raised
:
self
.
assertEqual
(
response
.
status
,
400
)
self
.
failUnless
(
"The parameter, <em>some_parameter</em>, "
self
.
assertTrue
(
"The parameter, <em>some_parameter</em>, "
"was omitted from the request."
in
str
(
raised
))
else
:
self
.
fail
(
"Didn't raise BadRequest"
)
...
...
@@ -869,7 +869,7 @@ class HTTPResponseTests(unittest.TestCase):
response
.
badRequestError
(
'URL1'
)
except
InternalError
,
raised
:
self
.
assertEqual
(
response
.
status
,
400
)
self
.
failUnless
(
"Sorry, an internal error occurred in this "
self
.
assertTrue
(
"Sorry, an internal error occurred in this "
"resource."
in
str
(
raised
))
else
:
self
.
fail
(
"Didn't raise InternalError"
)
...
...
@@ -878,12 +878,12 @@ class HTTPResponseTests(unittest.TestCase):
response
=
self
.
_makeOne
()
response
.
realm
=
''
response
.
_unauthorized
()
self
.
failIf
(
'WWW-Authenticate'
in
response
.
headers
)
self
.
assertFalse
(
'WWW-Authenticate'
in
response
.
headers
)
def
test__unauthorized_w_default_realm
(
self
):
response
=
self
.
_makeOne
()
response
.
_unauthorized
()
self
.
failUnless
(
'WWW-Authenticate'
in
response
.
headers
)
#literal
self
.
assertTrue
(
'WWW-Authenticate'
in
response
.
headers
)
#literal
self
.
assertEqual
(
response
.
headers
[
'WWW-Authenticate'
],
'basic realm="Zope"'
)
...
...
@@ -891,7 +891,7 @@ class HTTPResponseTests(unittest.TestCase):
response
=
self
.
_makeOne
()
response
.
realm
=
'Folly'
response
.
_unauthorized
()
self
.
failUnless
(
'WWW-Authenticate'
in
response
.
headers
)
#literal
self
.
assertTrue
(
'WWW-Authenticate'
in
response
.
headers
)
#literal
self
.
assertEqual
(
response
.
headers
[
'WWW-Authenticate'
],
'basic realm="Folly"'
)
...
...
@@ -902,7 +902,7 @@ class HTTPResponseTests(unittest.TestCase):
response
.
unauthorized
()
except
Unauthorized
,
raised
:
self
.
assertEqual
(
response
.
status
,
200
)
# publisher sets 401 later
self
.
failUnless
(
"<strong>You are not authorized "
self
.
assertTrue
(
"<strong>You are not authorized "
"to access this resource.</strong>"
in
str
(
raised
))
else
:
self
.
fail
(
"Didn't raise Unauthorized"
)
...
...
@@ -914,7 +914,7 @@ class HTTPResponseTests(unittest.TestCase):
try
:
response
.
unauthorized
()
except
Unauthorized
,
raised
:
self
.
failUnless
(
"<p>
\
n
No Authorization header found.</p>"
self
.
assertTrue
(
"<p>
\
n
No Authorization header found.</p>"
in
str
(
raised
))
else
:
self
.
fail
(
"Didn't raise Unauthorized"
)
...
...
@@ -927,7 +927,7 @@ class HTTPResponseTests(unittest.TestCase):
try
:
response
.
unauthorized
()
except
Unauthorized
,
raised
:
self
.
failUnless
(
"<p>
\
n
Username and password are not correct.</p>"
self
.
assertTrue
(
"<p>
\
n
Username and password are not correct.</p>"
in
str
(
raised
))
else
:
self
.
fail
(
"Didn't raise Unauthorized"
)
...
...
@@ -1260,7 +1260,7 @@ class HTTPResponseTests(unittest.TestCase):
stdout
=
StringIO
()
response
=
self
.
_makeOne
(
stdout
=
stdout
)
response
.
write
(
'Kilroy was here!'
)
self
.
failUnless
(
response
.
_wrote
)
self
.
assertTrue
(
response
.
_wrote
)
lines
=
stdout
.
getvalue
().
split
(
'
\
r
\
n
'
)
self
.
assertEqual
(
len
(
lines
),
5
)
self
.
assertEqual
(
lines
[
0
],
'Status: 200 OK'
)
...
...
@@ -1292,8 +1292,8 @@ class HTTPResponseTests(unittest.TestCase):
"<type 'exceptions.AttributeError'>"
)
self
.
assertEqual
(
response
.
headers
[
'bobo-exception-value'
],
'See the server error log for details'
)
self
.
failUnless
(
'bobo-exception-file'
in
response
.
headers
)
self
.
failUnless
(
'bobo-exception-line'
in
response
.
headers
)
self
.
assertTrue
(
'bobo-exception-file'
in
response
.
headers
)
self
.
assertTrue
(
'bobo-exception-line'
in
response
.
headers
)
finally
:
del
tb
...
...
@@ -1303,7 +1303,7 @@ class HTTPResponseTests(unittest.TestCase):
raise
AttributeError
(
'ERROR VALUE'
)
except
AttributeError
:
body
=
response
.
exception
()
self
.
failUnless
(
'ERROR VALUE'
in
str
(
body
))
self
.
assertTrue
(
'ERROR VALUE'
in
str
(
body
))
self
.
assertEqual
(
response
.
status
,
500
)
self
.
assertEqual
(
response
.
errmsg
,
'Internal Server Error'
)
# required by Bobo Call Interface (BCI)
...
...
@@ -1311,8 +1311,8 @@ class HTTPResponseTests(unittest.TestCase):
"<type 'exceptions.AttributeError'>"
)
self
.
assertEqual
(
response
.
headers
[
'bobo-exception-value'
],
'See the server error log for details'
)
self
.
failUnless
(
'bobo-exception-file'
in
response
.
headers
)
self
.
failUnless
(
'bobo-exception-line'
in
response
.
headers
)
self
.
assertTrue
(
'bobo-exception-file'
in
response
.
headers
)
self
.
assertTrue
(
'bobo-exception-line'
in
response
.
headers
)
#TODO
# def test_exception_* WAAAAAA!
...
...
src/ZPublisher/tests/test_WSGIPublisher.py
View file @
6220f215
...
...
@@ -53,7 +53,7 @@ class WSGIResponseTests(unittest.TestCase):
response
.
_streaming
=
True
response
.
body
=
'TESTING'
response
.
finalize
()
self
.
failIf
(
response
.
getHeader
(
'Content-Length'
))
self
.
assertFalse
(
response
.
getHeader
(
'Content-Length'
))
def
test_finalize_HTTP_1_0_keep_alive_w_content_length
(
self
):
response
=
self
.
_makeOne
()
...
...
@@ -93,7 +93,7 @@ class WSGIResponseTests(unittest.TestCase):
response
.
finalize
()
self
.
assertEqual
(
response
.
getHeader
(
'Connection'
),
'close'
)
self
.
assertEqual
(
response
.
getHeader
(
'Transfer-Encoding'
),
None
)
self
.
failIf
(
response
.
_chunking
)
self
.
assertFalse
(
response
.
_chunking
)
def
test_finalize_HTTP_1_1_wo_content_length_streaming_w_http_chunk
(
self
):
response
=
self
.
_makeOne
()
...
...
@@ -115,7 +115,7 @@ class WSGIResponseTests(unittest.TestCase):
response
.
setBody
(
'TESTING'
)
headers
=
response
.
listHeaders
()
sv
=
[
x
for
x
in
headers
if
x
[
0
]
==
'Server'
]
self
.
failIf
(
sv
)
self
.
assertFalse
(
sv
)
def
test_listHeaders_includes_Server_header_w_server_version_set
(
self
):
response
=
self
.
_makeOne
()
...
...
@@ -123,7 +123,7 @@ class WSGIResponseTests(unittest.TestCase):
response
.
setBody
(
'TESTING'
)
headers
=
response
.
listHeaders
()
sv
=
[
x
for
x
in
headers
if
x
[
0
]
==
'Server'
]
self
.
failUnless
((
'Server'
,
'TESTME'
)
in
sv
)
self
.
assertTrue
((
'Server'
,
'TESTME'
)
in
sv
)
def
test_listHeaders_includes_Date_header
(
self
):
import
time
...
...
@@ -134,7 +134,7 @@ class WSGIResponseTests(unittest.TestCase):
headers
=
response
.
listHeaders
()
whenstr
=
time
.
strftime
(
'%a, %d %b %Y %H:%M:%S GMT'
,
time
.
gmtime
(
time
.
mktime
(
WHEN
)))
self
.
failUnless
((
'Date'
,
whenstr
)
in
headers
)
self
.
assertTrue
((
'Date'
,
whenstr
)
in
headers
)
#def test___str__already_wrote_not_chunking(self):
# response = self._makeOne()
...
...
@@ -186,11 +186,11 @@ class Test_publish(unittest.TestCase):
_gmi
.
_result
=
(
_before
,
_after
,
_object
,
_realm
,
_debug_mode
,
_err_hook
,
_validated_hook
,
_tm
)
returned
=
self
.
_callFUT
(
request
,
'okmodule'
,
_gmi
)
self
.
failUnless
(
returned
is
response
)
self
.
assertTrue
(
returned
is
response
)
self
.
assertEqual
(
_gmi
.
_called_with
,
((
'okmodule'
,),
{}))
self
.
failUnless
(
request
.
_processedInputs
)
self
.
assertTrue
(
request
.
_processedInputs
)
self
.
assertEqual
(
response
.
after_list
,
(
_after
,))
self
.
failUnless
(
response
.
debug_mode
)
self
.
assertTrue
(
response
.
debug_mode
)
self
.
assertEqual
(
response
.
realm
,
'TESTING'
)
self
.
assertEqual
(
_before
.
_called_with
,
((),
{}))
self
.
assertEqual
(
request
[
'PARENTS'
],
[
_object
])
...
...
@@ -319,10 +319,10 @@ class Test_publish_module(unittest.TestCase):
self
.
assertEqual
(
headers
,
[(
'Content-Length'
,
'0'
)])
self
.
assertEqual
(
kw
,
{})
(
request
,
module
),
kw
=
_publish
.
_called_with
self
.
failUnless
(
isinstance
(
request
,
HTTPRequest
))
self
.
assertTrue
(
isinstance
(
request
,
HTTPRequest
))
self
.
assertEqual
(
module
,
'Zope2'
)
self
.
assertEqual
(
kw
,
{})
self
.
failUnless
(
_response
.
_finalized
)
self
.
assertTrue
(
_response
.
_finalized
)
self
.
assertEqual
(
_after1
.
_called_with
,
((),
{}))
self
.
assertEqual
(
_after2
.
_called_with
,
((),
{}))
...
...
@@ -336,7 +336,7 @@ class Test_publish_module(unittest.TestCase):
self
.
assertEqual
(
app_iter
,
(
''
,
''
))
(
status
,
headers
),
kw
=
start_response
.
_called_with
self
.
assertEqual
(
status
,
'401 Unauthorized'
)
self
.
failUnless
((
'Content-Length'
,
'0'
)
in
headers
)
self
.
assertTrue
((
'Content-Length'
,
'0'
)
in
headers
)
self
.
assertEqual
(
kw
,
{})
def
test_swallows_Redirect
(
self
):
...
...
@@ -349,8 +349,8 @@ class Test_publish_module(unittest.TestCase):
self
.
assertEqual
(
app_iter
,
(
''
,
''
))
(
status
,
headers
),
kw
=
start_response
.
_called_with
self
.
assertEqual
(
status
,
'302 Moved Temporarily'
)
self
.
failUnless
((
'Location'
,
'/redirect_to'
)
in
headers
)
self
.
failUnless
((
'Content-Length'
,
'0'
)
in
headers
)
self
.
assertTrue
((
'Location'
,
'/redirect_to'
)
in
headers
)
self
.
assertTrue
((
'Content-Length'
,
'0'
)
in
headers
)
self
.
assertEqual
(
kw
,
{})
def
test_response_body_is_file
(
self
):
...
...
@@ -368,7 +368,7 @@ class Test_publish_module(unittest.TestCase):
_publish
=
DummyCallable
()
_publish
.
_result
=
_response
app_iter
=
self
.
_callFUT
(
environ
,
start_response
,
_publish
)
self
.
failUnless
(
app_iter
is
body
)
self
.
assertTrue
(
app_iter
is
body
)
def
test_request_closed_when_tm_middleware_not_active
(
self
):
environ
=
self
.
_makeEnviron
()
...
...
@@ -384,7 +384,7 @@ class Test_publish_module(unittest.TestCase):
_publish
.
_result
=
DummyResponse
()
app_iter
=
self
.
_callFUT
(
environ
,
start_response
,
_publish
,
_request_factory
=
_request_factory
)
self
.
failUnless
(
_request
.
_closed
)
self
.
assertTrue
(
_request
.
_closed
)
def
test_request_not_closed_when_tm_middleware_active
(
self
):
import
transaction
...
...
@@ -402,9 +402,9 @@ class Test_publish_module(unittest.TestCase):
_publish
.
_result
=
DummyResponse
()
app_iter
=
self
.
_callFUT
(
environ
,
start_response
,
_publish
,
_request_factory
=
_request_factory
)
self
.
failIf
(
_request
.
_closed
)
self
.
assertFalse
(
_request
.
_closed
)
txn
=
transaction
.
get
()
self
.
failUnless
(
list
(
txn
.
getAfterCommitHooks
()))
self
.
assertTrue
(
list
(
txn
.
getAfterCommitHooks
()))
class
DummyRequest
(
dict
):
...
...
src/ZPublisher/tests/test_xmlrpc.py
View file @
6220f215
...
...
@@ -46,8 +46,8 @@ class XMLRPCResponseTests(unittest.TestCase):
as_set
=
as_set
[
0
]
self
.
assertEqual
(
method
,
None
)
self
.
failIf
(
'_secret'
in
as_set
.
keys
())
self
.
failUnless
(
'public'
in
as_set
.
keys
())
self
.
assertFalse
(
'_secret'
in
as_set
.
keys
())
self
.
assertTrue
(
'public'
in
as_set
.
keys
())
self
.
assertEqual
(
as_set
[
'public'
],
'def'
)
def
test_nil
(
self
):
...
...
@@ -130,7 +130,7 @@ class XMLRPCResponseTests(unittest.TestCase):
response
.
setBody
(
body
)
data
,
method
=
xmlrpclib
.
loads
(
faux
.
_body
)
data
=
data
[
0
]
self
.
failUnless
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertTrue
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertEqual
(
data
.
value
,
u'2006-05-24T07:00:00+00:00'
)
def
test_zopedatetimeattribute
(
self
):
...
...
@@ -142,7 +142,7 @@ class XMLRPCResponseTests(unittest.TestCase):
response
.
setBody
(
body
)
data
,
method
=
xmlrpclib
.
loads
(
faux
.
_body
)
data
=
data
[
0
][
'public'
]
self
.
failUnless
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertTrue
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertEqual
(
data
.
value
,
u'2006-05-24T07:00:00+00:00'
)
def
test_zopedatetimeattribute_recursive
(
self
):
...
...
@@ -154,7 +154,7 @@ class XMLRPCResponseTests(unittest.TestCase):
response
.
setBody
(
body
)
data
,
method
=
xmlrpclib
.
loads
(
faux
.
_body
)
data
=
data
[
0
][
'public'
][
'public'
]
self
.
failUnless
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertTrue
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertEqual
(
data
.
value
,
u'2006-05-24T07:00:00+00:00'
)
def
test_zopedatetimeinstance_in_list
(
self
):
...
...
@@ -166,7 +166,7 @@ class XMLRPCResponseTests(unittest.TestCase):
response
.
setBody
(
body
)
data
,
method
=
xmlrpclib
.
loads
(
faux
.
_body
)
data
=
data
[
0
][
0
]
self
.
failUnless
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertTrue
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertEqual
(
data
.
value
,
u'2006-05-24T07:00:00+00:00'
)
def
test_zopedatetimeinstance_in_dict
(
self
):
...
...
@@ -178,7 +178,7 @@ class XMLRPCResponseTests(unittest.TestCase):
response
.
setBody
(
body
)
data
,
method
=
xmlrpclib
.
loads
(
faux
.
_body
)
data
=
data
[
0
][
'date'
]
self
.
failUnless
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertTrue
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertEqual
(
data
.
value
,
u'2006-05-24T07:00:00+00:00'
)
def
test_functionattribute
(
self
):
...
...
src/ZPublisher/tests/testpubevents.py
View file @
6220f215
...
...
@@ -146,7 +146,7 @@ class TestPubEvents(TestCase):
self
.
assert_
(
isinstance
(
events
[
0
],
PubBeforeStreaming
))
self
.
assertEqual
(
events
[
0
].
response
,
response
)
self
.
failUnless
(
'datachunk1datachunk2'
in
out
.
getvalue
())
self
.
assertTrue
(
'datachunk1datachunk2'
in
out
.
getvalue
())
# Auxiliaries
...
...
src/ZServer/tests/test_clockserver.py
View file @
6220f215
...
...
@@ -59,9 +59,9 @@ class ClockServerTests(unittest.TestCase):
from
ZServer.medusa.http_server
import
http_request
from
ZServer.HTTPResponse
import
HTTPResponse
from
ZPublisher.HTTPRequest
import
HTTPRequest
self
.
failUnless
(
isinstance
(
req
,
http_request
))
self
.
failUnless
(
isinstance
(
resp
,
HTTPResponse
))
self
.
failUnless
(
isinstance
(
zreq
,
HTTPRequest
))
self
.
assertTrue
(
isinstance
(
req
,
http_request
))
self
.
assertTrue
(
isinstance
(
resp
,
HTTPResponse
))
self
.
assertTrue
(
isinstance
(
zreq
,
HTTPRequest
))
def
test_get_env
(
self
):
logger
=
DummyLogger
()
...
...
src/ZServer/tests/test_responses.py
View file @
6220f215
...
...
@@ -304,7 +304,7 @@ class ZServerHTTPResponseEventsTestCase(unittest.TestCase):
self
.
assert_
(
isinstance
(
events
[
0
],
PubBeforeStreaming
))
self
.
assertEqual
(
events
[
0
].
response
,
response
)
self
.
failUnless
(
'datachunk1datachunk2'
in
out
.
getvalue
())
self
.
assertTrue
(
'datachunk1datachunk2'
in
out
.
getvalue
())
def
test_suite
():
suite
=
unittest
.
TestSuite
()
...
...
src/ZTUtils/tests/testTree.py
View file @
6220f215
...
...
@@ -187,7 +187,7 @@ class TreeTests(unittest.TestCase):
treeroot1
=
self
.
tm
.
tree
(
self
.
root
,
self
.
expansionmap
)
encoded
=
Tree
.
encodeExpansion
(
treeroot1
.
flat
())
self
.
failIf
(
encoded
.
find
(
'
\
n
'
)
!=
-
1
)
self
.
assertFalse
(
encoded
.
find
(
'
\
n
'
)
!=
-
1
)
decodedmap
=
Tree
.
decodeExpansion
(
encoded
)
treeroot2
=
self
.
tm
.
tree
(
self
.
root
,
decodedmap
)
...
...
src/Zope2/App/tests/testExceptionHook.py
View file @
6220f215
...
...
@@ -246,9 +246,9 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
self
.
call
(
client
,
request
,
f
)
self
.
failUnless
(
client
.
messages
,
client
.
messages
)
self
.
assertTrue
(
client
.
messages
,
client
.
messages
)
tb
=
client
.
messages
[
0
]
self
.
failUnless
(
"Unauthorized: You are not allowed"
in
tb
,
tb
)
self
.
assertTrue
(
"Unauthorized: You are not allowed"
in
tb
,
tb
)
def
testRenderUnauthorizedStandardClientMethod
(
self
):
from
AccessControl
import
Unauthorized
...
...
@@ -257,9 +257,9 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
self
.
call
(
client
.
dummyMethod
,
request
,
f
)
self
.
failUnless
(
client
.
messages
,
client
.
messages
)
self
.
assertTrue
(
client
.
messages
,
client
.
messages
)
tb
=
client
.
messages
[
0
]
self
.
failUnless
(
"Unauthorized: You are not allowed"
in
tb
,
tb
)
self
.
assertTrue
(
"Unauthorized: You are not allowed"
in
tb
,
tb
)
def
testRenderUnauthorizedBrokenClient
(
self
):
from
AccessControl
import
Unauthorized
...
...
@@ -283,9 +283,9 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
self
.
call
(
client
,
request
,
f
)
self
.
failUnless
(
client
.
messages
,
client
.
messages
)
self
.
assertTrue
(
client
.
messages
,
client
.
messages
)
tb
=
client
.
messages
[
0
]
self
.
failUnless
(
"CustomException: Zope"
in
tb
,
tb
)
self
.
assertTrue
(
"CustomException: Zope"
in
tb
,
tb
)
def
testRenderRetryRaisesConflictError
(
self
):
from
ZPublisher
import
Retry
...
...
@@ -300,9 +300,9 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
self
.
call
(
client
,
request
,
f
)
self
.
failUnless
(
client
.
messages
,
client
.
messages
)
self
.
assertTrue
(
client
.
messages
,
client
.
messages
)
tb
=
client
.
messages
[
0
]
self
.
failUnless
(
"ConflictError: database conflict error"
in
tb
,
tb
)
self
.
assertTrue
(
"ConflictError: database conflict error"
in
tb
,
tb
)
class
CustomExceptionView
(
Acquisition
.
Explicit
):
...
...
@@ -337,9 +337,9 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
self
.
failUnless
(
isinstance
(
v
,
Unauthorized
),
v
)
self
.
failUnless
(
"Exception View: Unauthorized"
in
str
(
v
))
self
.
failUnless
(
"Context: StandardClient"
in
str
(
v
))
self
.
assertTrue
(
isinstance
(
v
,
Unauthorized
),
v
)
self
.
assertTrue
(
"Exception View: Unauthorized"
in
str
(
v
))
self
.
assertTrue
(
"Context: StandardClient"
in
str
(
v
))
def
testCustomExceptionViewForbidden
(
self
):
from
ZPublisher.HTTPResponse
import
HTTPResponse
...
...
@@ -350,9 +350,9 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
self
.
failUnless
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
failUnless
(
v
.
status
==
403
,
(
v
.
status
,
403
))
self
.
failUnless
(
"Exception View: Forbidden"
in
str
(
v
))
self
.
assertTrue
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
assertTrue
(
v
.
status
==
403
,
(
v
.
status
,
403
))
self
.
assertTrue
(
"Exception View: Forbidden"
in
str
(
v
))
def
testCustomExceptionViewNotFound
(
self
):
from
ZPublisher.HTTPResponse
import
HTTPResponse
...
...
@@ -363,9 +363,9 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
self
.
failUnless
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
failUnless
(
v
.
status
==
404
,
(
v
.
status
,
404
))
self
.
failUnless
(
"Exception View: NotFound"
in
str
(
v
),
v
)
self
.
assertTrue
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
assertTrue
(
v
.
status
==
404
,
(
v
.
status
,
404
))
self
.
assertTrue
(
"Exception View: NotFound"
in
str
(
v
),
v
)
def
testCustomExceptionViewBadRequest
(
self
):
from
ZPublisher.HTTPResponse
import
HTTPResponse
...
...
@@ -376,9 +376,9 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
self
.
failUnless
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
failUnless
(
v
.
status
==
400
,
(
v
.
status
,
400
))
self
.
failUnless
(
"Exception View: BadRequest"
in
str
(
v
),
v
)
self
.
assertTrue
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
assertTrue
(
v
.
status
==
400
,
(
v
.
status
,
400
))
self
.
assertTrue
(
"Exception View: BadRequest"
in
str
(
v
),
v
)
def
testCustomExceptionViewInternalError
(
self
):
from
ZPublisher.HTTPResponse
import
HTTPResponse
...
...
@@ -389,9 +389,9 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
self
.
failUnless
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
failUnless
(
v
.
status
==
500
,
(
v
.
status
,
500
))
self
.
failUnless
(
"Exception View: InternalError"
in
str
(
v
),
v
)
self
.
assertTrue
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
assertTrue
(
v
.
status
==
500
,
(
v
.
status
,
500
))
self
.
assertTrue
(
"Exception View: InternalError"
in
str
(
v
),
v
)
def
testRedirectNoExceptionView
(
self
):
from
zExceptions
import
Redirect
...
...
@@ -401,7 +401,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
self
.
failUnless
(
isinstance
(
v
,
Redirect
),
v
)
self
.
assertTrue
(
isinstance
(
v
,
Redirect
),
v
)
self
.
assertEquals
(
v
.
args
[
0
],
"http://zope.org/"
)
...
...
src/Zope2/App/tests/test_schema.py
View file @
6220f215
...
...
@@ -49,4 +49,4 @@ class Zope2VocabularyRegistryTests(unittest.TestCase, CleanUp):
registry
=
self
.
_makeOne
()
context
=
object
()
found
=
registry
.
get
(
context
,
'foundit'
)
self
.
failUnless
(
found
is
_marker
)
self
.
assertTrue
(
found
is
_marker
)
src/Zope2/Startup/tests/testStarter.py
View file @
6220f215
...
...
@@ -254,7 +254,7 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
effective-user %s"""
%
runnerid
)
starter
=
make_starter
(
conf
)
finished
=
starter
.
dropPrivileges
()
self
.
failUnless
(
finished
)
self
.
assertTrue
(
finished
)
finally
:
os
.
getuid
=
_old_getuid
...
...
@@ -292,9 +292,9 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
logger
=
logging
.
getLogger
()
self
.
assertEqual
(
logger
.
level
,
logging
.
INFO
)
l
=
open
(
os
.
path
.
join
(
TEMPNAME
,
'event.log'
)).
read
()
self
.
failUnless
(
l
.
find
(
'hello'
)
>
-
1
)
self
.
failUnless
(
os
.
path
.
exists
(
os
.
path
.
join
(
TEMPNAME
,
'Z2.log'
)))
self
.
failUnless
(
os
.
path
.
exists
(
os
.
path
.
join
(
TEMPNAME
,
'trace.log'
)))
self
.
assertTrue
(
l
.
find
(
'hello'
)
>
-
1
)
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
TEMPNAME
,
'Z2.log'
)))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
TEMPNAME
,
'trace.log'
)))
finally
:
for
name
in
(
'event.log'
,
'Z2.log'
,
'trace.log'
):
try
:
...
...
@@ -326,10 +326,10 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
f
.
seek
(
1
)
# skip over the locked byte
guts
=
f
.
read
()
f
.
close
()
self
.
failIf
(
guts
.
find
(
'hello'
)
>
-
1
)
self
.
assertFalse
(
guts
.
find
(
'hello'
)
>
-
1
)
finally
:
starter
.
unlinkLockFile
()
self
.
failIf
(
os
.
path
.
exists
(
name
))
self
.
assertFalse
(
os
.
path
.
exists
(
name
))
def
testMakePidFile
(
self
):
# put something in the way (it should be deleted)
...
...
@@ -344,10 +344,10 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
try
:
starter
=
self
.
get_starter
(
conf
)
starter
.
makePidFile
()
self
.
failIf
(
open
(
name
).
read
().
find
(
'hello'
)
>
-
1
)
self
.
assertFalse
(
open
(
name
).
read
().
find
(
'hello'
)
>
-
1
)
finally
:
starter
.
unlinkPidFile
()
self
.
failIf
(
os
.
path
.
exists
(
name
))
self
.
assertFalse
(
os
.
path
.
exists
(
name
))
def
testConfigureInterpreter
(
self
):
import
sys
...
...
src/reStructuredText/tests/testReST.py
View file @
6220f215
...
...
@@ -147,12 +147,12 @@ text
def
test_csv_table_file_option_raise
(
self
):
source
=
'.. csv-table::
\
n
:file: inclusion.txt'
result
=
HTML
(
source
)
self
.
failUnless
(
'File and URL access deactivated'
in
result
)
self
.
assertTrue
(
'File and URL access deactivated'
in
result
)
def
test_csv_table_url_option_raise
(
self
):
source
=
'.. csv-table::
\
n
:url: http://www.evil.org'
result
=
HTML
(
source
)
self
.
failUnless
(
'File and URL access deactivated'
in
result
)
self
.
assertTrue
(
'File and URL access deactivated'
in
result
)
def
test_suite
():
...
...
src/webdav/tests/testLockable.py
View file @
6220f215
...
...
@@ -4,18 +4,18 @@ class TestUtilFunctions(unittest.TestCase):
def
test_wl_isLocked
(
self
):
from
webdav.Lockable
import
wl_isLocked
unlockable
=
UnlockableResource
()
self
.
failIf
(
wl_isLocked
(
unlockable
))
self
.
assertFalse
(
wl_isLocked
(
unlockable
))
lockable_unlocked
=
LockableResource
(
locked
=
False
)
self
.
failIf
(
wl_isLocked
(
lockable_unlocked
))
self
.
assertFalse
(
wl_isLocked
(
lockable_unlocked
))
lockable_locked
=
LockableResource
(
locked
=
True
)
self
.
failUnless
(
wl_isLocked
(
lockable_locked
))
self
.
assertTrue
(
wl_isLocked
(
lockable_locked
))
def
test_wl_isLockable
(
self
):
from
webdav.Lockable
import
wl_isLockable
unlockable
=
UnlockableResource
()
self
.
failIf
(
wl_isLockable
(
unlockable
))
self
.
assertFalse
(
wl_isLockable
(
unlockable
))
lockable
=
LockableResource
(
locked
=
False
)
self
.
failUnless
(
wl_isLockable
(
lockable
))
self
.
assertTrue
(
wl_isLockable
(
lockable
))
from
webdav.interfaces
import
IWriteLock
from
zope.interface
import
implements
...
...
src/webdav/tests/testNullResource.py
View file @
6220f215
...
...
@@ -46,7 +46,7 @@ class TestNullResource(unittest.TestCase):
self
.
assertRaises
(
NotFound
,
nonesuch
.
HEAD
,
request
,
response
)
self
.
assertEqual
(
response
.
body
,
''
)
self
.
failUnless
(
response
.
locked
)
self
.
assertTrue
(
response
.
locked
)
def
test_PUT_unauthorized_message
(
self
):
# See https://bugs.launchpad.net/bugs/143946
...
...
@@ -73,7 +73,7 @@ class TestNullResource(unittest.TestCase):
try
:
nonesuch
.
PUT
(
request
,
response
)
except
Unauthorized
,
e
:
self
.
failUnless
(
str
(
e
).
startswith
(
'Unable to create object'
))
self
.
assertTrue
(
str
(
e
).
startswith
(
'Unable to create object'
))
def
test_suite
():
...
...
src/webdav/tests/testPUT_factory.py
View file @
6220f215
...
...
@@ -42,31 +42,31 @@ class TestPUTFactory(unittest.TestCase):
request
=
self
.
app
.
REQUEST
put
=
request
.
traverse
(
'/folder/doc'
)
put
(
request
,
request
.
RESPONSE
)
self
.
failUnless
(
'doc'
in
self
.
folder
.
objectIds
())
self
.
assertTrue
(
'doc'
in
self
.
folder
.
objectIds
())
def
testSimpleVirtualHosting
(
self
):
request
=
self
.
app
.
REQUEST
put
=
request
.
traverse
(
'/VirtualHostBase/http/foo.com:80/VirtualHostRoot/folder/doc'
)
put
(
request
,
request
.
RESPONSE
)
self
.
failUnless
(
'doc'
in
self
.
folder
.
objectIds
())
self
.
assertTrue
(
'doc'
in
self
.
folder
.
objectIds
())
def
testSubfolderVirtualHosting
(
self
):
request
=
self
.
app
.
REQUEST
put
=
request
.
traverse
(
'/VirtualHostBase/http/foo.com:80/folder/VirtualHostRoot/doc'
)
put
(
request
,
request
.
RESPONSE
)
self
.
failUnless
(
'doc'
in
self
.
folder
.
objectIds
())
self
.
assertTrue
(
'doc'
in
self
.
folder
.
objectIds
())
def
testInsideOutVirtualHosting
(
self
):
request
=
self
.
app
.
REQUEST
put
=
request
.
traverse
(
'/VirtualHostBase/http/foo.com:80/VirtualHostRoot/_vh_foo/folder/doc'
)
put
(
request
,
request
.
RESPONSE
)
self
.
failUnless
(
'doc'
in
self
.
folder
.
objectIds
())
self
.
assertTrue
(
'doc'
in
self
.
folder
.
objectIds
())
def
testSubfolderInsideOutVirtualHosting
(
self
):
request
=
self
.
app
.
REQUEST
put
=
request
.
traverse
(
'/VirtualHostBase/http/foo.com:80/folder/VirtualHostRoot/_vh_foo/doc'
)
put
(
request
,
request
.
RESPONSE
)
self
.
failUnless
(
'doc'
in
self
.
folder
.
objectIds
())
self
.
assertTrue
(
'doc'
in
self
.
folder
.
objectIds
())
def
testCollector2261
(
self
):
from
OFS.Folder
import
manage_addFolder
...
...
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