~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/archiveuploader/tests/test_sync_notification.py

  • Committer: Jeroen Vermeulen
  • Date: 2012-01-06 05:35:00 UTC
  • mto: This revision was merged to the branch mainline in revision 14645.
  • Revision ID: jeroen.vermeulen@canonical.com-20120106053500-db0mtsk7wasq0hsn
Also test against spamming the Changed-By author.

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
            close_bugs=False)
95
95
        return synced_spph
96
96
 
97
 
    def makeChangesFile(self, spph, maintainer, maintainer_address):
 
97
    def makeChangesFile(self, spph, maintainer, maintainer_address,
 
98
                        changer, changer_address):
98
99
        maintainer_key = self.factory.makeGPGKey(maintainer)
99
100
        temp_dir = self.makeTemporaryDirectory()
100
101
        changes_file = os.path.join(
101
102
            temp_dir, "%s.changes" % spph.source_package_name)
102
 
        open(changes_file, 'w').write(
103
 
            "Maintainer: %s <%s>\n" % (maintainer.name, maintainer_address))
 
103
        with open(changes_file, 'w') as changes:
 
104
            changes.write(
 
105
                "Maintainer: %s <%s>\n"
 
106
                "Changed-By: %s <%s>\n"
 
107
                % (
 
108
                    maintainer.name,
 
109
                    maintainer_address,
 
110
                    changer.name,
 
111
                    changer_address,
 
112
                    ))
104
113
        return FakeChangesFile(spph, changes_file, maintainer_key)
105
114
 
106
 
    def makeNascentUpload(self, spph, maintainer, maintainer_address):
 
115
    def makeNascentUpload(self, spph, maintainer, maintainer_address,
 
116
                          changer, changer_address):
107
117
        """Create a `NascentUpload` for `spph`."""
 
118
        changes = self.makeChangesFile(
 
119
            spph, maintainer, maintainer_address, changer, changer_address)
108
120
        upload = NascentUpload(
109
 
            self.makeChangesFile(spph, maintainer, maintainer_address),
110
 
            FakeUploadPolicy(spph), DevNullLogger())
 
121
            changes, FakeUploadPolicy(spph), DevNullLogger())
111
122
        upload.queue_root = upload._createQueueEntry()
112
123
        das = self.factory.makeDistroArchSeries(
113
124
            distroseries=spph.distroseries)
131
142
    def test_maintainer_not_notified_about_build_failure_elsewhere(self):
132
143
        """No mail to maintainers about builds they're not responsible for.
133
144
 
134
 
 
135
145
        We import Debian source packages, then sync them into Ubuntu (and
136
146
        from there, into Ubuntu-derived distros).  Those syncs then trigger
137
147
        builds that the original Debian maintainers are not responsible for.
138
148
 
139
 
        In a situation like that, we should not bother the maintainer with
140
 
        the failure.  We notify the person who requested the sync instead.
 
149
        In a situation like that, we should not bother the maintainer or
 
150
        the author of the last change with the failure.  We notify the
 
151
        person who requested the sync instead.
141
152
 
142
153
        This test guards against bug 876594.
143
154
        """
144
155
        maintainer, maintainer_address = self.makePersonWithEmail()
 
156
        changer, changer_address = self.makePersonWithEmail()
145
157
        dsp = self.factory.makeDistroSeriesParent()
146
158
        original_spph = self.makeSPPH(dsp.parent_series, maintainer_address)
147
159
        sync_requester, syncer_address = self.makePersonWithEmail()
148
160
        synced_spph = self.syncSource(
149
161
            original_spph, dsp.derived_series, sync_requester)
150
162
        nascent_upload = self.makeNascentUpload(
151
 
            synced_spph, maintainer, maintainer_address)
 
163
            synced_spph, maintainer, maintainer_address,
 
164
            changer, changer_address)
152
165
        pop_notifications()
153
166
        self.processAndRejectUpload(nascent_upload)
154
167
 
155
168
        notified_addresses = '\n'.join(self.getNotifiedAddresses())
156
169
 
157
170
        self.assertNotIn(maintainer_address, notified_addresses)
 
171
        self.assertNotIn(changer_address, notified_addresses)
158
172
        self.assertIn(syncer_address, notified_addresses)