Skip to content

Commit e334493

Browse files
committed
Add unit tests for 'coriolis.osmorphing.windows'
1 parent c05511c commit e334493

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

coriolis/tests/osmorphing/test_windows.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,40 @@ def test__create_service(self):
302302
self.conn.exec_ps_command.assert_called_once_with(
303303
expected_commands, ignore_stdout=True)
304304

305+
def test__delete_startup_entry(self):
306+
self.morphing_tools._delete_startup_entry(
307+
"mock_key_name", "mock_service_name")
308+
309+
registry_path = ("HKLM:\\mock_key_name\\\Microsoft\\"
310+
"Windows\\CurrentVersion\\Run")
311+
312+
expected_commands = (
313+
"$ErrorActionPreference = 'Stop';"
314+
"Remove-ItemProperty -Path "
315+
f"'{registry_path}' "
316+
"-Name 'mock_service_name' -Force"
317+
)
318+
319+
self.conn.exec_ps_command.assert_called_once_with(
320+
expected_commands, ignore_stdout=True)
321+
322+
def test__delete_uninstall_entry(self):
323+
self.morphing_tools._delete_unistall_entry(
324+
"mock_key_name", "mock_service_name")
325+
326+
registry_path = ("HKLM:\\mock_key_name\\\Microsoft\\"
327+
"Windows\\CurrentVersion\\Uninstall\\*")
328+
329+
expected_commands = (
330+
"$ErrorActionPreference = 'Stop';"
331+
f"Get-ItemProperty '{registry_path}' | "
332+
"Where-Object { $_.DisplayName -like 'mock_service_name' } | "
333+
"ForEach-Object { Remove-Item -Path $_.PSPath -Force }"
334+
)
335+
336+
self.conn.exec_ps_command.assert_called_once_with(
337+
expected_commands, ignore_stdout=True)
338+
305339
@mock.patch.object(windows.utils, 'write_winrm_file')
306340
def test_run_user_script(self, mock_write_winrm_file):
307341
user_script = 'echo "Hello, World!"'

0 commit comments

Comments
 (0)