243
244
shutil.rmtree(root_dir)
246
@patch('ubuntucoreupgrader.upgrader.get_mount_details')
247
@patch('ubuntucoreupgrader.upgrader.mount')
248
@patch('ubuntucoreupgrader.upgrader.unmount')
249
def test_no_format_in_cmd(self, mock_umount, mock_mount,
252
# If the command file does not contain the format command, mkfs
253
# should not be called.
254
with patch('ubuntucoreupgrader.upgrader.mkfs') as mock_mkfs:
256
options = parse_args(args=args)
257
commands = make_commands([self.TARFILE])
258
upgrader = Upgrader(options, commands, [])
259
upgrader.TIMESTAMP_FILE = '/dev/null'
260
upgrader.MOUNTPOINT_CMD = "true"
263
# No format command in command file, so should not have been
265
self.assertFalse(mock_mkfs.called)
267
@patch('ubuntucoreupgrader.upgrader.get_mount_details')
268
@patch('ubuntucoreupgrader.upgrader.mount')
269
@patch('ubuntucoreupgrader.upgrader.unmount')
270
def test_format(self, mock_umount, mock_mount, mock_mount_details):
271
MOCK_FS_TUPLE = ("device", "fstype", "label")
272
mock_mount_details.return_value = MOCK_FS_TUPLE
274
# mkfs should be called if the format command is specified in
276
with patch('ubuntucoreupgrader.upgrader.mkfs') as mock_mkfs:
278
options = parse_args(args=args)
279
commands = make_commands([self.TARFILE])
281
# add format command to command file
282
commands.insert(0, 'format system')
284
upgrader = Upgrader(options, commands, [])
285
upgrader.TIMESTAMP_FILE = '/dev/null'
286
upgrader.MOUNTPOINT_CMD = "true"
289
mock_mkfs.assert_called_with(*MOCK_FS_TUPLE)
246
291
if __name__ == "__main__":