38
43
layer = LaunchpadZopelessLayer
45
def test_notify_from_unicode_names(self):
46
# People with unicode in their names should appear correctly in the
47
# email and not get smashed to ASCII or otherwise transliterated.
48
RANDOM_UNICODE = u"Loïc"
49
creator = self.factory.makePerson(displayname=RANDOM_UNICODE)
50
spr = self.factory.makeSourcePackageRelease(creator=creator)
51
self.factory.makeSourcePackageReleaseFile(sourcepackagerelease=spr)
52
archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY)
53
pocket = PackagePublishingPocket.RELEASE
54
distroseries = self.factory.makeDistroSeries()
55
distroseries.changeslist = "blah@example.com"
56
blamer = self.factory.makePerson()
58
blamer, spr, [], [], archive, distroseries, pocket,
60
notifications = pop_notifications()
61
self.assertEqual(2, len(notifications))
62
msg = notifications[1].get_payload(0)
63
body = msg.get_payload(decode=True)
64
self.assertIn("Loïc", body)
40
66
def test_calculate_subject_customfile(self):
41
67
lfa = self.factory.makeLibraryFileAlias()
42
68
package_upload = self.factory.makePackageUpload()
87
113
'Maintainer': 'Foo Bar <foo.bar@canonical.com>',
88
114
'Changes': ' * Foo!',
90
(changesfile, date, changedby, maintainer) = fetch_information(
116
info = fetch_information(
91
117
None, None, changes)
92
self.assertEqual('2001-01-01', date)
93
self.assertEqual(' * Foo!', changesfile)
94
for field in (changedby, maintainer):
118
self.assertEqual('2001-01-01', info['date'])
119
self.assertEqual(' * Foo!', info['changesfile'])
123
info['changedby_displayname'],
124
info['maintainer_displayname'],
95
127
self.assertEqual('Foo Bar <foo.bar@canonical.com>', field)
97
129
def test_fetch_information_spr(self):
98
spr = self.factory.makeSourcePackageRelease()
99
(changesfile, date, changedby, maintainer) = fetch_information(
101
self.assertEqual(date, spr.dateuploaded)
102
self.assertEqual(changesfile, spr.changelog_entry)
103
self.assertEqual(changedby, format_address_for_person(spr.creator))
105
maintainer, format_address_for_person(spr.maintainer))
130
creator = self.factory.makePerson(displayname=u"foø")
131
maintainer = self.factory.makePerson(displayname=u"bær")
132
spr = self.factory.makeSourcePackageRelease(
133
creator=creator, maintainer=maintainer)
134
info = fetch_information(spr, None, None)
135
self.assertEqual(info['date'], spr.dateuploaded)
136
self.assertEqual(info['changesfile'], spr.changelog_entry)
138
info['changedby'], format_address_for_person(spr.creator))
140
info['maintainer'], format_address_for_person(spr.maintainer))
142
u"foø <%s>" % spr.creator.preferredemail.email,
143
info['changedby_displayname'])
145
u"bær <%s>" % spr.maintainer.preferredemail.email,
146
info['maintainer_displayname'])
107
148
def test_fetch_information_bprs(self):
108
149
bpr = self.factory.makeBinaryPackageRelease()
109
(changesfile, date, changedby, maintainer) = fetch_information(
150
info = fetch_information(None, [bpr], None)
111
151
spr = bpr.build.source_package_release
112
self.assertEqual(date, spr.dateuploaded)
113
self.assertEqual(changesfile, spr.changelog_entry)
114
self.assertEqual(changedby, format_address_for_person(spr.creator))
116
maintainer, format_address_for_person(spr.maintainer))
152
self.assertEqual(info['date'], spr.dateuploaded)
153
self.assertEqual(info['changesfile'], spr.changelog_entry)
155
info['changedby'], format_address_for_person(spr.creator))
157
info['maintainer'], format_address_for_person(spr.maintainer))
159
info['changedby_displayname'],
160
formataddr((spr.creator.displayname,
161
spr.creator.preferredemail.email)))
163
info['maintainer_displayname'],
164
formataddr((spr.maintainer.displayname,
165
spr.maintainer.preferredemail.email)))
118
167
def test_calculate_subject_spr(self):
119
168
spr = self.factory.makeSourcePackageRelease()