1413
1413
archive = self.test_publisher.ubuntutest.main_archive
1414
1414
source = self.test_publisher.getPubSource(
1415
1415
archive=archive, version='1.0-2', architecturehintlist='any')
1416
source.sourcepackagerelease.changelog_entry = '* Foo!'
1416
changelog = self.factory.makeChangelog(spn="foo", versions=["1.0-2"])
1417
source.sourcepackagerelease.changelog = changelog
1418
transaction.commit() # Librarian.
1417
1419
nobby = self.createNobby(('i386', 'hppa'))
1418
1420
getUtility(ISourcePackageFormatSelectionSet).add(
1419
1421
nobby, SourcePackageFormat.FORMAT_1_0)
1427
1429
self.assertEquals(
1428
1430
get_ppa_reference(target_archive),
1429
1431
notification['X-Launchpad-PPA'])
1431
source.sourcepackagerelease.changelog_entry,
1432
notification.as_string())
1432
body = notification.get_payload()[0].get_payload()
1433
expected = dedent("""\
1436
-> Component: main Section: base
1438
foo (1.0-2) unstable; urgency=3Dlow
1444
You are receiving this email because you are the uploader of the above
1447
self.assertEqual(expected, body)
1434
1449
def test_copy_generates_notification(self):
1435
1450
# When a copy into a primary archive is performed, a notification is
1437
1452
archive = self.test_publisher.ubuntutest.main_archive
1438
1453
source = self.test_publisher.getPubSource(
1439
1454
archive=archive, version='1.0-2', architecturehintlist='any')
1440
source.sourcepackagerelease.changelog_entry = '* Foo!'
1455
changelog = self.factory.makeChangelog(spn="foo", versions=["1.0-2"])
1456
source.sourcepackagerelease.changelog = changelog
1441
1457
# Copying to a primary archive reads the changes to close bugs.
1442
1458
transaction.commit()
1443
1459
nobby = self.createNobby(('i386', 'hppa'))
1455
1471
for mail in (notification, announcement):
1456
1472
self.assertEquals(
1457
1473
'[ubuntutest/nobby] foo 1.0-2 (Accepted)', mail['Subject'])
1458
expected_text = dedent("""
1474
expected_text = dedent("""\
1475
foo (1.0-2) unstable; urgency=3Dlow
1462
1480
Changed-By: Foo Bar <foo.bar@canonical.com>
1463
1481
http://launchpad.dev/ubuntutest/nobby/+source/foo/1.0-2
1464
1482
""" % source.sourcepackagerelease.dateuploaded)
1465
self.assertIn(expected_text, notification.as_string())
1466
self.assertIn(expected_text, announcement.as_string())
1483
# Spurious newlines are a pain and don't really affect the end
1484
# results so stripping is the easiest route here.
1485
expected_text.strip()
1486
body = mail.get_payload()[0].get_payload()
1487
self.assertEqual(expected_text, body)
1488
self.assertEqual(expected_text, body)
1490
def test_copy_notification_contains_aggregate_change_log(self):
1491
# When copying a package that generates a notification,
1492
# the changelog should contain all of the changelog_entry texts for
1493
# all the sourcepackagereleases between the last published version
1494
# and the new version.
1495
archive = self.test_publisher.ubuntutest.main_archive
1496
source3 = self.test_publisher.getPubSource(
1497
sourcename="foo", archive=archive, version='1.2',
1498
architecturehintlist='any')
1499
changelog = self.factory.makeChangelog(
1500
spn="foo", versions=["1.2", "1.1", "1.0"])
1501
source3.sourcepackagerelease.changelog = changelog
1502
transaction.commit()
1504
# Now make a new series, nobby, and publish foo 1.0 in it.
1505
nobby = self.createNobby(('i386', 'hppa'))
1506
getUtility(ISourcePackageFormatSelectionSet).add(
1507
nobby, SourcePackageFormat.FORMAT_1_0)
1508
nobby.changeslist = 'nobby-changes@example.com'
1509
source1 = self.factory.makeSourcePackageRelease(
1510
sourcepackagename="foo", version="1.0")
1511
self.factory.makeSourcePackagePublishingHistory(
1512
sourcepackagerelease=source1, distroseries=nobby,
1513
status=PackagePublishingStatus.PUBLISHED,
1514
pocket=source3.pocket)
1516
# Now copy foo 1.3 from ubuntutest.
1517
[copied_source] = do_copy(
1518
[source3], nobby.main_archive, nobby, source3.pocket, False,
1519
person=source3.sourcepackagerelease.creator,
1520
check_permissions=False, send_email=True)
1522
[notification, announcement] = pop_notifications()
1523
for mail in (notification, announcement):
1524
mailtext = mail.as_string()
1525
self.assertIn("foo (1.1)", mailtext)
1526
self.assertIn("foo (1.2)", mailtext)
1468
1528
def test_copy_generates_rejection_email(self):
1469
1529
# When a copy into a primary archive fails, we expect a rejection