6
6
from cStringIO import StringIO
8
8
from debian.deb822 import Changes
9
from testtools.matchers import LessThan
10
11
from canonical.config import config
11
12
from canonical.launchpad.webapp.errorlog import ErrorReportingUtility
131
133
published_copy.status, PackagePublishingStatus.PENDING)
132
134
self.assertEqual(copy_source, published_copy.sourcepackagerelease)
136
def test_commits_after_each_item(self):
137
# Test that the script commits after each item, not just at the end.
139
self.createWaitingAcceptancePackage(
141
self.factory.makeDistroSeries(distribution=self.distro),
142
sourcename='source%d' % i)
145
class UploadCheckingSynchronizer:
149
def beforeCompletion(inner_self, txn):
152
def afterCompletion(inner_self, txn):
153
if txn.status != 'Committed':
155
inner_self.commit_count += 1
157
upload for upload in uploads
158
if upload.package_upload.status ==
159
PackageUploadStatus.DONE])
161
min(len(uploads), inner_self.commit_count),
164
script = self.getScript([])
165
self.layer.txn.commit()
166
self.layer.switchDbUser(self.dbuser)
167
synch = UploadCheckingSynchronizer()
168
script.txn.registerSynch(synch)
170
self.assertThat(len(uploads), LessThan(synch.commit_count))
135
173
class TestBugsFromChangesFile(TestCaseWithFactory):
136
174
"""Test get_bugs_from_changes_file."""