~jamesodhunt/ubuntu/vivid/ubuntu-core-upgrader/use-os-sync

« back to all changes in this revision

Viewing changes to ubuntucoreupgrader/tests/test_upgrader.py

  • Committer: Michael Vogt
  • Date: 2015-04-16 14:41:06 UTC
  • mfrom: (27.1.2 ubuntu-core-upgrader)
  • Revision ID: michael.vogt@ubuntu.com-20150416144106-b3gau0i0oesk5bdt
mergedĀ lp:~jamesodhunt/ubuntu/vivid/ubuntu-core-upgrader/bug-1444500

Show diffs side-by-side

added added

removed removed

Lines of Context:
278
278
 
279
279
        mock_mkfs.assert_called_with(*MOCK_FS_TUPLE)
280
280
 
 
281
    @patch.object(Upgrader, 'sync_partitions')
 
282
    @patch('ubuntucoreupgrader.upgrader.get_mount_details')
 
283
    @patch('ubuntucoreupgrader.upgrader.remount')
 
284
    @patch('ubuntucoreupgrader.upgrader.mount')
 
285
    @patch('ubuntucoreupgrader.upgrader.fsck')
 
286
    @patch('ubuntucoreupgrader.upgrader.mkfs')
 
287
    @patch('ubuntucoreupgrader.upgrader.unmount')
 
288
    def test_mount_unmount_no_format(self, mock_umount, mock_mkfs, mock_fsck,
 
289
                                     mock_mount, mock_remount,
 
290
                                     mock_mount_details, mock_sync_partitions):
 
291
        MOCK_FS_TUPLE = ("device", "fstype", "label")
 
292
        mock_mount_details.return_value = MOCK_FS_TUPLE
 
293
 
 
294
        # mkfs should be called if the format command is specified in
 
295
        # the command file.
 
296
        args = ['cmdfile']
 
297
        options = parse_args(args=args)
 
298
        commands = make_commands([self.TARFILE])
 
299
 
 
300
        commands.insert(0, 'mount system')
 
301
        commands.append('unmount system')
 
302
 
 
303
        upgrader = Upgrader(options, commands, [])
 
304
        upgrader.TIMESTAMP_FILE = '/dev/null'
 
305
        upgrader.MOUNTPOINT_CMD = "true"
 
306
        upgrader.run()
 
307
 
 
308
        self.assertTrue(mock_sync_partitions.called)
 
309
 
 
310
    @patch.object(Upgrader, 'sync_partitions')
 
311
    @patch('ubuntucoreupgrader.upgrader.get_mount_details')
 
312
    @patch('ubuntucoreupgrader.upgrader.remount')
 
313
    @patch('ubuntucoreupgrader.upgrader.mount')
 
314
    @patch('ubuntucoreupgrader.upgrader.fsck')
 
315
    @patch('ubuntucoreupgrader.upgrader.mkfs')
 
316
    @patch('ubuntucoreupgrader.upgrader.unmount')
 
317
    def test_mount_unmount_with_format(self, mock_umount, mock_mkfs, mock_fsck,
 
318
                                       mock_mount, mock_remount,
 
319
                                       mock_mount_details,
 
320
                                       mock_sync_partitions):
 
321
        MOCK_FS_TUPLE = ("device", "fstype", "label")
 
322
        mock_mount_details.return_value = MOCK_FS_TUPLE
 
323
 
 
324
        # mkfs should be called if the format command is specified in
 
325
        # the command file.
 
326
        args = ['cmdfile']
 
327
        options = parse_args(args=args)
 
328
        commands = make_commands([self.TARFILE])
 
329
 
 
330
        commands.insert(0, 'format system')
 
331
        commands.insert(1, 'mount system')
 
332
        commands.append('unmount system')
 
333
 
 
334
        upgrader = Upgrader(options, commands, [])
 
335
        upgrader.TIMESTAMP_FILE = '/dev/null'
 
336
        upgrader.MOUNTPOINT_CMD = "true"
 
337
        upgrader.run()
 
338
 
 
339
        self.assertFalse(mock_sync_partitions.called)
 
340
 
281
341
    def test_empty_removed_file(self):
282
342
        root_dir = make_tmp_dir()
283
343