Skip to content

Commit

Permalink
Fix black
Browse files Browse the repository at this point in the history
  • Loading branch information
twangboy committed Apr 20, 2020
1 parent 4ff1e2e commit 7b2ae02
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
26 changes: 13 additions & 13 deletions salt/modules/win_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
# Import Salt libs
import salt.utils.platform
import salt.utils.winapi
from salt.ext.six.moves import range
from salt.exceptions import ArgumentValueError, CommandExecutionError
from salt.ext.six.moves import range

# Import 3rd Party Libraries
try:
Expand Down Expand Up @@ -681,37 +681,37 @@ def create_task_from_xml(

except pythoncom.com_error as error:
hr, msg, exc, arg = error.args # pylint: disable=W0633
error_code = hex(exc[5] + 2**32)
error_code = hex(exc[5] + 2 ** 32)
fc = {
0x80041319: "Required element or attribute missing",
0x80041318: "Value incorrectly formatted or out of range",
0x80020005: "Access denied",
0x80041309: "A task's trigger is not found",
0x8004130a: "One or more of the properties required to run this "
"task have not been set",
"task have not been set",
0x8004130c: "The Task Scheduler service is not installed on this "
"computer",
"computer",
0x8004130d: "The task object could not be opened",
0x8004130e: "The object is either an invalid task object or is not "
"a task object",
"a task object",
0x8004130f: "No account information could be found in the Task "
"Scheduler security database for the task indicated",
"Scheduler security database for the task indicated",
0x80041310: "Unable to establish existence of the account "
"specified",
"specified",
0x80041311: "Corruption was detected in the Task Scheduler "
"security database; the database has been reset",
"security database; the database has been reset",
0x80041313: "The task object version is either unsupported or "
"invalid",
"invalid",
0x80041314: "The task has been configured with an unsupported "
"combination of account settings and run time options",
"combination of account settings and run time options",
0x80041315: "The Task Scheduler Service is not running",
0x80041316: "The task XML contains an unexpected node",
0x80041317: "The task XML contains an element or attribute from an "
"unexpected namespace",
"unexpected namespace",
0x8004131a: "The task XML is malformed",
0x0004131c: "The task is registered, but may fail to start. Batch "
"logon privilege needs to be enabled for the task "
"principal",
"logon privilege needs to be enabled for the task "
"principal",
0x8004131d: "The task XML contains too many nodes of the same type",
}
try:
Expand Down
28 changes: 15 additions & 13 deletions tests/integration/modules/test_win_task.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals

from tests.support.case import ModuleCase
from tests.support.unit import skipIf
from tests.support.helpers import destructiveTest

import salt.modules.win_task as task
from salt.exceptions import CommandExecutionError
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')
@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"""
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
Expand Down Expand Up @@ -66,15 +65,18 @@ def test_adding_task_with_xml(self):
</Actions>
</Task>
"""
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)
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"""<Malformed"""
with self.assertRaises(CommandExecutionError):
task.create_task_from_xml('foo', xml_text=xml_text)
2 changes: 1 addition & 1 deletion tests/unit/modules/test_win_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@skipIf(not salt.utils.platform.is_windows(), "System is not Windows")
class WinTaskTestCase(TestCase):
"""
Test cases for salt.modules.win_task
Test cases for salt.modules.win_task
"""

def test_repeat_interval(self):
Expand Down

0 comments on commit 7b2ae02

Please sign in to comment.