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
d5ebc7c2
Commit
d5ebc7c2
authored
Oct 29, 2005
by
Chris McDonough
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add one test and expand another for database mounting.
Make sure that savepoint creation is optimistic.
parent
36a57871
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
10 deletions
+49
-10
lib/python/Products/ZODBMountPoint/MountedObject.py
lib/python/Products/ZODBMountPoint/MountedObject.py
+4
-4
lib/python/Products/ZODBMountPoint/tests/testMountPoint.py
lib/python/Products/ZODBMountPoint/tests/testMountPoint.py
+45
-6
No files found.
lib/python/Products/ZODBMountPoint/MountedObject.py
View file @
d5ebc7c2
...
...
@@ -82,7 +82,6 @@ class SimpleTrailblazer:
container
=
self
.
_construct
(
container
,
part
)
return
container
class
CustomTrailblazer
(
SimpleTrailblazer
):
"""Like SimpleTrailblazer but creates custom objects.
...
...
@@ -113,7 +112,7 @@ class CustomTrailblazer (SimpleTrailblazer):
obj
=
context
.
unrestrictedTraverse
(
id
)
# Commit a subtransaction to assign the new object to
# the correct database.
transaction
.
savepoint
()
transaction
.
savepoint
(
optimistic
=
True
)
return
obj
...
...
@@ -123,7 +122,8 @@ class MountedObject(SimpleItem):
'''
meta_type
=
'ZODB Mount Point'
_isMountedObject
=
1
# DM 2005-05-17: default value change necessary after fix of '_create_mount_point' handling
# DM 2005-05-17: default value change necessary after fix of
# '_create_mount_point' handling
#_create_mount_points = 0
_create_mount_points
=
True
...
...
@@ -193,7 +193,7 @@ class MountedObject(SimpleItem):
obj
=
Application
()
root
[
real_root
]
=
obj
# Get it into the database
transaction
.
savepoint
()
transaction
.
savepoint
(
optimistic
=
True
)
else
:
raise
...
...
lib/python/Products/ZODBMountPoint/tests/testMountPoint.py
View file @
d5ebc7c2
...
...
@@ -11,7 +11,7 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""Tests of
DBTab and
ZODBMountPoint
"""Tests of ZODBMountPoint
"""
import
os
...
...
@@ -23,7 +23,9 @@ import transaction
from
OFS.Application
import
Application
from
OFS.Folder
import
Folder
import
App.config
from
Products.ZODBMountPoint.MountedObject
import
manage_addMounts
,
getMountPoint
from
Products.ZODBMountPoint.MountedObject
import
manage_addMounts
from
Products.ZODBMountPoint.MountedObject
import
getMountPoint
from
Products.ZODBMountPoint.MountedObject
import
manage_getMountStatus
from
Zope2.Startup.datatypes
import
DBTab
try
:
...
...
@@ -62,7 +64,7 @@ class TestDBConfig:
original_config
=
None
class
DBTabTests
(
unittest
.
TestCase
):
class
MountingTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
global
original_config
...
...
@@ -88,7 +90,6 @@ class DBTabTests (unittest.TestCase):
App
.
config
.
setConfiguration
(
d
)
self
.
conf
=
conf
db
=
conf
.
getDatabase
(
'/'
)
self
.
db
=
db
conn
=
db
.
open
()
root
=
conn
.
root
()
root
[
'Application'
]
=
app
=
Application
()
...
...
@@ -104,7 +105,6 @@ class DBTabTests (unittest.TestCase):
transaction
.
abort
()
self
.
app
.
_p_jar
.
close
()
del
self
.
app
del
self
.
db
for
db
in
self
.
conf
.
databases
.
values
():
db
.
close
()
del
self
.
conf
...
...
@@ -126,6 +126,10 @@ class DBTabTests (unittest.TestCase):
self
.
assertEqual
(
app
.
mount2
.
_p_changed
,
0
)
self
.
assertEqual
(
app
.
_p_changed
,
0
)
self
.
assertEqual
(
app
.
mount1
.
a1
,
'1'
)
self
.
assertEqual
(
app
.
mount2
.
a2
,
'2'
)
self
.
assertEqual
(
app
.
a3
,
'3'
)
def
testGetMountPoint
(
self
):
self
.
assert_
(
getMountPoint
(
self
.
app
)
is
None
)
self
.
assert_
(
getMountPoint
(
self
.
app
.
mount1
)
is
not
None
)
...
...
@@ -139,8 +143,43 @@ class DBTabTests (unittest.TestCase):
transaction
.
commit
()
self
.
assert_
(
getMountPoint
(
self
.
app
.
mount2
)
is
None
)
def
test_manage_getMountStatus
(
self
):
status
=
manage_getMountStatus
(
self
.
app
)
expected
=
[{
'status'
:
'Ok'
,
'path'
:
'/mount1'
,
'name'
:
'test_mount1.fs'
,
'exists'
:
1
},
{
'status'
:
'Ok'
,
'path'
:
'/mount2'
,
'name'
:
'test_mount2.fs'
,
'exists'
:
1
}]
self
.
assertEqual
(
expected
,
status
)
del
self
.
app
.
mount2
status
=
manage_getMountStatus
(
self
.
app
)
expected
=
[{
'status'
:
'Ok'
,
'path'
:
'/mount1'
,
'name'
:
'test_mount1.fs'
,
'exists'
:
1
},
{
'status'
:
'Ready to create'
,
'path'
:
'/mount2'
,
'name'
:
'test_mount2.fs'
,
'exists'
:
0
}]
self
.
assertEqual
(
expected
,
status
)
self
.
app
.
mount2
=
Folder
(
'mount2'
)
status
=
manage_getMountStatus
(
self
.
app
)
expected
=
[{
'status'
:
'Ok'
,
'path'
:
'/mount1'
,
'name'
:
'test_mount1.fs'
,
'exists'
:
1
},
{
'status'
:
'** Something is in the way **'
,
'path'
:
'/mount2'
,
'name'
:
'test_mount2.fs'
,
'exists'
:
1
}]
self
.
assertEqual
(
expected
,
status
)
def
test_suite
():
return
unittest
.
makeSuite
(
DBTab
Tests
,
'test'
)
return
unittest
.
makeSuite
(
Mounting
Tests
,
'test'
)
if
__name__
==
'__main__'
:
unittest
.
main
()
...
...
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