def test_additions_installed(self): ''' Test to ensure that the VirtualBox Guest Additions are installed ''' ret = {'name': 'salt', 'changes': {}, 'result': True, 'comment': ''} mock = MagicMock(side_effect=[True, False, False, False]) with patch.dict(vbox_guest.__salt__, {"vbox_guest.additions_version": mock, "vbox_guest.additions_install": mock}): ret.update({'comment': 'System already in the correct state'}) self.assertDictEqual(vbox_guest.additions_installed('salt'), ret) with patch.dict(vbox_guest.__opts__, {"test": True}): ret.update({'changes': {'new': True, 'old': False}, 'comment': 'The state of VirtualBox Guest' ' Additions will be changed.', 'result': None}) self.assertDictEqual(vbox_guest.additions_installed('salt'), ret) with patch.dict(vbox_guest.__opts__, {"test": False}): ret.update({'changes': {'new': False, 'old': False}, 'comment': 'The state of VirtualBox Guest' ' Additions was changed!', 'result': False}) self.assertDictEqual(vbox_guest.additions_installed('salt'), ret)
def test_additions_installed(): """ Test to ensure that the VirtualBox Guest Additions are installed """ ret = {"name": "salt", "changes": {}, "result": True, "comment": ""} mock = MagicMock(side_effect=[True, False, False, False]) with patch.dict( vbox_guest.__salt__, {"vbox_guest.additions_version": mock, "vbox_guest.additions_install": mock}, ): ret.update({"comment": "System already in the correct state"}) assert vbox_guest.additions_installed("salt") == ret with patch.dict(vbox_guest.__opts__, {"test": True}): ret.update( { "changes": {"new": True, "old": False}, "comment": ( "The state of VirtualBox Guest Additions will be changed." ), "result": None, } ) assert vbox_guest.additions_installed("salt") == ret with patch.dict(vbox_guest.__opts__, {"test": False}): ret.update( { "changes": {"new": False, "old": False}, "comment": "The state of VirtualBox Guest Additions was changed!", "result": False, } ) assert vbox_guest.additions_installed("salt") == ret