コード例 #1
0
    def test_check_instance_present_command_error(self):
        '''
        Test to check check_instance_present when it raises an error
        '''

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

        mock_is_instance_installed = MagicMock(
            side_effect=exceptions.CommandExecutionError('error'))
        with patch.dict(
                netweavermod.__salt__,
            {'netweaver.is_instance_installed': mock_is_instance_installed}):
            assert netweavermod.check_instance_present('MESSAGESERVER',
                                                       'GREEN', 'virtual',
                                                       'prd', 00,
                                                       'pass') == ret

        mock_is_instance_installed.assert_called_once_with(
            sap_instance='MESSAGESERVER',
            dispstatus='GREEN',
            virtual_host='virtual',
            sid='prd',
            inst=00,
            password='******')
コード例 #2
0
    def test_check_instance_present(self):
        '''
        Test to check check_instance_present when the instance is present
        '''

        ret = {
            'name': 'MESSAGESERVER',
            'changes': {},
            'result': True,
            'comment':
            'Netweaver instance MESSAGESERVER present in virtualhost'
        }

        mock_is_instance_installed = MagicMock(
            return_value={'hostname': 'virtualhost'})
        with patch.dict(
                netweavermod.__salt__,
            {'netweaver.is_instance_installed': mock_is_instance_installed}):
            assert netweavermod.check_instance_present('MESSAGESERVER',
                                                       'GREEN', 'virtual',
                                                       'prd', 00,
                                                       'pass') == ret

        mock_is_instance_installed.assert_called_once_with(
            sap_instance='MESSAGESERVER',
            dispstatus='GREEN',
            virtual_host='virtual',
            sid='prd',
            inst=00,
            password='******')
コード例 #3
0
    def test_check_instance_present_test(self):
        '''
        Test check_instance_present in test mode
        '''

        ret = {
            'name': 'MESSAGESERVER',
            'changes': {},
            'result': None,
            'comment':
            'Netweaver instance MESSAGESERVER presence would be checked'
        }

        mock_is_instance_installed = MagicMock(return_value=False)
        with patch.dict(
                netweavermod.__salt__,
            {'netweaver.is_instance_installed': mock_is_instance_installed}):
            with patch.dict(netweavermod.__opts__, {'test': True}):
                assert netweavermod.check_instance_present(
                    'MESSAGESERVER', 'GREEN', 'virtual', 'prd', 00,
                    'pass') == ret