Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes
ZopeVersionControl.tests.testVersionControl.VersionControlTestsWithCommits Class Reference
Inheritance diagram for ZopeVersionControl.tests.testVersionControl.VersionControlTestsWithCommits:
Inheritance graph
[legend]
Collaboration diagram for ZopeVersionControl.tests.testVersionControl.VersionControlTestsWithCommits:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def testIsVersionableResource
def testIsUnderVersionControl
def testIsResourceUpToDate
def testIsResourceChanged
def testVersionBookkeeping
def testApplyVersionControl
def testCheckoutResource
def testCheckinResource
def testUncheckoutResource
def testUpdateResource
def testLabelResource
def testActivityAPI
def testSelectionByDate
def testSelectionByLabel
def testGetVersionOfResource
def testDetectPersistentSubObjectChange
def testContainerVersioning
def testNonVersionedAttribute
def testNonVersionedAttributeWithAcquisition

Static Public Attributes

int do_commits = 1
 setUp = common_setUp
 tearDown = common_tearDown
 commit = common_commit

Detailed Description

Version control test suite with transaction commits that mimic
   the transaction commits that you would get with Web based usage.

Definition at line 767 of file testVersionControl.py.


Member Function Documentation

Definition at line 396 of file testVersionControl.py.

00396 
00397     def testActivityAPI(self):
00398         from Products.ZopeVersionControl.Utility import VersionControlError
00399 
00400         repository = self.repository
00401         document = self.document1
00402 
00403         repository.applyVersionControl(document)
00404         self.commit()
00405 
00406         self.failUnless(repository.isUnderVersionControl(document))
00407         self.failUnless(repository.isResourceUpToDate(document))
00408         if self.do_commits:
00409             self.failIf(repository.isResourceChanged(document))
00410 
00411         info = repository.getVersionInfo(document)
00412         self.failUnless(info.sticky == None)
00413         first_version = info.version_id
00414 
00415         activity_name = 'My Big Project'
00416 
00417         repository.makeActivity(document, activity_name)
00418         self.commit()
00419 
00420         # Make sure we can't do it again for the same activity id.
00421         self.failUnlessRaises(VersionControlError,
00422                               repository.makeActivity,
00423                               document, activity_name
00424                               )
00425 
00426         document = repository.updateResource(document, activity_name)
00427         self.commit()
00428 
00429         self.failUnless(repository.isResourceUpToDate(document))
00430         if self.do_commits:
00431             self.failIf(repository.isResourceChanged(document))
00432 
00433         info = repository.getVersionInfo(document)
00434         self.failUnless(info.version_id == first_version)
00435         self.failUnless(info.sticky == ('B', activity_name))
00436 
00437         repository.checkoutResource(document)
00438         self.commit()
00439 
00440         document.manage_edit('activity change 1', '')
00441         self.commit()
00442 
00443         document = repository.checkinResource(document, 'activity change 1')
00444         self.commit()
00445 
00446         info = repository.getVersionInfo(document)
00447         self.failUnless(info.sticky == ('B', activity_name))
00448 
00449         for n in range(10):
00450             activity_name = 'Activity %d' % n
00451 
00452             repository.makeActivity(document, activity_name)
00453             self.commit()
00454 
00455             info = repository.getVersionInfo(document)
00456             root_version = info.version_id
00457 
00458             document = repository.updateResource(document, activity_name)
00459             self.commit()
00460 
00461             self.failUnless(repository.isResourceUpToDate(document))
00462 
00463             info = repository.getVersionInfo(document)
00464             self.failUnless(info.sticky == ('B', activity_name))
00465             self.failUnless(info.version_id == root_version)
00466 
00467             repository.checkoutResource(document)
00468             self.commit()
00469                 
00470             document.manage_edit('activity change %d' % n, '')
00471             self.commit()
00472 
00473             document = repository.checkinResource(
00474                 document, 'activity change %d' % n
00475                 )
00476             self.commit()
00477 
00478             info = repository.getVersionInfo(document)
00479             self.failUnless(info.sticky == ('B', activity_name))
00480             self.failIf(info.version_id == root_version)
00481 
00482         document = repository.updateResource(document, root_version)
00483         self.commit()
00484 
00485         self.failIf(repository.isResourceUpToDate(document))
00486 
00487         document = repository.updateResource(document, first_version)
00488         self.commit()
00489 
00490 #        self.failUnless(repository.isResourceUpToDate(document))
00491 
00492 
00493 

Definition at line 157 of file testVersionControl.py.

00157 
00158     def testApplyVersionControl(self):
00159         # Test checking whether a versioned resource is up to date.
00160         from Products.ZopeVersionControl.Utility import VersionControlError
00161         repository = self.repository
00162 
00163         document = repository.applyVersionControl(self.document1)
00164         self.commit()
00165         self.failUnless(repository.isUnderVersionControl(document))
00166 
00167         # Make sure we can't do it a second time.
00168         self.failUnlessRaises(VersionControlError,
00169                               repository.applyVersionControl,
00170                               document
00171                               )
00172 
00173         info = repository.getVersionInfo(document)
00174     
00175         # Check that the last log entry record is what we expect.
00176         record = repository.getLogEntries(document)[0]
00177         self.failUnless(record.version_id == info.version_id)
00178         self.failUnless(record.user_id == 'UnitTester')
00179         self.failUnless(record.action == record.ACTION_CHECKIN)
00180         self.failUnless(record.path == '/folder1/folder2/document1')
00181 

Definition at line 228 of file testVersionControl.py.

00228 
00229     def testCheckinResource(self):
00230         # Test checking in a version controlled resource.
00231         from Products.ZopeVersionControl.Utility import VersionControlError
00232         repository = self.repository
00233 
00234         document = repository.applyVersionControl(self.document1)
00235         self.commit()
00236 
00237         # Make sure you can't checkin a checked-in resource.
00238         self.failUnlessRaises(VersionControlError,
00239                               repository.checkinResource,
00240                               document, ''
00241                               )
00242 
00243         info = repository.getVersionInfo(document)
00244         first_version = info.version_id
00245 
00246         repository.checkoutResource(document)
00247         self.commit()
00248 
00249         document = repository.checkinResource(document, '')
00250         self.commit()
00251 
00252         # Check that the last log entry record is what we expect.
00253         record = repository.getLogEntries(document)[0]
00254         info = repository.getVersionInfo(document)
00255         self.failUnless(record.version_id == info.version_id)
00256         self.failUnless(record.user_id == 'UnitTester')
00257         self.failUnless(record.action == record.ACTION_CHECKIN)
00258         self.failUnless(record.path == '/folder1/folder2/document1')
00259 
00260         self.failUnlessRaises(VersionControlError,
00261                               repository.checkinResource,
00262                               document, ''
00263                               )
00264 
00265         document = repository.updateResource(document, first_version)
00266         self.commit()
00267 
00268         self.failUnlessRaises(VersionControlError,
00269                               repository.checkinResource,
00270                               document, ''
00271                               )
00272 

Definition at line 182 of file testVersionControl.py.

00182 
00183     def testCheckoutResource(self):
00184         # Test checking out a version controlled resource.
00185         from Products.ZopeVersionControl.Utility import VersionControlError
00186         repository = self.repository
00187 
00188         document = repository.applyVersionControl(self.document1)
00189         self.commit()
00190 
00191         info = repository.getVersionInfo(document)
00192         first_version = info.version_id
00193 
00194         repository.checkoutResource(document)
00195         self.commit()
00196 
00197         # Make sure you can't checkout a checked-out resource.
00198         self.failUnlessRaises(VersionControlError,
00199                               repository.checkoutResource,
00200                               document
00201                               )
00202 
00203         # Check that the last log entry record is what we expect.
00204         record = repository.getLogEntries(document)[0]
00205         self.failUnless(record.version_id == first_version)
00206         self.failUnless(record.user_id == 'UnitTester')
00207         self.failUnless(record.action == record.ACTION_CHECKOUT)
00208         self.failUnless(record.path == '/folder1/folder2/document1')
00209 
00210         document = repository.checkinResource(document, '')
00211         self.commit()
00212         document = repository.updateResource(document, first_version)
00213         self.commit()
00214 
00215         # Make sure you can't checkout a non-up-to-date resource.
00216         self.failUnlessRaises(VersionControlError,
00217                               repository.checkoutResource,
00218                               document
00219                               )
00220 
00221         # Check that the last log entry record is what we expect.
00222         record = repository.getLogEntries(document)[0]
00223         self.failUnless(record.version_id == first_version)
00224         self.failUnless(record.user_id == 'UnitTester')
00225         self.failUnless(record.action == record.ACTION_UPDATE)
00226         self.failUnless(record.path == '/folder1/folder2/document1')
00227 

Definition at line 671 of file testVersionControl.py.

00671 
00672     def testContainerVersioning(self):
00673         from OFS.DTMLDocument import addDTMLDocument
00674         # Verify that containers and items are versioned independently.
00675         repository = self.repository
00676         folder1 = self.app.folder1
00677         folder2 = folder1.folder2
00678         folder1.testattr = 'container_v1'
00679         folder2.testattr = 'item_v1'
00680 
00681         self.assert_(not repository.isUnderVersionControl(folder1))
00682         repository.applyVersionControl(folder1)
00683         folder1 = self.app.folder1
00684         self.assert_(repository.isUnderVersionControl(folder1))
00685         self.assert_(not repository.isUnderVersionControl(folder2))
00686         repository.applyVersionControl(folder2)
00687         folder2 = folder1.folder2
00688         self.assert_(repository.isUnderVersionControl(folder2))
00689         self.assert_(not repository.isUnderVersionControl(folder2.document1))
00690 
00691         # Make the first version of folder1 and check it in.
00692         repository.checkoutResource(folder1)
00693         folder1 = self.app.folder1
00694         repository.checkinResource(folder1)
00695         folder1 = self.app.folder1
00696         folder2 = folder1.folder2
00697         info = repository.getVersionInfo(folder1)
00698         first_version = info.version_id
00699 
00700         # Change folder1 and check it in again
00701         repository.checkoutResource(folder1)
00702         folder1 = self.app.folder1
00703         folder1.testattr = 'container_v2'
00704         addDTMLDocument(folder1, 'document3', file='some more text')
00705         repository.checkinResource(folder1)
00706         folder1 = self.app.folder1
00707         folder2 = folder1.folder2
00708 
00709         # Change folder2
00710         repository.checkoutResource(folder2)
00711         folder2 = folder1.folder2
00712         folder2.testattr = 'item_v2'
00713 
00714         # Now revert folder1 and verify that folder2 was not reverted.
00715         repository.updateResource(folder1, first_version)
00716         folder1 = self.app.folder1
00717         folder2 = folder1.folder2
00718         self.assertEqual(folder1.testattr, 'container_v1')
00719         self.assertEqual(folder2.testattr, 'item_v2')
00720 
00721         # Verify that document3 remains an item of the reverted folder1.
00722         self.assert_(hasattr(folder1, 'document3'))
00723         self.assert_(str(folder1.document3) == 'some more text')
00724 
00725         # Remove document3 and verify that it doesn't reappear upon revert.
00726         folder1._delObject('document3')
00727         repository.updateResource(folder1, '')
00728         folder1 = self.app.folder1
00729         self.assertEqual(folder1.testattr, 'container_v2')
00730         self.assertEqual(folder1.folder2.testattr, 'item_v2')
00731         self.assert_(not hasattr(folder1, 'document3'))
00732 

Definition at line 654 of file testVersionControl.py.

00654 
00655     def testDetectPersistentSubObjectChange(self):
00656         # Test detection of changes to persistent sub-objects.
00657         repository = self.repository
00658         folder2 = self.folder2
00659         document = self.document1
00660 
00661         # Place a resource w/ persistent subobjects under version control.
00662         repository.applyVersionControl(folder2)
00663         get_transaction().commit()
00664 
00665         document1 = getattr(folder2, 'document1')
00666         document1.manage_edit('spam spam', '')
00667         get_transaction().commit()
00668 
00669         self.failUnless(repository.isResourceChanged(folder2))
00670 

Definition at line 614 of file testVersionControl.py.

00614 
00615     def testGetVersionOfResource(self):
00616         # Test retrieving specific versions of resources.
00617         from Products.ZopeVersionControl.Utility import VersionControlError
00618         repository = self.repository
00619 
00620         document = repository.applyVersionControl(self.document1)
00621         self.commit()
00622 
00623         info = repository.getVersionInfo(document)
00624         history_id = info.history_id
00625         first_version = info.version_id
00626 
00627         repository.labelResource(document, 'First Version')
00628 
00629         for n in range(10):
00630             repository.checkoutResource(document)
00631             self.commit()
00632             document = repository.checkinResource(document, '')
00633             self.commit()
00634 
00635         # Make sure the "get version of resource" api is working.
00636         doc_copy = repository.getVersionOfResource(
00637             info.history_id, first_version
00638             )
00639         info = repository.getVersionInfo(doc_copy)
00640         self.failUnless(info.version_id == first_version)
00641         self.failUnless(info.sticky == ('V', first_version))
00642         self.failUnless(document._p_oid != doc_copy._p_oid)
00643         self.failUnless(document is not doc_copy)
00644 
00645         doc_copy = repository.getVersionOfResource(
00646             info.history_id, "First Version"
00647             )
00648         info = repository.getVersionInfo(doc_copy)
00649         self.failUnless(info.version_id == first_version)
00650         self.failUnless(info.sticky == ('L', 'First Version'))
00651         self.failUnless(document._p_oid != doc_copy._p_oid)
00652         self.failUnless(document is not doc_copy)
00653 

Definition at line 77 of file testVersionControl.py.

00077 
00078     def testIsResourceChanged(self):
00079         # Test checking whether a versioned resource has changed.
00080         repository = self.repository
00081         document = repository.applyVersionControl(self.document1)
00082         self.commit()
00083         if self.do_commits:
00084             self.failIf(repository.isResourceChanged(document))
00085 
00086         document = repository.checkoutResource(document)
00087         self.commit()
00088         if self.do_commits:
00089             self.failIf(repository.isResourceChanged(document))
00090 
00091         document.manage_edit('change 1', '')
00092         self.commit()
00093         if self.do_commits:
00094             self.failUnless(repository.isResourceChanged(document))
00095 
00096         document = repository.checkinResource(document, '')
00097         self.commit()
00098         if self.do_commits:
00099             self.failIf(repository.isResourceChanged(document))
00100 

Definition at line 53 of file testVersionControl.py.

00053 
00054     def testIsResourceUpToDate(self):
00055         # Test checking whether a versioned resource is up to date.
00056         repository = self.repository
00057         document = repository.applyVersionControl(self.document1)
00058         self.commit()
00059         self.failUnless(repository.isResourceUpToDate(document))
00060 
00061         info = repository.getVersionInfo(document)
00062         first_version = info.version_id
00063 
00064         document = repository.checkoutResource(document)
00065         self.commit()
00066         document = repository.checkinResource(document, '')
00067         self.commit()
00068 
00069         document = repository.updateResource(document, first_version)
00070         self.commit()
00071         self.failIf(repository.isResourceUpToDate(document))
00072 
00073         document = repository.updateResource(document, None)
00074         self.commit()
00075         self.failUnless(repository.isResourceUpToDate(document))
00076 

Definition at line 43 of file testVersionControl.py.

00043 
00044     def testIsUnderVersionControl(self):
00045         # Test checking whether an object is under version control.
00046         repository = self.repository
00047         document = self.document1
00048         self.failIf(repository.isUnderVersionControl(document))
00049         repository.applyVersionControl(document)
00050         self.commit()
00051         self.failUnless(repository.isUnderVersionControl(document))
00052 

Definition at line 32 of file testVersionControl.py.

00032 
00033     def testIsVersionableResource(self):
00034         # Test checking whether an object is a versionable resource.
00035         repository = self.repository
00036         document = self.document1
00037         nonversionable = self.document_nonversion
00038         self.failUnless(repository.isAVersionableResource(document))
00039         self.failIf(repository.isAVersionableResource(nonversionable))
00040         self.failIf(repository.isAVersionableResource('foobar'))
00041         self.failIf(repository.isAVersionableResource(self))
00042 

Definition at line 343 of file testVersionControl.py.

00343 
00344     def testLabelResource(self):
00345         # Test labeling a version controlled resource.
00346         from Products.ZopeVersionControl.Utility import VersionControlError
00347         repository = self.repository
00348 
00349         document = repository.applyVersionControl(self.document1)
00350         self.commit()
00351 
00352         info = repository.getVersionInfo(document)
00353         first_version = info.version_id
00354 
00355         repository.labelResource(document, 'First Version', 1)
00356 
00357         document = repository.checkoutResource(document)
00358         self.commit()
00359 
00360         self.failUnlessRaises(VersionControlError,
00361                               repository.labelResource,
00362                               document, 'First Version', 1
00363                               )
00364 
00365         document = repository.uncheckoutResource(document)
00366         self.commit()
00367 
00368         repository.makeActivity(document, 'Activity 1')
00369 
00370         self.failUnlessRaises(VersionControlError,
00371                               repository.labelResource,
00372                               document, 'mainline', 1
00373                               )
00374 
00375         self.failUnlessRaises(VersionControlError,
00376                               repository.labelResource,
00377                               document, 'Activity 1', 1
00378                               )
00379 
00380         document = repository.checkoutResource(document)
00381         self.commit()
00382 
00383         document = repository.checkinResource(document, '')
00384         self.commit()
00385 
00386         self.failUnlessRaises(VersionControlError,
00387                               repository.labelResource,
00388                               document, 'First Version', 0
00389                               )
00390 
00391         document = repository.updateResource(document, 'First Version')
00392         self.commit()
00393         info = repository.getVersionInfo(document)
00394         self.failUnless(info.version_id == first_version)
00395 

Definition at line 733 of file testVersionControl.py.

00733 
00734     def testNonVersionedAttribute(self):
00735         # Test a non-version-controlled attribute mixed with
00736         # a version-controlled attribute.
00737         self.document1.extra_attr = 'v1'
00738         self.document1.__vc_ignore__ = ('__ac_local_roles__',)
00739         self.document1.__ac_local_roles__ = {'sam': ['Manager',]}
00740         repository = self.repository
00741         document = repository.applyVersionControl(self.document1)
00742         info = repository.getVersionInfo(document)
00743         first_version = info.version_id
00744         repository.checkoutResource(document)
00745         self.document1.extra_attr = 'v2'
00746         self.document1.__ac_local_roles__ = {}
00747         repository.checkinResource(document)
00748         repository.updateResource(document, first_version)
00749         self.assertEqual(document.extra_attr, 'v1')
00750         self.assertEqual(document.__ac_local_roles__, {})

Definition at line 751 of file testVersionControl.py.

00751 
00752     def testNonVersionedAttributeWithAcquisition(self):
00753         # Test a non-version-controlled attribute 
00754         # that is acquired does not cause an error
00755         self.document1.__vc_ignore__ = ('dummy_attr',)
00756         self.folder1.dummy_attr = 'dummy_attr'
00757         self.assertEqual( self.folder1.dummy_attr, self.document1.dummy_attr )
00758 
00759         repository = self.repository
00760         document = repository.applyVersionControl(self.document1)
00761         info = repository.getVersionInfo(document)
00762         first_version = info.version_id
00763         repository.checkoutResource(document)
00764         self.document1.extra_attr = 'new'
00765         repository.checkinResource(document)
00766         repository.updateResource(document, first_version)

Definition at line 494 of file testVersionControl.py.

00494 
00495     def testSelectionByDate(self):
00496         # Test selection of versions by date.
00497         from Products.ZopeVersionControl.Utility import VersionControlError
00498         from DateTime.DateTime import DateTime
00499         import time
00500 
00501         repository = self.repository
00502         document = repository.applyVersionControl(self.document1)
00503         self.commit()
00504 
00505         document = repository.checkoutResource(document)
00506         self.commit()
00507 
00508         document.manage_edit('change 1', '')
00509         self.commit()
00510 
00511         document = repository.checkinResource(document, 'change 1')
00512         self.commit()
00513 
00514         repository.labelResource(document, 'change 1')
00515         self.commit()
00516 
00517         info = repository.getVersionInfo(document)
00518         first_version = info.version_id
00519 
00520         # Trickery: we'll hack the timestamp of the first version so
00521         # that we can act like it was created yesterday :)
00522         history = repository.getVersionHistory(info.history_id)
00523         version = history.getVersionById(info.version_id)
00524         orig_time = version.date_created
00525         new_time = orig_time - 86400.0
00526         timestamp = int(orig_time / 60.0)
00527         new_stamp = int(new_time / 60.0)
00528         version.date_created = new_time
00529         branch = history._branches['mainline']
00530         key, val = branch.m_order.items()[0]
00531         del branch.m_date[timestamp]
00532         branch.m_date[new_stamp] = key
00533         self.commit()
00534 
00535         for n in range(10):
00536             document = repository.checkoutResource(document)
00537             self.commit()
00538             change_no = 'change %d' % (n + 2)
00539             document.manage_edit(change_no, '')
00540             self.commit()
00541             document = repository.checkinResource(document, change_no)
00542             self.commit()
00543             repository.labelResource(document, change_no)
00544             self.commit()
00545 
00546         target_time = time.time() - 14400.0
00547         document = repository.updateResource(document, target_time)
00548         self.commit()
00549         info = repository.getVersionInfo(document)
00550         self.failUnless(info.version_id == first_version)
00551 
00552         # Now do some branching and make sure we backtrack correctly
00553         # through the branch lineage when doing date selection.
00554         document = repository.updateResource(document, 'change 5')
00555         self.commit()
00556 
00557         for n in range(10):
00558             activity_name = 'Activity %d' % n
00559             repository.makeActivity(document, activity_name)
00560             self.commit()
00561             document = repository.updateResource(document, activity_name)
00562             self.commit()
00563             for i in range(10):
00564                 repository.checkoutResource(document)
00565                 self.commit()
00566                 document.manage_edit('activity change %d' % i, '')
00567                 self.commit()
00568                 document = repository.checkinResource(document, '')
00569                 self.commit()
00570 
00571         document = repository.updateResource(document, target_time)
00572         self.commit()
00573         info = repository.getVersionInfo(document)
00574         self.failUnless(info.version_id == first_version)
00575 

Definition at line 576 of file testVersionControl.py.

00576 
00577     def testSelectionByLabel(self):
00578         # Test labeling and selection of versions using labels.
00579         from Products.ZopeVersionControl.Utility import VersionControlError
00580 
00581         repository = self.repository
00582         document = repository.applyVersionControl(self.document1)
00583 
00584         # Ensure that labeling and lookup by label works as expected.
00585         label_set = []
00586         for n in range(10):
00587             change_no = 'change %d' % n
00588             document = repository.checkoutResource(document)
00589             document.manage_edit(change_no, '')
00590             document = repository.checkinResource(document, change_no)
00591             repository.labelResource(document, change_no)
00592             info = repository.getVersionInfo(document)
00593             label_set.append((change_no, info.version_id))
00594 
00595         for label, version_id in label_set:
00596             document = repository.updateResource(document, label)
00597             info = repository.getVersionInfo(document)
00598             self.failUnless(info.version_id == version_id)
00599             self.failUnless(info.sticky == ('L', label))
00600 
00601         # Ensure that label moving works as expected and that we get an
00602         # error if we try to reuse a label without forcing a label move.
00603         document = repository.updateResource(document, 'change 0')
00604         repository.labelResource(document, 'change 1', force=1)
00605         document = repository.updateResource(document, 'change 1')
00606         info = repository.getVersionInfo(document)
00607         self.failUnless(info.version_id == label_set[0][1])
00608 
00609         self.failUnlessRaises(VersionControlError,
00610                               repository.labelResource,
00611                               document, 'change 3'
00612                               )
00613 

Definition at line 273 of file testVersionControl.py.

00273 
00274     def testUncheckoutResource(self):
00275         # Test uncheckout of a version controlled resource.
00276         from Products.ZopeVersionControl.Utility import VersionControlError
00277         repository = self.repository
00278 
00279         document = repository.applyVersionControl(self.document1)
00280         self.commit()
00281 
00282         info = repository.getVersionInfo(document)
00283         first_version = info.version_id
00284 
00285         repository.checkoutResource(document)
00286         self.commit()
00287 
00288         document.manage_edit('change 1', '')
00289 
00290         document = repository.uncheckoutResource(document)
00291         self.commit()
00292 
00293         info = repository.getVersionInfo(document)
00294         self.failUnless(info.status == info.CHECKED_IN)
00295 
00296         # Check that the last log entry record is what we expect.
00297         record = repository.getLogEntries(document)[0]
00298         self.failUnless(record.version_id == first_version)
00299         self.failUnless(record.user_id == 'UnitTester')
00300         self.failUnless(record.action == record.ACTION_UNCHECKOUT)
00301         self.failUnless(record.path == '/folder1/folder2/document1')
00302 

Definition at line 303 of file testVersionControl.py.

00303 
00304     def testUpdateResource(self):
00305         # Test updating a version controlled resource.
00306         from Products.ZopeVersionControl.Utility import VersionControlError
00307         repository = self.repository
00308 
00309         document = repository.applyVersionControl(self.document1)
00310         self.commit()
00311 
00312         info = repository.getVersionInfo(document)
00313         first_version = info.version_id
00314 
00315         repository.labelResource(document, 'First Version', 1)
00316 
00317         repository.checkoutResource(document)
00318         self.commit()
00319 
00320         document = repository.checkinResource(document, '')
00321         self.commit()
00322 
00323         document = repository.updateResource(document, first_version)
00324         self.commit()
00325         info = repository.getVersionInfo(document)
00326         self.failUnless(info.version_id == first_version)
00327 
00328         document = repository.updateResource(document, None)
00329         self.commit()
00330 
00331         document = repository.updateResource(document, 'First Version')
00332         self.commit()
00333         info = repository.getVersionInfo(document)
00334         self.failUnless(info.version_id == first_version)
00335 
00336         # Check that the last log entry record is what we expect.
00337         record = repository.getLogEntries(document)[0]
00338         self.failUnless(record.version_id == first_version)
00339         self.failUnless(record.user_id == 'UnitTester')
00340         self.failUnless(record.action == record.ACTION_UPDATE)
00341         self.failUnless(record.path == '/folder1/folder2/document1')
00342 

Definition at line 101 of file testVersionControl.py.

00101 
00102     def testVersionBookkeeping(self):
00103         # Check the consistency of the version bookkeeping info.
00104         repository = self.repository
00105 
00106         document = repository.applyVersionControl(self.document1)
00107         self.commit()
00108 
00109         info = repository.getVersionInfo(document)
00110         self.failUnless(info.user_id == 'UnitTester')
00111         self.failUnless(info.status == info.CHECKED_IN)
00112         self.failUnless(info.sticky == None)
00113         first_version = info.version_id
00114 
00115         document = repository.checkoutResource(document)
00116         self.commit()
00117         info = repository.getVersionInfo(document)
00118         self.failUnless(info.status == info.CHECKED_OUT)
00119 
00120         document = repository.checkinResource(document, '')
00121         self.commit()
00122         info = repository.getVersionInfo(document)
00123         self.failUnless(info.status == info.CHECKED_IN)
00124 
00125         document = repository.updateResource(document, first_version)
00126         self.commit()
00127         info = repository.getVersionInfo(document)
00128         self.failUnless(info.status == info.CHECKED_IN)
00129         self.failUnless(info.version_id == first_version)
00130 
00131         branch_name = 'Bug Fix Branch'
00132         repository.makeActivity(document, branch_name)
00133         self.commit()
00134         document = repository.updateResource(document, branch_name)
00135         self.commit()
00136         info = repository.getVersionInfo(document)
00137         self.failUnless(info.sticky == ('B', branch_name))
00138 
00139         document = repository.updateResource(document, 'mainline')
00140         self.commit()
00141         info = repository.getVersionInfo(document)
00142         self.failUnless(info.sticky == None)
00143 
00144         document = repository.checkoutResource(document)
00145         self.commit()
00146         info = repository.getVersionInfo(document)
00147         self.failUnless(info.status == info.CHECKED_OUT)
00148 
00149         document.manage_edit('change 1', '')
00150         self.commit()
00151 
00152         document = repository.uncheckoutResource(document)
00153         self.commit()
00154         info = repository.getVersionInfo(document)
00155         self.failUnless(info.status == info.CHECKED_IN)
00156 


Member Data Documentation

Definition at line 28 of file testVersionControl.py.

Definition at line 26 of file testVersionControl.py.

Definition at line 27 of file testVersionControl.py.


The documentation for this class was generated from the following file: