[Zodb-checkins] CVS: Zope3/src/zodb/tests - test_invalidation.py:1.1
Jeremy Hylton
jeremy@zope.com
Wed, 15 Jan 2003 18:33:09 -0500
Update of /cvs-repository/Zope3/src/zodb/tests
In directory cvs.zope.org:/tmp/cvs-serv7413/zodb/tests
Added Files:
test_invalidation.py
Log Message:
Add a trivial test of invalidation.
=== Added File Zope3/src/zodb/tests/test_invalidation.py ===
##############################################################################
#
# 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.
#
##############################################################################
"""Test that invalidations propagate across connections."""
import unittest
from zodb.db import DB
from zodb.storage.mapping import MappingStorage
from zodb.storage.tests.minpo import MinPO
from transaction import get_transaction
class InvalidationTests(unittest.TestCase):
num_connections = 3
def setUp(self):
self.storage = MappingStorage()
self.db = DB(self.storage)
self.connections = [self.db.open() for i in range(4)]
def tearDown(self):
self.db.close()
def testSimpleInvalidation(self):
root = self.connections[0].root()
obj = root[1] = MinPO(1)
get_transaction().commit()
for cn in self.connections[1:]:
cn.sync()
root = cn.root()
self.assertEqual(root[1].value, 1)
obj.value = 2
get_transaction().commit()
for cn in self.connections[1:]:
cn.sync()
root = cn.root()
self.assertEqual(root[1].value, 2)
def test_suite():
return unittest.makeSuite(InvalidationTests)