~sil2100/cupstream2distro/dont_multi_merge

« back to all changes in this revision

Viewing changes to tests/unit/test_script_publisher.py

Skip publication only when version is already at dest. Fixes: https://bugs.launchpad.net/bugs/1416981.

Approved by PS Jenkins bot, ℝobert 𝔹ruce ℙark.

Show diffs side-by-side

added added

removed removed

Lines of Context:
178
178
        self.script.initiate_publication(dest, ppa, set_versions)
179
179
        self.script.find_ppa_sources.assert_called_once_with(
180
180
            ppa, sources, defaultdict(set))
181
 
        self.script.write_rsync_file.assert_called_once_with(sources)
 
181
        self.script.write_rsync_file.assert_called_once_with(sources, dest)
182
182
        self.assertEqual(self.script.copy_to_dest.call_count, 0)
183
183
        set_versions.assert_called_once_with(defaultdict(set))
184
184
 
204
204
 
205
205
    def test_write_rsync_file(self):
206
206
        """Ensure that we write the rsync packagelist correctly."""
 
207
        dest = Mock()
207
208
        sources = [
208
209
            SourceFake('foo', '1.0-0ubuntu1'),
209
210
            SourceFake('bar', '2.0-0ubuntu1'),
210
211
        ]
211
212
        self.script.PackageList = Mock()
212
213
        self.script.PackageList.return_value.series = 'vivid'
213
 
        self.script.write_rsync_file(sources)
 
214
        self.script.write_rsync_file(sources, dest)
214
215
        self.script.PackageList.assert_called_once_with()
215
216
        publish_source = self.script.PackageList().publish_source
216
217
        self.assertEqual(publish_source.mock_calls,
224
225
 
225
226
    def test_write_rsync_file_no_dupes(self):
226
227
        """Ensure that rsync file does not contain duplicate publishing."""
 
228
        dest = Mock()
227
229
        sources = [
228
230
            SourceFake('foo', '1.0-0ubuntu1'),
229
231
            SourceFake('bar', '2.0-0ubuntu1'),
230
232
        ]
231
 
        self.script.DotProject.return_value.published_version = '2.0-0ubuntu1'
 
233
        self.script.packagemanager.get_current_version_for_series\
 
234
            .return_value = '2.0-0ubuntu1'
232
235
        self.script.PackageList = Mock()
233
236
        self.script.PackageList.return_value.series = 'vivid'
234
 
        self.script.write_rsync_file(sources)
 
237
        self.script.write_rsync_file(sources, dest)
235
238
        self.script.PackageList.assert_called_once_with()
236
239
        publish_source = self.script.PackageList().publish_source
237
240
        self.assertEqual(publish_source.mock_calls,
238
241
                         [call(sources[0])])
239
242
        self.assertEqual(
240
243
            self.script.DotProject.mock_calls,
241
 
            [call('foo'), call().mark_as_published('1.0-0ubuntu1'),
242
 
             call('bar')])
 
244
            [call('foo'), call().mark_as_published('1.0-0ubuntu1')])
243
245
        self.assertEqual(self.script.logging.error.call_count, 0)
244
246
        self.script.PackageList().write.assert_called_once_with()
245
247
 
248
250
 
249
251
        And it should call copy_to_dest with the rest.
250
252
        """
 
253
        dest = Mock()
251
254
        trusty = 'https://api.launchpad.net/devel/ubuntu/trusty'
252
255
        utopic = 'https://api.launchpad.net/devel/ubuntu/utopic'
253
256
        vivid = 'https://api.launchpad.net/devel/ubuntu/vivid'
260
263
        ]
261
264
        self.script.copy_to_dest = Mock()
262
265
        self.script.PackageList = Mock()
263
 
        self.script.write_rsync_file(sources)
 
266
        self.script.write_rsync_file(sources, dest)
264
267
        self.script.PackageList.assert_called_once_with()
265
268
        publish_source = self.script.PackageList().publish_source
266
269
        self.assertEqual(publish_source.call_count, 2)