def test_enabled(self): ''' Test to enable the RDP service and make sure access to the RDP port is allowed in the firewall configuration. ''' name = 'my_service' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} mock_t = MagicMock(side_effect=[False, False, True]) mock_f = MagicMock(return_value=False) with patch.dict(rdp.__salt__, {'rdp.status': mock_t, 'rdp.enable': mock_f}): with patch.dict(rdp.__opts__, {'test': True}): comt = ('RDP will be enabled') ret.update({'comment': comt, 'result': None}) self.assertDictEqual(rdp.enabled(name), ret) with patch.dict(rdp.__opts__, {'test': False}): ret.update({'comment': '', 'result': False, 'changes': {'RDP was enabled': True}}) self.assertDictEqual(rdp.enabled(name), ret) comt = ('RDP is enabled') ret.update({'comment': comt, 'result': True, 'changes': {}}) self.assertDictEqual(rdp.enabled(name), ret)
def test_enabled(self): ''' Test to enable the RDP service and make sure access to the RDP port is allowed in the firewall configuration. ''' name = 'my_service' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} mock_t = MagicMock(side_effect=[False, False, True]) mock_f = MagicMock(return_value=False) with patch.dict(rdp.__salt__, { 'rdp.status': mock_t, 'rdp.enable': mock_f }): with patch.dict(rdp.__opts__, {'test': True}): comt = ('RDP will be enabled') ret.update({'comment': comt, 'result': None}) self.assertDictEqual(rdp.enabled(name), ret) with patch.dict(rdp.__opts__, {'test': False}): ret.update({ 'comment': '', 'result': False, 'changes': { 'RDP was enabled': True } }) self.assertDictEqual(rdp.enabled(name), ret) comt = ('RDP is enabled') ret.update({'comment': comt, 'result': True, 'changes': {}}) self.assertDictEqual(rdp.enabled(name), ret)
def test_enabled(): """ Test to enable the RDP service and make sure access to the RDP port is allowed in the firewall configuration. """ name = "my_service" ret = {"name": name, "changes": {}, "result": True, "comment": ""} mock_t = MagicMock(side_effect=[False, False, True]) mock_f = MagicMock(return_value=False) with patch.dict(rdp.__salt__, { "rdp.status": mock_t, "rdp.enable": mock_f }): with patch.dict(rdp.__opts__, {"test": True}): comt = "RDP will be enabled" ret.update({"comment": comt, "result": None}) assert rdp.enabled(name) == ret with patch.dict(rdp.__opts__, {"test": False}): ret.update({ "comment": "", "result": False, "changes": { "RDP was enabled": True } }) assert rdp.enabled(name) == ret comt = "RDP is enabled" ret.update({"comment": comt, "result": True, "changes": {}}) assert rdp.enabled(name) == ret