def test_install(self): ''' Test win_servermanager.install ''' mock = MagicMock( return_value={ 'ExitCode': 0, 'Success': True, 'FeatureResult': [{ 'DisplayName': 'Spongebob', 'RestartNeeded': False }] }) with patch.dict(win_servermanager.__grains__, {'osversion': '10.0.15130'}): with patch.object(win_servermanager, '_pshell_json', mock): expected = { 'ExitCode': 0, 'DisplayName': 'Spongebob', 'RestartNeeded': False, 'Success': True } self.assertDictEqual( win_servermanager.install('Telnet-Client'), expected)
def test_install(self): ''' Test if it install a feature. ''' with patch.dict(win_servermanager.__salt__, {'cmd.run': self._m_run()}): self.assertDictEqual(win_servermanager.install('Telnet-Client'), {'message': ''})
def test_install(self): ''' Test if it install a feature. ''' with patch.dict(win_servermanager.__salt__, {'cmd.run': self._m_run()}): self.assertDictEqual(win_servermanager.install('Telnet-Client'), { 'message': '' })
def test_install_restart(): """ Test win_servermanager.install when restart=True """ mock_out = { "Success": True, "RestartNeeded": 1, "FeatureResult": [{ "Id": 338, "Name": "XPS-Viewer", "DisplayName": "XPS Viewer", "Success": True, "RestartNeeded": True, "Message": "", "SkipReason": 0, }], "ExitCode": 0, } expected = { "ExitCode": 0, "RestartNeeded": True, "Restarted": True, "Features": { "XPS-Viewer": { "DisplayName": "XPS Viewer", "Message": "", "RestartNeeded": True, "SkipReason": 0, "Success": True, } }, "Success": True, } mock_reboot = MagicMock(return_value=True) with patch.object(win_servermanager, "_pshell_json", return_value=mock_out), patch.dict( win_servermanager.__salt__, {"system.reboot": mock_reboot}): result = win_servermanager.install("XPS-Viewer", restart=True) mock_reboot.assert_called_once() assert result == expected