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
cd4efecf
Commit
cd4efecf
authored
Aug 27, 2008
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove tests that depend on the presence of the Examples.zexp
parent
6a65eec3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
6 additions
and
155 deletions
+6
-155
lib/python/Testing/ZopeTestCase/doc/HOWTO.stx
lib/python/Testing/ZopeTestCase/doc/HOWTO.stx
+0
-3
lib/python/Testing/ZopeTestCase/testBaseTestCase.py
lib/python/Testing/ZopeTestCase/testBaseTestCase.py
+2
-3
lib/python/Testing/ZopeTestCase/testPortalTestCase.py
lib/python/Testing/ZopeTestCase/testPortalTestCase.py
+2
-3
lib/python/Testing/ZopeTestCase/testShoppingCart.py
lib/python/Testing/ZopeTestCase/testShoppingCart.py
+0
-143
lib/python/Testing/ZopeTestCase/testZopeTestCase.py
lib/python/Testing/ZopeTestCase/testZopeTestCase.py
+2
-3
No files found.
lib/python/Testing/ZopeTestCase/doc/HOWTO.stx
View file @
cd4efecf
...
...
@@ -178,9 +178,6 @@ Writing Tests
It demonstrates how to manipulate the test user's roles and permissions and how
security is validated.
- **'testShoppingCart.py'** tests the ShoppingCart example. This test
uses Sessions and shows how to test a TTW Zope application.
- **'testFunctional.py'** demonstrates the new functional testing features.
Tests may call 'self.publish()' to simulate URL calls to the ZPublisher.
...
...
lib/python/Testing/ZopeTestCase/testBaseTestCase.py
View file @
cd4efecf
...
...
@@ -15,9 +15,8 @@
NOTE: This is *not* an example TestCase. Do not
use this file as a blueprint for your own tests!
See testPythonScript.py and testShoppingCart.py for
example test cases. See testSkeleton.py for a quick
way of getting started.
See testPythonScript.py for example test cases. See testSkeleton.py for a
quick way of getting started.
$Id$
"""
...
...
lib/python/Testing/ZopeTestCase/testPortalTestCase.py
View file @
cd4efecf
...
...
@@ -15,9 +15,8 @@
NOTE: This is *not* an example TestCase. Do not
use this file as a blueprint for your own tests!
See testPythonScript.py and testShoppingCart.py for
example test cases. See testSkeleton.py for a quick
way of getting started.
See testPythonScript.py for example test cases. See testSkeleton.py for a
quick way of getting started.
$Id$
"""
...
...
lib/python/Testing/ZopeTestCase/testShoppingCart.py
deleted
100644 → 0
View file @
6a65eec3
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
"""Example ZopeTestCase testing the ShoppingCart example application
Note the use of sessions and how the SESSION object is added to
the REQUEST in afterSetUp().
You can use zLOG.LOG() if you set up the event log variables first.
Handy for debugging and tracing your tests.
$Id$
"""
import
os
,
sys
if
__name__
==
'__main__'
:
execfile
(
os
.
path
.
join
(
sys
.
path
[
0
],
'framework.py'
))
#os.environ['STUPID_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log')
#os.environ['STUPID_LOG_SEVERITY'] = '0'
from
Testing
import
ZopeTestCase
from
Testing.ZopeTestCase
import
layer
from
Testing.ZopeTestCase
import
utils
from
Testing.ZopeTestCase
import
transaction
from
Globals
import
SOFTWARE_HOME
examples_path
=
os
.
path
.
join
(
SOFTWARE_HOME
,
'..'
,
'..'
,
'skel'
,
'import'
,
'Examples.zexp'
)
examples_path
=
os
.
path
.
abspath
(
examples_path
)
class
ShoppingCartLayer
(
layer
.
ZopeLite
):
@
classmethod
def
setUp
(
cls
):
# Set up sessioning objects
utils
.
appcall
(
utils
.
setupCoreSessions
)
# Set up example applications
utils
.
appcall
(
utils
.
importObjectFromFile
,
examples_path
,
quiet
=
1
)
@
classmethod
def
tearDown
(
cls
):
def
cleanup
(
app
):
app
.
_delObject
(
'Examples'
)
transaction
.
commit
()
utils
.
appcall
(
cleanup
)
class
DummyOrder
:
'''Construct an order we can add to the cart'''
__allow_access_to_unprotected_subobjects__
=
1
def
__init__
(
self
,
id
,
quantity
):
self
.
id
=
id
self
.
quantity
=
quantity
class
TestShoppingCart
(
ZopeTestCase
.
ZopeTestCase
):
'''Test the ShoppingCart example application'''
_setup_fixture
=
0
# No default fixture
layer
=
ShoppingCartLayer
def
afterSetUp
(
self
):
self
.
cart
=
self
.
app
.
Examples
.
ShoppingCart
# Put SESSION object into REQUEST
request
=
self
.
app
.
REQUEST
sdm
=
self
.
app
.
session_data_manager
request
.
set
(
'SESSION'
,
sdm
.
getSessionData
())
self
.
session
=
request
.
SESSION
def
testSession
(
self
):
# Session should work
self
.
session
.
set
(
'boring'
,
'boring'
)
self
.
assertEqual
(
self
.
session
.
get
(
'boring'
),
'boring'
)
def
testCartIsEmpty
(
self
):
# Cart should be empty
self
.
assertEqual
(
len
(
self
.
cart
.
currentItems
()),
0
)
def
testAddItems
(
self
):
# Adding to the cart should work
self
.
cart
.
addItems
([
DummyOrder
(
'510-115'
,
1
),])
self
.
assertEqual
(
len
(
self
.
cart
.
currentItems
()),
1
)
def
testDeleteItems
(
self
):
# Deleting from the cart should work
self
.
cart
.
addItems
([
DummyOrder
(
'510-115'
,
1
),])
self
.
cart
.
deleteItems
([
'510-115'
])
self
.
assertEqual
(
len
(
self
.
cart
.
currentItems
()),
0
)
def
testAddQuantity
(
self
):
# Adding to quantity should work
self
.
cart
.
addItems
([
DummyOrder
(
'510-115'
,
1
),])
self
.
cart
.
addItems
([
DummyOrder
(
'510-115'
,
2
),])
self
.
cart
.
addItems
([
DummyOrder
(
'510-115'
,
3
),])
self
.
assertEqual
(
self
.
cart
.
currentItems
()[
0
][
'quantity'
],
6
)
def
testGetTotal
(
self
):
# Totals should be computed correctly
self
.
cart
.
addItems
([
DummyOrder
(
'510-115'
,
1
),])
self
.
cart
.
addItems
([
DummyOrder
(
'510-122'
,
2
),])
self
.
cart
.
addItems
([
DummyOrder
(
'510-007'
,
2
),])
self
.
assertEqual
(
self
.
cart
.
getTotal
(),
149.95
)
def
testGetItem
(
self
):
# Getting an item from the "database" should work
item
=
self
.
cart
.
getItem
(
'510-115'
)
self
.
assertEqual
(
item
[
'id'
],
'510-115'
)
self
.
assertEqual
(
item
[
'title'
],
'Econo Feeder'
)
self
.
assertEqual
(
item
[
'price'
],
7.95
)
def
testEight
(
self
):
# Additional test to trigger connection pool depletion bug
pass
class
TestSandboxedShoppingCart
(
ZopeTestCase
.
Sandboxed
,
TestShoppingCart
):
'''Demonstrate that sessions work in sandboxes'''
def
test_suite
():
from
unittest
import
TestSuite
,
makeSuite
suite
=
TestSuite
()
suite
.
addTest
(
makeSuite
(
TestShoppingCart
))
suite
.
addTest
(
makeSuite
(
TestSandboxedShoppingCart
))
return
suite
if
__name__
==
'__main__'
:
framework
()
lib/python/Testing/ZopeTestCase/testZopeTestCase.py
View file @
cd4efecf
...
...
@@ -15,9 +15,8 @@
NOTE: This is *not* an example TestCase. Do not
use this file as a blueprint for your own tests!
See testPythonScript.py and testShoppingCart.py for
example test cases. See testSkeleton.py for a quick
way of getting started.
See testPythonScript.py for example test cases. See testSkeleton.py for a
quick way of getting started.
$Id$
"""
...
...
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