# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
import salt.modules.win_task as task
import salt.utils.platform
from salt.exceptions import CommandExecutionError
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest
from tests.support.unit import skipIf
@skipIf(not salt.utils.platform.is_windows(), "windows test only")
class WinTasksTest(ModuleCase):
"""
Tests for salt.modules.win_task.
"""
@destructiveTest
def test_adding_task_with_xml(self):
"""
Test adding a task using xml
"""
xml_text = r"""
2015-06-12T15:59:35.691983
System
true
PT30S
System
InteractiveToken
HighestAvailable
IgnoreNew
true
true
true
false
false
true
false
true
true
false
false
false
P3D
4
echo
"hello"
"""
self.assertEquals(
self.run_function("task.create_task_from_xml", "foo", xml_text=xml_text),
True,
)
all_tasks = self.run_function("task.list_tasks")
self.assertIn("foo", all_tasks)
@destructiveTest
def test_adding_task_with_invalid_xml(self):
"""
Test adding a task using a malformed xml
"""
xml_text = r"""