def mock_robotdocsconf(request):
    filename = os.path.join('folder1', 'robotdocsconf.py')
    mfile = MockFile(filename=filename,
                     content="robotdocs={\n"
                     "    'library':\n"
                     "        {'args': ['arg'], 'docformat': 'docformat'}}")
    create_patch(mfile, request)
    return mfile
def mock_sphinxdocsconf(request):
    filename = os.path.join('sphinxdocs', 'conf.py')
    template = "html_static_path = ['_static']\n" \
               "html_extra_path = ['{path}']\n"
    content = template.format(path=os.path.join(os.pardir, 'robotdocs'))
    mfile = MockFile(filename=filename, content=content)
    create_patch(mfile, request)
    return mfile
def mock_robotdocsconf_with_modulename(request):
    filename = os.path.join('folder3', 'robotdocsconf.py')
    mfile = MockFile(filename=filename,
                     content="module_name=\"module libraries\"\n\n"
                     "robotdocs={\n"
                     "    'library':\n"
                     "        {'args': ['arg1', 'arg2'],"
                     " 'docformat': 'docformat'}}")
    create_patch(mfile, request)
    return mfile
Пример #4
0
def mock_requirements_log_file_raises_tmpdir(request, tmpdir):
    with tmpdir.as_cwd():

        mfile = MockFile(filename=Runner().requirements_log_file,
                         content="reguirements install log")

        def exception(*args, **kwargs):
            raise Exception('message')

        mfile.set_side_effect(exception)
        create_patch(mfile, request)
        return tmpdir
Пример #5
0
def mock_detect_bash_prompt(request):
    def detect_bash_prompt_works():
        pass
    return create_patch(mock.patch.object(BashShell, '_detect_bash_prompt',
                                          side_effect=detect_bash_prompt_works,
                                          return_value='Hello'),
                        request)
Пример #6
0
def mock_tempfile_mkdtemp(request, mock_gettempdir):
    def mock_mkdtemp(suffix='', prefix='tmp', dir=None):
        return os.path.join(
            dir or tempfile.gettempdir(),
            '{prefix}random{suffix}'.format(prefix=prefix, suffix=suffix))

    return create_patch(mock.patch('tempfile.mkdtemp', mock_mkdtemp), request)
Пример #7
0
def mock_check_start_success(request):
    def check_start_success_pass(*_, **kwargs):  # pylint: disable=unused-argument
        pass

    return create_patch(mock.patch.object(
        BashShell, 'check_start_success',
        side_effect=check_start_success_pass), request)
Пример #8
0
def mock_send_input_line_bash(request):
    def send_input_line_works(*_, **kwargs):  # pylint: disable=unused-argument
        pass
    return create_patch(mock.patch.object(BashShell,
                                          '_send_input_line',
                                          side_effect=send_input_line_works,),
                        request)
Пример #9
0
def mock_virtualenvrunner(request):
    m = mock.MagicMock(spec_set=Runner)
    m.__enter__.return_value = mock.Mock(spec_set=Runner)
    mpatch = mock.patch(
        'crl.devutils._tmpindex.virtualenvrunner.runner.Runner',
        return_value=m)
    return MockVirtualenvrunner(init=create_patch(mpatch, request),
                                handle=m.__enter__.return_value)
Пример #10
0
def mock_read_until_prompt_not_found(request):
    return create_patch(mock.patch.object(KeyAuthenticatedSshShell,
                                          '_read_until',
                                          side_effect=ShellStartError(
                                              "Shell start to ipaddress "
                                              "did not succeed. "
                                              "Prompt not found.")),
                        request)
Пример #11
0
def mock_read_until_end_multiple_return_values(request):
    buffer = 'USAGE OF THE ROOT ACCOUNT AND THE FULL BASH IS RECOMMENDED ONLY ' \
             'FOR LIMITED USE. ' \
             'PLEASE USE A NON-ROOT ACCOUNT OR LIMITED BASH SHELL.'
    return create_patch(mock.patch.object(BashShell,
                                          '_read_until_end',
                                          side_effect=['\r\n', buffer]),
                        request)
Пример #12
0
def mock_read_until_prompt_found(request):
    buffer = 'Warning: Permanently added ipaddr (RSA) to the list ' \
             'known hosts.USAGE OF THE ROOT ACCOUNT AND THE FULL BASH IS ' \
             'RECOMMENDED ONLY FOR LIMITED USE.PLEASE USE A NON-ROOT ACCOUNT' \
             ' AND THE SCLISHELL(fsclish) AND / OR LIMITED BASH SHELL.'
    return create_patch(mock.patch.object(KeyAuthenticatedSshShell,
                                          '_read_until',
                                          return_value=buffer),
                        request)
Пример #13
0
def mock_paramiko_channel(request):
    c = create_patch(
        mock.patch('crl.remotescript.ssh.paramiko.SSHClient', spec_set=True),
        request)

    chan = c.return_value.get_transport.return_value.open_session.return_value
    chan.recv_ready.return_value = False
    chan.recv_stderr_ready.return_value = False
    return chan
def mock_autorunnerterminal(request):
    return create_patch(
        mock.patch('crl.interactivesessions._terminalpools'
                   '.AutoRunnerTerminal'), request)
Пример #15
0
def mock_time_sleep(request):
    return create_patch(mock.patch('time.sleep', spec_set=True), request)
Пример #16
0
def mpatch_versionhandler(request, mock_versionhandler):
    return create_patch(mock.patch(
        'crl.devutils.tasks.versionhandler.VersionHandler',
        return_value=mock_versionhandler), request)
Пример #17
0
def mpatch_setuphandler(request, mock_setuphandler):
    return create_patch(mock.patch(
        'crl.devutils.tasks.setuphandler.SetupHandler',
        return_value=mock_setuphandler), request)
Пример #18
0
def mock_module2rst(request):
    mfile = MockFile(filename=os.path.join('sphinxdocs', 'module2.rst'))
    create_patch(mfile, request)
    return mfile
Пример #19
0
def mpatch_packagehandler(request, mock_packagehandler):
    return create_patch(mock.patch(
        'crl.devutils.tasks.packagehandler.PackageHandler',
        return_value=mock_packagehandler), request)
Пример #20
0
def mock_paramiko(request):
    return create_patch(mock.patch(
        'crl.interactivesessions.shells.sshshell.paramiko'), request)
Пример #21
0
def mock_os_path_isdir_no_sphinxdocs(request):
    mock_is_dir = MockIsdir(path='sphinxdocs', ispath=False)
    create_patch(mock.patch('os.path.isdir', side_effect=mock_is_dir.isdir),
                 request)
    return mock_is_dir
def mock_get_response_or_raise(request):
    return create_patch(
        mock.patch.object(AutoRunnerTerminal, 'get_response_or_raise'),
        request)
Пример #23
0
def mpatch_devpihandler(request, mock_devpihandler):
    return create_patch(mock.patch(
        'crl.devutils.tasks.devpihandler.DevpiHandler',
        return_value=mock_devpihandler), request)
Пример #24
0
def mpatch_githandler(request, mock_githandler):
    return create_patch(mock.patch(
        'crl.devutils.tasks.githandler.GitHandler',
        return_value=mock_githandler), request)
Пример #25
0
def mock_create_packagehandler(request, mock_packagehandler):
    return MockHandlerFactory(create_patch(mock.patch(
        'crl.devutils.tasks.create_packagehandler',
        return_value=mock_packagehandler), request), mock_packagehandler)
Пример #26
0
def mock_create_doccreator(request, mock_doccreator):
    return MockHandlerFactory(create_patch(mock.patch(
        'crl.devutils.tasks.create_doccreator',
        return_value=mock_doccreator), request), handler=mock_doccreator)
Пример #27
0
def mpatch_doccreator(request, mock_doccreator):
    return create_patch(mock.patch(
        'crl.devutils.tasks.doccreator.DocCreator',
        return_value=mock_doccreator), request)
Пример #28
0
def mock_robotdocsrst(request):
    mfile = MockFile(filename=os.path.join('sphinxdocs', 'robotdocs.rst'))
    create_patch(mfile, request)
    return mfile
Пример #29
0
def mock_read_until_end_status_nok(request):
    return create_patch(mock.patch.object(KeyAuthenticatedSshShell,
                                          '_read_until_end',
                                          return_value='@255@'),
                        request)
Пример #30
0
def mpatch_run(request):
    return create_patch(mock.patch(
        'crl.devutils.tasks.run', return_value='return_value'), request)