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} )
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} )
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 })
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} )
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, }
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 })
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, }, )
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} )
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, }
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)
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)
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} )