• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zopefoundation / transaction / 16399678488

18 Sep 2024 07:25AM UTC coverage: 99.793% (+0.1%) from 99.696%
16399678488

push

github

dataflake
- vb [ci skip]

299 of 306 branches covered (97.71%)

Branch coverage included in aggregate %.

3083 of 3083 relevant lines covered (100.0%)

1.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/transaction/tests/test_savepoint.py
1
##############################################################################
2
#
3
# Copyright (c) 2004 Zope Foundation and Contributors.
4
# All Rights Reserved.
5
#
6
# This software is subject to the provisions of the Zope Public License,
7
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
# FOR A PARTICULAR PURPOSE.
12
#
13
##############################################################################
14
import unittest
1✔
15

16

17
class SavepointTests(unittest.TestCase):
1✔
18

19
    def testRollbackRollsbackDataManagersThatJoinedLater(self):
1✔
20
        # A savepoint needs to not just rollback it's savepoints, but needs
21
        # to # rollback savepoints for data managers that joined savepoints
22
        # after the savepoint:
23
        import transaction
1✔
24
        from transaction.tests import savepointsample
1✔
25
        dm = savepointsample.SampleSavepointDataManager()
1✔
26
        dm['name'] = 'bob'
1✔
27
        sp1 = transaction.savepoint()
1✔
28
        dm['job'] = 'geek'
1✔
29
        transaction.savepoint()
1✔
30
        dm['salary'] = 'fun'
1✔
31
        dm2 = savepointsample.SampleSavepointDataManager()
1✔
32
        dm2['name'] = 'sally'
1✔
33

34
        self.assertIn('name', dm)
1✔
35
        self.assertIn('job', dm)
1✔
36
        self.assertIn('salary', dm)
1✔
37
        self.assertIn('name', dm2)
1✔
38

39
        sp1.rollback()
1✔
40

41
        self.assertIn('name', dm)
1✔
42
        self.assertNotIn('job', dm)
1✔
43
        self.assertNotIn('salary', dm)
1✔
44
        self.assertNotIn('name', dm2)
1✔
45

46
    def test_commit_after_rollback_for_dm_that_joins_after_savepoint(self):
1✔
47
        # There was a problem handling data managers that joined after a
48
        # savepoint.  If the savepoint was rolled back and then changes
49
        # made, the dm would end up being joined twice, leading to extra
50
        # tpc calls and pain.
51
        import transaction
1✔
52
        from transaction.tests import savepointsample
1✔
53
        sp = transaction.savepoint()
1✔
54
        dm = savepointsample.SampleSavepointDataManager()
1✔
55
        dm['name'] = 'bob'
1✔
56
        sp.rollback()
1✔
57
        dm['name'] = 'Bob'
1✔
58
        transaction.commit()
1✔
59
        self.assertEqual(dm['name'], 'Bob')
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc