Esempio n. 1
0
    def test_present(self):
        """
        Test to ensure the SNS topic exists.
        """
        name = "test.example.com."

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

        mock = MagicMock(side_effect=[True, False, False])
        mock_bool = MagicMock(return_value=False)
        with patch.dict(
            boto_sns.__salt__, {"boto_sns.exists": mock, "boto_sns.create": mock_bool}
        ):
            comt = "AWS SNS topic {0} present.".format(name)
            ret.update({"comment": comt})
            self.assertDictEqual(boto_sns.present(name), ret)

            with patch.dict(boto_sns.__opts__, {"test": True}):
                comt = "AWS SNS topic {0} is set to be created.".format(name)
                ret.update({"comment": comt, "result": None})
                self.assertDictEqual(boto_sns.present(name), ret)

            with patch.dict(boto_sns.__opts__, {"test": False}):
                comt = "Failed to create {0} AWS SNS topic".format(name)
                ret.update({"comment": comt, "result": False})
                self.assertDictEqual(boto_sns.present(name), ret)
Esempio n. 2
0
    def test_present(self):
        '''
        Test to ensure the SNS topic exists.
        '''
        name = 'test.example.com.'

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

        mock = MagicMock(side_effect=[True, False, False])
        mock_bool = MagicMock(return_value=False)
        with patch.dict(boto_sns.__salt__, {
                'boto_sns.exists': mock,
                'boto_sns.create': mock_bool
        }):
            comt = ('AWS SNS topic {0} present.'.format(name))
            ret.update({'comment': comt})
            self.assertDictEqual(boto_sns.present(name), ret)

            with patch.dict(boto_sns.__opts__, {'test': True}):
                comt = ('AWS SNS topic {0} is set to be created.'.format(name))
                ret.update({'comment': comt, 'result': None})
                self.assertDictEqual(boto_sns.present(name), ret)

            with patch.dict(boto_sns.__opts__, {'test': False}):
                comt = ('Failed to create {0} AWS SNS topic'.format(name))
                ret.update({'comment': comt, 'result': False})
                self.assertDictEqual(boto_sns.present(name), ret)
Esempio n. 3
0
    def test_present(self):
        '''
        Test to ensure the SNS topic exists.
        '''
        name = 'test.example.com.'

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

        mock = MagicMock(side_effect=[True, False, False])
        mock_bool = MagicMock(return_value=False)
        with patch.dict(boto_sns.__salt__,
                        {'boto_sns.exists': mock,
                         'boto_sns.create': mock_bool}):
            comt = ('AWS SNS topic {0} present.'.format(name))
            ret.update({'comment': comt})
            self.assertDictEqual(boto_sns.present(name), ret)

            with patch.dict(boto_sns.__opts__, {'test': True}):
                comt = ('AWS SNS topic {0} is set to be created.'.format(name))
                ret.update({'comment': comt, 'result': None})
                self.assertDictEqual(boto_sns.present(name), ret)

            with patch.dict(boto_sns.__opts__, {'test': False}):
                comt = ('Failed to create {0} AWS SNS topic'.format(name))
                ret.update({'comment': comt, 'result': False})
                self.assertDictEqual(boto_sns.present(name), ret)