168
169
expected_email = email.format(package_name=spr.sourcepackagename.name)
169
170
self.assertIn(expected_email, bcc_address)
172
def test_fetch_information_spr_multiple_changelogs(self):
173
# If previous_version is passed the "changelog" entry in the
174
# returned dict should contain the changelogs for all SPRs *since*
175
# that version and up to and including the passed SPR.
176
changelog = self.factory.makeChangelog(
177
spn="foo", versions=["1.2", "1.1", "1.0"])
178
spph = self.factory.makeSourcePackagePublishingHistory(
179
sourcepackagename="foo", version="1.3", changelog=changelog)
180
self.layer.txn.commit() # Yay, librarian.
182
spr = spph.sourcepackagerelease
183
info = fetch_information(spr, None, None, previous_version="1.0")
185
self.assertIn("foo (1.1)", info['changelog'])
186
self.assertIn("foo (1.2)", info['changelog'])
188
def test_notify_bpr_rejected(self):
189
# If we notify about a rejected bpr with no source, a notification is
191
bpr = self.factory.makeBinaryPackageRelease()
192
changelog = self.factory.makeChangelog(spn="foo", versions=["1.1"])
194
bpr.build.source_package_release).changelog = changelog
195
self.layer.txn.commit()
196
archive = self.factory.makeArchive()
197
pocket = self.factory.getAnyPocket()
198
distroseries = self.factory.makeDistroSeries()
199
person = self.factory.makePerson()
201
person, None, [bpr], [], archive, distroseries, pocket,
203
[notification] = pop_notifications()
204
body = notification.get_payload()[0].get_payload()
205
self.assertEqual(person_to_email(person), notification['To'])
206
expected_body = dedent("""\
208
Rejected by archive administrator.
210
foo (1.1) unstable; urgency=3Dlow
216
If you don't understand why your files were rejected please send an email
217
to launchpad-users@lists.launchpad.net for help (requires membership).
221
You are receiving this email because you are the uploader of the above
224
self.assertEqual(expected_body, body)
172
227
class TestNotification(TestCaseWithFactory):
200
255
creator=creator, maintainer=maintainer)
201
256
info = fetch_information(spr, None, None)
202
257
self.assertEqual(info['date'], spr.dateuploaded)
203
self.assertEqual(info['changesfile'], spr.changelog_entry)
258
self.assertEqual(info['changelog'], spr.changelog_entry)
204
259
self.assertEqual(
205
260
info['changedby'], format_address_for_person(spr.creator))
206
261
self.assertEqual(
217
272
info = fetch_information(None, [bpr], None)
218
273
spr = bpr.build.source_package_release
219
274
self.assertEqual(info['date'], spr.dateuploaded)
220
self.assertEqual(info['changesfile'], spr.changelog_entry)
275
self.assertEqual(info['changelog'], spr.changelog_entry)
221
276
self.assertEqual(
222
277
info['changedby'], format_address_for_person(spr.creator))
223
278
self.assertEqual(
270
325
notifications = pop_notifications()
271
326
self.assertEqual(0, len(notifications))
273
def test_notify_bpr_rejected(self):
274
# If we notify about a rejected bpr with no source, a notification is
276
bpr = self.factory.makeBinaryPackageRelease()
278
bpr.build.source_package_release).changelog_entry = '* Foo!'
279
archive = self.factory.makeArchive()
280
pocket = self.factory.getAnyPocket()
281
distroseries = self.factory.makeDistroSeries()
282
person = self.factory.makePerson()
284
person, None, [bpr], [], archive, distroseries, pocket,
286
[notification] = pop_notifications()
287
body = notification.as_string()
288
self.assertEqual(person_to_email(person), notification['To'])
289
self.assertIn('Rejected by archive administrator.\n\n* Foo!\n', body)
291
328
def test_reject_changes_file_no_email(self):
292
329
# If we are rejecting a mail, and the person to notify has no
293
330
# preferred email, we should return early.