279
279
mock_mkfs.assert_called_with(*MOCK_FS_TUPLE)
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
294
# mkfs should be called if the format command is specified in
297
options = parse_args(args=args)
298
commands = make_commands([self.TARFILE])
300
commands.insert(0, 'mount system')
301
commands.append('unmount system')
303
upgrader = Upgrader(options, commands, [])
304
upgrader.TIMESTAMP_FILE = '/dev/null'
305
upgrader.MOUNTPOINT_CMD = "true"
308
self.assertTrue(mock_sync_partitions.called)
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,
320
mock_sync_partitions):
321
MOCK_FS_TUPLE = ("device", "fstype", "label")
322
mock_mount_details.return_value = MOCK_FS_TUPLE
324
# mkfs should be called if the format command is specified in
327
options = parse_args(args=args)
328
commands = make_commands([self.TARFILE])
330
commands.insert(0, 'format system')
331
commands.insert(1, 'mount system')
332
commands.append('unmount system')
334
upgrader = Upgrader(options, commands, [])
335
upgrader.TIMESTAMP_FILE = '/dev/null'
336
upgrader.MOUNTPOINT_CMD = "true"
339
self.assertFalse(mock_sync_partitions.called)
281
341
def test_empty_removed_file(self):
282
342
root_dir = make_tmp_dir()