コード例 #1
0
    def test_sections_present(self):
        """
        Test to verify sections present in file.
        """
        name = "salt"

        ret = {"name": name, "result": None, "comment": "", "changes": {}}

        with patch.dict(ini_manage.__opts__, {"test": True}):
            with patch.dict(ini_manage.__salt__,
                            {"ini.get_ini": MagicMock(return_value=None)}):
                comt = "No changes detected."
                ret.update({"comment": comt, "result": True})
                self.assertDictEqual(ini_manage.sections_present(name), ret)

        changes = {
            "first": "who is on",
            "second": "what is on",
            "third": "I don't know",
        }
        with patch.dict(ini_manage.__salt__,
                        {"ini.set_option": MagicMock(return_value=changes)}):
            with patch.dict(ini_manage.__opts__, {"test": False}):
                comt = "Changes take effect"
                ret.update({
                    "comment": comt,
                    "result": True,
                    "changes": changes
                })
                self.assertDictEqual(ini_manage.sections_present(name), ret)
コード例 #2
0
    def test_sections_present(self):
        '''
        Test to verify sections present in file.
        '''
        name = 'salt'

        ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}

        with patch.dict(ini_manage.__opts__, {'test': True}):
            comt = 'No changes detected.'
            ret.update({'comment': comt, 'result': True})
            self.assertDictEqual(ini_manage.sections_present(name), ret)

        changes = {
            'first': 'who is on',
            'second': 'what is on',
            'third': "I don't know"
        }
        with patch.dict(ini_manage.__salt__,
                        {'ini.set_option': MagicMock(return_value=changes)}):
            with patch.dict(ini_manage.__opts__, {'test': False}):
                comt = ('Changes take effect')
                ret.update({
                    'comment': comt,
                    'result': True,
                    'changes': changes
                })
                self.assertDictEqual(ini_manage.sections_present(name), ret)
コード例 #3
0
    def test_sections_present(self):
        '''
        Test to verify sections present in file.
        '''
        name = 'salt'

        ret = {'name': name,
               'result': None,
               'comment': '',
               'changes': {}}

        with patch.dict(ini_manage.__opts__, {'test': True}):
            comt = (('ini file {0} shall be validated for '
                     'presence of given sections with the '
                     'exact contents').format(name))
            ret.update({'comment': comt})
            self.assertDictEqual(ini_manage.sections_present(name), ret)

        with patch.dict(ini_manage.__opts__, {'test': False}):
            comt = ('No anomaly detected')
            ret.update({'comment': comt, 'result': True})
            self.assertDictEqual(ini_manage.sections_present(name), ret)