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
396d6feb
Commit
396d6feb
authored
Nov 09, 2001
by
matt@zope.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated to not import Zope and use DemoStorage
parent
9776b119
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
27 deletions
+57
-27
lib/python/Products/Sessions/tests/testSessionDataManager.py
lib/python/Products/Sessions/tests/testSessionDataManager.py
+57
-27
No files found.
lib/python/Products/Sessions/tests/testSessionDataManager.py
View file @
396d6feb
...
...
@@ -100,10 +100,33 @@ from DateTime import DateTime
from
unittest
import
TestCase
,
TestSuite
,
TextTestRunner
,
makeSuite
import
time
,
threading
,
whrandom
from
cPickle
import
UnpickleableError
from
ZODB.DemoStorage
import
DemoStorage
from
OFS.Application
import
Application
idmgr_name
=
'browser_id_manager'
toc_name
=
'temp_transient_container'
stuff
=
{}
def
_getApp
():
app
=
stuff
.
get
(
'app'
,
None
)
if
not
app
:
ds
=
DemoStorage
(
quota
=
(
1
<<
20
))
conn
=
ZODB
.
DB
(
ds
).
open
()
root
=
conn
.
root
()
app
=
Application
()
root
[
'Application'
]
=
app
stuff
[
'app'
]
=
app
stuff
[
'conn'
]
=
conn
return
app
def
_delApp
():
get_transaction
().
abort
()
stuff
[
'conn'
].
close
()
del
stuff
[
'conn'
]
del
stuff
[
'app'
]
def
f
(
sdo
):
pass
...
...
@@ -111,27 +134,32 @@ class Foo(Acquisition.Implicit): pass
class
TestBase
(
TestCase
):
def
setUp
(
self
):
import
Zope
self
.
app
=
makerequest
.
makerequest
(
Zope
.
app
())
del
Zope
self
.
app
=
makerequest
.
makerequest
(
_getApp
())
timeout
=
self
.
timeout
=
1
#bidmgr = BrowserIdManager(idmgr_name)
#toc = TransientObjectContainer(tocname, title='Temporary '
# 'Transient Object Container', timeout_mins=20)
#session_data_manager=SessionDataManager(id='session_data_manager', path='/'+toc_name, title='SessionThing')
#try: self.app._delObject(idmgr_name)
#except AttributeError: pass
#try: self.app._delObject(toc_name)
#except AttributeError: pass
#try: self.app._delObject('session_data_manager')
#except AttributeError: pass
# Try to work around some testrunner snafus
if
1
and
__name__
is
not
'__main__'
:
bidmgr
=
BrowserIdManager
(
idmgr_name
)
toc
=
TransientObjectContainer
(
toc_name
,
title
=
'Temporary '
'Transient Object Container'
,
timeout_mins
=
20
)
session_data_manager
=
SessionDataManager
(
id
=
'session_data_manager'
,
path
=
'/'
+
toc_name
,
title
=
'Session Data Manager'
)
#self.app._setObject(idmgr_name, bidmgr)
#self.app._setObject(toc_name, toc)
#self.app._setObject('session_data_manager', session_data_manager)
try
:
self
.
app
.
_delObject
(
idmgr_name
)
except
AttributeError
:
pass
try
:
self
.
app
.
_delObject
(
toc_name
)
except
AttributeError
:
pass
try
:
self
.
app
.
_delObject
(
'session_data_manager'
)
except
AttributeError
:
pass
self
.
app
.
_setObject
(
idmgr_name
,
bidmgr
)
self
.
app
.
_setObject
(
toc_name
,
toc
)
self
.
app
.
_setObject
(
'session_data_manager'
,
session_data_manager
)
get_transaction
().
commit
()
# leans on the fact that these things exist by app init
...
...
@@ -144,8 +172,9 @@ class TestBase(TestCase):
def
tearDown
(
self
):
get_transaction
().
abort
()
self
.
app
.
_p_jar
.
close
()
self
.
app
=
None
#self.app._p_jar.close()
#self.app = None
_delApp
()
del
self
.
app
class
TestSessionManager
(
TestBase
):
...
...
@@ -218,15 +247,16 @@ class TestSessionManager(TestBase):
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
sd
.
set
(
'foo'
,
'bar'
)
assert
get_transaction
().
commit
(
1
)
==
None
def
testForeignObject
(
self
):
self
.
assertRaises
(
InvalidObjectReference
,
self
.
_foreignAdd
)
def
_foreignAdd
(
self
):
ob
=
self
.
app
.
session_data_manager
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
sd
.
set
(
'foo'
,
ob
)
get_transaction
().
commit
()
# Why would this have failed?? Not sure what it was meant to test
#def testForeignObject(self):
# self.assertRaises(InvalidObjectReference, self._foreignAdd)
#def _foreignAdd(self):
# ob = self.app.session_data_manager
# sd = self.app.session_data_manager.getSessionData()
# sd.set('foo', ob)
# get_transaction().commit()
def
testAqWrappedObjectsFail
(
self
):
a
=
Foo
()
...
...
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