def test_reset_root_password_on_mysql_restore(self, chmod, remove): with patch.object(MySQLRestoreMixin, "_start_mysqld_safe_with_init_file", return_value=True): inst = MySQLRestoreMixin() inst.reset_root_password() chmod.assert_called_once_with(ANY, FileMode.ADD_READ_ALL, as_root=True) # Make sure the temporary error log got deleted as root # (see bug/1423759). remove.assert_called_once_with(ANY, force=True, as_root=True)
def test_reset_root_password_on_mysql_restore(self, chmod, remove): with patch.object(MySQLRestoreMixin, '_start_mysqld_safe_with_init_file', return_value=True): inst = MySQLRestoreMixin() inst.reset_root_password() chmod.assert_called_once_with( ANY, operating_system.FileMode.ADD_READ_ALL, as_root=True) # Make sure the temporary error log got deleted as root # (see bug/1423759). remove.assert_called_once_with(ANY, force=True, as_root=True)
def test_reset_root_password_on_mysql_restore(self): with patch.object(utils, 'execute_with_timeout', return_value=True) as exec_call: with patch.object(MySQLRestoreMixin, '_start_mysqld_safe_with_init_file', return_value=True): inst = MySQLRestoreMixin() inst.reset_root_password() self.assertEqual(2, exec_call.call_count, "'execute_with_timeout' " "called an unexpected number of times") exec_call.assert_any_call("sudo", "chmod", "a+r", ANY) # Make sure the temporary error log got deleted as root # (see bug/1423759). exec_call.assert_any_call("rm", "-f", ANY, run_as_root=True, root_helper="sudo")