fix migration tests. do not use transactions during unit testing.
svn path=/plone.app.discussion/trunk/; revision=32805
This commit is contained in:
parent
c0bb88f44c
commit
dc2e5232f7
@ -35,7 +35,14 @@ class View(BrowserView):
|
|||||||
self.total_comments_migrated = 0
|
self.total_comments_migrated = 0
|
||||||
self.total_comments_deleted = 0
|
self.total_comments_deleted = 0
|
||||||
|
|
||||||
transaction.begin()
|
dry_run = self.request.has_key("dry_run")
|
||||||
|
|
||||||
|
# This is for testing only.
|
||||||
|
# Do not use transactions during a test.
|
||||||
|
test = self.request.has_key("test")
|
||||||
|
|
||||||
|
if not test:
|
||||||
|
transaction.begin()
|
||||||
|
|
||||||
catalog = getToolByName(context, 'portal_catalog')
|
catalog = getToolByName(context, 'portal_catalog')
|
||||||
dtool = context.portal_discussion
|
dtool = context.portal_discussion
|
||||||
@ -137,7 +144,8 @@ class View(BrowserView):
|
|||||||
log("Something went wrong during migration. The number of migrated comments (%s)\
|
log("Something went wrong during migration. The number of migrated comments (%s)\
|
||||||
differs from the number of deleted comments (%s)."
|
differs from the number of deleted comments (%s)."
|
||||||
% (self.total_comments_migrated, self.total_comments_deleted))
|
% (self.total_comments_migrated, self.total_comments_deleted))
|
||||||
transaction.abort()
|
if not test:
|
||||||
|
transaction.abort()
|
||||||
log("Abort transaction")
|
log("Abort transaction")
|
||||||
|
|
||||||
log("\n")
|
log("\n")
|
||||||
@ -151,10 +159,10 @@ class View(BrowserView):
|
|||||||
log("%s comments could not be migrated." % (count_comments_old - self.total_comments_migrated))
|
log("%s comments could not be migrated." % (count_comments_old - self.total_comments_migrated))
|
||||||
log("Please make sure your portal catalog is up-to-date.")
|
log("Please make sure your portal catalog is up-to-date.")
|
||||||
|
|
||||||
if self.request.has_key("dry_run"):
|
if dry_run and not test:
|
||||||
transaction.abort()
|
transaction.abort()
|
||||||
log("Dry run")
|
log("Dry run")
|
||||||
log("Abort transaction")
|
log("Abort transaction")
|
||||||
|
if not test:
|
||||||
transaction.commit()
|
transaction.commit()
|
||||||
return '\n'.join(out)
|
return '\n'.join(out)
|
||||||
|
@ -29,6 +29,7 @@ class MigrationTest(PloneTestCase):
|
|||||||
self.workflow.doActionFor(self.portal.doc, 'publish')
|
self.workflow.doActionFor(self.portal.doc, 'publish')
|
||||||
|
|
||||||
request = self.app.REQUEST
|
request = self.app.REQUEST
|
||||||
|
request.set("test", True)
|
||||||
context = getattr(self.portal, 'doc')
|
context = getattr(self.portal, 'doc')
|
||||||
self.view = View(context, request)
|
self.view = View(context, request)
|
||||||
self.workflow.setChainForPortalTypes(('Discussion Item',), 'comment_review_workflow')
|
self.workflow.setChainForPortalTypes(('Discussion Item',), 'comment_review_workflow')
|
||||||
|
Loading…
Reference in New Issue
Block a user