Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
Commits
f10b4b12
Commit
f10b4b12
authored
May 27, 2003
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove test of old configuration code.
parent
a1a9ca35
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
185 deletions
+0
-185
src/ZODB/tests/testStorageConfig.py
src/ZODB/tests/testStorageConfig.py
+0
-185
No files found.
src/ZODB/tests/testStorageConfig.py
deleted
100644 → 0
View file @
a1a9ca35
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
import
os
import
shutil
import
tempfile
import
unittest
from
StringIO
import
StringIO
import
ZConfig.Context
from
ZODB
import
StorageConfig
class
StorageTestBase
(
unittest
.
TestCase
):
def
setUp
(
self
):
unittest
.
TestCase
.
setUp
(
self
)
self
.
tmpfn
=
tempfile
.
mktemp
()
self
.
storage
=
None
def
tearDown
(
self
):
unittest
.
TestCase
.
tearDown
(
self
)
storage
=
self
.
storage
self
.
storage
=
None
try
:
if
storage
is
not
None
:
storage
.
close
()
except
:
pass
try
:
# BDBFullStorage storage creates a directory
if
os
.
path
.
isdir
(
self
.
tmpfn
):
shutil
.
rmtree
(
self
.
tmpfn
)
else
:
os
.
remove
(
self
.
tmpfn
)
except
os
.
error
:
pass
def
loadConfigText
(
self
,
text
):
context
=
ZConfig
.
Context
.
Context
()
io
=
StringIO
(
text
)
return
context
.
loadFile
(
io
)
class
StorageTestCase
(
StorageTestBase
):
def
testFileStorage
(
self
):
from
ZODB.FileStorage
import
FileStorage
sample
=
"""
<Storage>
type FileStorage
file_name %s
create yes
</Storage>
"""
%
self
.
tmpfn
rootconf
=
self
.
loadConfigText
(
sample
)
storageconf
=
rootconf
.
getSection
(
"Storage"
)
cls
,
args
=
StorageConfig
.
getStorageInfo
(
storageconf
)
self
.
assertEqual
(
cls
,
FileStorage
)
self
.
assertEqual
(
args
,
{
"file_name"
:
self
.
tmpfn
,
"create"
:
1
})
self
.
storage
=
StorageConfig
.
createStorage
(
storageconf
)
self
.
assert_
(
isinstance
(
self
.
storage
,
FileStorage
))
def
testZEOStorage
(
self
):
from
ZEO.ClientStorage
import
ClientStorage
sample
=
"""
<Storage>
type ClientStorage
addr zeo://www.python.org:9001
wait no
</Storage>
"""
rootconf
=
self
.
loadConfigText
(
sample
)
storageconf
=
rootconf
.
getSection
(
"Storage"
)
cls
,
args
=
StorageConfig
.
getStorageInfo
(
storageconf
)
self
.
assertEqual
(
cls
,
ClientStorage
)
self
.
assertEqual
(
args
,
{
"addr"
:
[(
"www.python.org"
,
9001
)],
"wait"
:
0
})
self
.
storage
=
StorageConfig
.
createStorage
(
storageconf
)
self
.
assert_
(
isinstance
(
self
.
storage
,
ClientStorage
))
def
testDemoStorage
(
self
):
from
ZODB.DemoStorage
import
DemoStorage
sample
=
"""
<Storage>
type DemoStorage
</Storage>
"""
rootconf
=
self
.
loadConfigText
(
sample
)
storageconf
=
rootconf
.
getSection
(
"Storage"
)
cls
,
args
=
StorageConfig
.
getStorageInfo
(
storageconf
)
self
.
assertEqual
(
cls
,
DemoStorage
)
self
.
assertEqual
(
args
,
{})
self
.
storage
=
StorageConfig
.
createStorage
(
storageconf
)
self
.
assert_
(
isinstance
(
self
.
storage
,
DemoStorage
))
def
testModuleStorage
(
self
):
# Test explicit module+class
from
ZODB.DemoStorage
import
DemoStorage
sample
=
"""
<Storage>
type ZODB.DemoStorage.DemoStorage
</Storage>
"""
rootconf
=
self
.
loadConfigText
(
sample
)
storageconf
=
rootconf
.
getSection
(
"Storage"
)
cls
,
args
=
StorageConfig
.
getStorageInfo
(
storageconf
)
self
.
assertEqual
(
cls
,
DemoStorage
)
self
.
assertEqual
(
args
,
{})
self
.
storage
=
StorageConfig
.
createStorage
(
storageconf
)
self
.
assert_
(
isinstance
(
self
.
storage
,
DemoStorage
))
class
BDBStorageTests
(
StorageTestBase
):
def
testFullStorage
(
self
):
try
:
from
BDBStorage.BDBFullStorage
import
BDBFullStorage
except
ImportError
:
return
sample
=
"""
<Storage>
type BDBFullStorage
name %s
cachesize 1000
</Storage>
"""
%
self
.
tmpfn
os
.
mkdir
(
self
.
tmpfn
)
rootconf
=
self
.
loadConfigText
(
sample
)
storageconf
=
rootconf
.
getSection
(
"Storage"
)
cls
,
args
=
StorageConfig
.
getStorageInfo
(
storageconf
)
self
.
assertEqual
(
cls
,
BDBFullStorage
)
# It's too hard to test the config instance equality
args
=
args
.
copy
()
del
args
[
'config'
]
self
.
assertEqual
(
args
,
{
"name"
:
self
.
tmpfn
})
self
.
storage
=
StorageConfig
.
createStorage
(
storageconf
)
self
.
assert_
(
isinstance
(
self
.
storage
,
BDBFullStorage
))
# XXX _config isn't public
self
.
assert_
(
self
.
storage
.
_config
.
cachesize
,
1000
)
def
testMinimalStorage
(
self
):
try
:
from
BDBStorage.BDBMinimalStorage
import
BDBMinimalStorage
except
ImportError
:
return
sample
=
"""
<Storage>
type BDBMinimalStorage
name %s
cachesize 1000
</Storage>
"""
%
self
.
tmpfn
os
.
mkdir
(
self
.
tmpfn
)
rootconf
=
self
.
loadConfigText
(
sample
)
storageconf
=
rootconf
.
getSection
(
"Storage"
)
cls
,
args
=
StorageConfig
.
getStorageInfo
(
storageconf
)
self
.
assertEqual
(
cls
,
BDBMinimalStorage
)
# It's too hard to test the config instance equality
args
=
args
.
copy
()
del
args
[
'config'
]
self
.
assertEqual
(
args
,
{
"name"
:
self
.
tmpfn
})
self
.
storage
=
StorageConfig
.
createStorage
(
storageconf
)
self
.
assert_
(
isinstance
(
self
.
storage
,
BDBMinimalStorage
))
# XXX _config isn't public
self
.
assert_
(
self
.
storage
.
_config
.
cachesize
,
1000
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
StorageTestCase
))
import
BDBStorage
if
BDBStorage
.
is_available
:
suite
.
addTest
(
unittest
.
makeSuite
(
BDBStorageTests
))
return
suite
if
__name__
==
'__main__'
:
unittest
.
main
(
defaultTest
=
'test_suite'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment