コード例 #1
0
    def test_present(self):
        '''
        scenario of creating upgrading extensions with possible schema and
        version specifications
        '''
        with patch.dict(postgres_extension.__salt__, {
                    'postgres.create_metadata': Mock(side_effect=[
                        [postgresmod._EXTENSION_NOT_INSTALLED],
                        [postgresmod._EXTENSION_INSTALLED],
                        [postgresmod._EXTENSION_TO_MOVE, postgresmod._EXTENSION_INSTALLED],

                    ]),
                    'postgres.create_extension': Mock(side_effect=[
                        True, True, True,
                    ])}):
            ret = postgres_extension.present('foo')
            self.assertEqual(
                ret,
                {'comment': 'The extension foo has been installed',
                 'changes': {'foo': 'Installed'}, 'name': 'foo', 'result': True}
            )
            ret = postgres_extension.present('foo')
            self.assertEqual(
                ret,
                {'comment': 'Extension foo is already present',
                 'changes': {}, 'name': 'foo', 'result': True}
            )
            ret = postgres_extension.present('foo')
            self.assertEqual(
                ret,
                {'comment': 'The extension foo has been upgraded',
                 'changes': {'foo': 'Upgraded'}, 'name': 'foo', 'result': True}
            )
コード例 #2
0
ファイル: postgres_test.py プロジェクト: bryson/salt
    def test_presenttest(self):
        '''
        scenario of creating upgrading extensions with possible schema and
        version specifications
        '''
        with patch.dict(postgres_extension.__opts__, {'test': True}):
            ret = postgres_extension.present('foo')
            self.assertEqual(
                ret,
                {'comment': 'Extension foo is set to be installed',
                 'changes': {}, 'name': 'foo', 'result': None}

            )
            ret = postgres_extension.present('foo')
            self.assertEqual(
                ret,
                {'comment': "Extension foo is set to be created",
                 'changes': {}, 'name': 'foo', 'result': None}

            )
            ret = postgres_extension.present('foo')
            self.assertEqual(
                ret,
                {'comment': "Extension foo is set to be upgraded",
                 'changes': {}, 'name': 'foo', 'result': None}
            )
コード例 #3
0
 def test_presenttest(self):
     '''
     scenario of creating upgrading extensions with possible schema and
     version specifications
     '''
     ret = postgres_extension.present('foo')
     self.assertEqual(
         ret, {
             'comment': 'Extension foo is set to be installed',
             'changes': {},
             'name': 'foo',
             'result': None
         })
     ret = postgres_extension.present('foo')
     self.assertEqual(
         ret, {
             'comment': "Extension foo is set to be created",
             'changes': {},
             'name': 'foo',
             'result': None
         })
     ret = postgres_extension.present('foo')
     self.assertEqual(
         ret, {
             'comment': "Extension foo is set to be upgraded",
             'changes': {},
             'name': 'foo',
             'result': None
         })
コード例 #4
0
    def test_present_failed(self):
        '''
        scenario of creating upgrading extensions with possible schema and
        version specifications
        '''
        with patch.dict(postgres_extension.__salt__, {
                    'postgres.create_metadata': Mock(side_effect=[
                        [postgresmod._EXTENSION_NOT_INSTALLED],
                        [postgresmod._EXTENSION_TO_MOVE, postgresmod._EXTENSION_INSTALLED],

                    ]),
                    'postgres.create_extension': Mock(side_effect=[
                        False, False,
                    ])}):
            ret = postgres_extension.present('foo')
            self.assertEqual(
                ret,
                {'comment': 'Failed to install extension foo',
                 'changes': {}, 'name': 'foo', 'result': False},
            )
            ret = postgres_extension.present('foo')
            self.assertEqual(
                ret,
                {'comment': 'Failed to upgrade extension foo',
                 'changes': {}, 'name': 'foo', 'result': False}
            )
コード例 #5
0
def test_present_failed():
    """
    scenario of creating upgrading extensions with possible schema and
    version specifications
    """
    with patch.dict(
            postgres_extension.__salt__,
        {
            "postgres.create_metadata":
            Mock(side_effect=[
                [postgresmod._EXTENSION_NOT_INSTALLED],
                [
                    postgresmod._EXTENSION_TO_MOVE,
                    postgresmod._EXTENSION_INSTALLED
                ],
            ]),
            "postgres.create_extension":
            Mock(side_effect=[False, False]),
        },
    ):
        ret = postgres_extension.present("foo")
        assert ret == {
            "comment": "Failed to install extension foo",
            "changes": {},
            "name": "foo",
            "result": False,
        }
        ret = postgres_extension.present("foo")
        assert ret == {
            "comment": "Failed to upgrade extension foo",
            "changes": {},
            "name": "foo",
            "result": False,
        }
コード例 #6
0
 def test_present(self):
     '''
     scenario of creating upgrading extensions with possible schema and
     version specifications
     '''
     ret = postgres_extension.present('foo')
     self.assertEqual(
         ret, {
             'comment': 'The extension foo has been installed',
             'changes': {},
             'name': 'foo',
             'result': True
         })
     ret = postgres_extension.present('foo')
     self.assertEqual(
         ret, {
             'comment': 'Extention foo is already present',
             'changes': {},
             'name': 'foo',
             'result': True
         })
     ret = postgres_extension.present('foo')
     self.assertEqual(
         ret, {
             'comment': 'The extension foo has been upgradeed',
             'changes': {},
             'name': 'foo',
             'result': True
         })
コード例 #7
0
 def test_present(self):
     """
     scenario of creating upgrading extensions with possible schema and
     version specifications
     """
     with patch.dict(
             postgres_extension.__salt__,
         {
             "postgres.create_metadata":
             Mock(side_effect=[
                 [postgresmod._EXTENSION_NOT_INSTALLED],
                 [postgresmod._EXTENSION_INSTALLED],
                 [
                     postgresmod._EXTENSION_TO_MOVE,
                     postgresmod._EXTENSION_INSTALLED,
                 ],
             ]),
             "postgres.create_extension":
             Mock(side_effect=[True, True, True]),
         },
     ):
         ret = postgres_extension.present("foo")
         self.assertEqual(
             ret,
             {
                 "comment": "The extension foo has been installed",
                 "changes": {
                     "foo": "Installed"
                 },
                 "name": "foo",
                 "result": True,
             },
         )
         ret = postgres_extension.present("foo")
         self.assertEqual(
             ret,
             {
                 "comment": "Extension foo is already present",
                 "changes": {},
                 "name": "foo",
                 "result": True,
             },
         )
         ret = postgres_extension.present("foo")
         self.assertEqual(
             ret,
             {
                 "comment": "The extension foo has been upgraded",
                 "changes": {
                     "foo": "Upgraded"
                 },
                 "name": "foo",
                 "result": True,
             },
         )
コード例 #8
0
ファイル: postgres_test.py プロジェクト: bryson/salt
 def test_present_failed(self):
     '''
     scenario of creating upgrading extensions with possible schema and
     version specifications
     '''
     ret = postgres_extension.present('foo')
     self.assertEqual(
         ret,
         {'comment': 'Failed to install extension foo',
          'changes': {}, 'name': 'foo', 'result': False},
     )
     ret = postgres_extension.present('foo')
     self.assertEqual(
         ret,
         {'comment': 'Failed to upgrade extension foo',
          'changes': {}, 'name': 'foo', 'result': False}
     )
コード例 #9
0
 def test_present_failed(self):
     '''
     scenario of creating upgrading extensions with possible schema and
     version specifications
     '''
     ret = postgres_extension.present('foo')
     self.assertEqual(
         ret,
         {'comment': 'Failed to install extension foo',
          'changes': {}, 'name': 'foo', 'result': False},
     )
     ret = postgres_extension.present('foo')
     self.assertEqual(
         ret,
         {'comment': 'Failed to upgrade extension foo',
          'changes': {}, 'name': 'foo', 'result': False}
     )
コード例 #10
0
def test_presenttest():
    """
    scenario of creating upgrading extensions with possible schema and
    version specifications
    """
    with patch.dict(
            postgres_extension.__salt__,
        {
            "postgres.create_metadata":
            Mock(side_effect=[
                [postgresmod._EXTENSION_NOT_INSTALLED],
                [postgresmod._EXTENSION_INSTALLED],
                [
                    postgresmod._EXTENSION_TO_MOVE,
                    postgresmod._EXTENSION_INSTALLED
                ],
            ]),
            "postgres.create_extension":
            Mock(side_effect=[True, True, True]),
        },
    ):
        with patch.dict(postgres_extension.__opts__, {"test": True}):
            ret = postgres_extension.present("foo")
            assert ret == {
                "comment": "Extension foo is set to be installed",
                "changes": {},
                "name": "foo",
                "result": None,
            }
            ret = postgres_extension.present("foo")
            assert ret == {
                "comment": "Extension foo is already present",
                "changes": {},
                "name": "foo",
                "result": True,
            }
            ret = postgres_extension.present("foo")
            assert ret == {
                "comment": "Extension foo is set to be upgraded",
                "changes": {},
                "name": "foo",
                "result": None,
            }
コード例 #11
0
    def test_present(self):
        '''
        Test to ensure that the named extension is present
        with the specified privileges.
        '''
        name = 'frank'

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

        mock = MagicMock(return_value={})
        with patch.dict(postgres_extension.__salt__,
                        {'postgres.create_metadata': mock}):
            with patch.dict(postgres_extension.__opts__, {'test': True}):
                comt = ('Extension {0} is set to be created'.format(name))
                ret.update({'comment': comt, 'result': None})
                self.assertDictEqual(postgres_extension.present(name), ret)

            with patch.dict(postgres_extension.__opts__, {'test': False}):
                comt = ('Extension {0} is already present'.format(name))
                ret.update({'comment': comt, 'result': True})
                self.assertDictEqual(postgres_extension.present(name), ret)
コード例 #12
0
    def test_present(self):
        """
        Test to ensure that the named extension is present
        with the specified privileges.
        """
        name = "frank"

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

        mock = MagicMock(return_value={})
        with patch.dict(
            postgres_extension.__salt__, {"postgres.create_metadata": mock}
        ):
            with patch.dict(postgres_extension.__opts__, {"test": True}):
                comt = "Extension {0} is already present".format(name)
                ret.update({"comment": comt, "result": True})
                self.assertDictEqual(postgres_extension.present(name), ret)

            with patch.dict(postgres_extension.__opts__, {"test": False}):
                comt = "Extension {0} is already present".format(name)
                ret.update({"comment": comt, "result": True})
                self.assertDictEqual(postgres_extension.present(name), ret)
コード例 #13
0
ファイル: postgres_test.py プロジェクト: bryson/salt
 def test_present(self):
     '''
     scenario of creating upgrading extensions with possible schema and
     version specifications
     '''
     ret = postgres_extension.present('foo')
     self.assertEqual(
         ret,
         {'comment': 'The extension foo has been installed',
          'changes': {'foo': 'Installed'}, 'name': 'foo', 'result': True}
     )
     ret = postgres_extension.present('foo')
     self.assertEqual(
         ret,
         {'comment': 'Extension foo is already present',
          'changes': {}, 'name': 'foo', 'result': True}
     )
     ret = postgres_extension.present('foo')
     self.assertEqual(
         ret,
         {'comment': 'The extension foo has been upgraded',
          'changes': {'foo': 'Upgraded'}, 'name': 'foo', 'result': True}
     )
コード例 #14
0
    def test_present(self):
        '''
        Test to ensure that the named extension is present
        with the specified privileges.
        '''
        name = 'frank'

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

        mock = MagicMock(return_value={})
        with patch.dict(postgres_extension.__salt__,
                        {'postgres.create_metadata': mock}):
            with patch.dict(postgres_extension.__opts__, {'test': True}):
                comt = ('Extension {0} is set to be created'.format(name))
                ret.update({'comment': comt, 'result': None})
                self.assertDictEqual(postgres_extension.present(name), ret)

            with patch.dict(postgres_extension.__opts__, {'test': False}):
                comt = ('Extension {0} is already present'.format(name))
                ret.update({'comment': comt, 'result': True})
                self.assertDictEqual(postgres_extension.present(name), ret)