Esempio n. 1
0
def _execute_before_step_hook(request, response, _socket):
    MessagesStore.clear()
    execution_info = create_execution_context_from(
        request.stepExecutionStartingRequest.currentExecutionInfo)
    tags = list(execution_info.scenario.tags) + list(
        execution_info.specification.tags)
    run_hook(request, response, registry.before_step(tags), execution_info)
Esempio n. 2
0
    def test_create_execution_context_from(self):
        message = Message()
        spec_name = 'SPEC_NAME'
        spec_file_name = 'SPEC_FILE_NAME'
        scenario_name = 'SCENARIO_NAME'
        step_name = 'STEP_NAME'

        message.executionStartingRequest.\
            currentExecutionInfo.currentSpec.name = spec_name
        message.executionStartingRequest.\
            currentExecutionInfo.currentSpec.fileName = spec_file_name
        message.executionStartingRequest.\
            currentExecutionInfo.currentSpec.isFailed = True
        message.executionStartingRequest.\
            currentExecutionInfo.currentScenario.name = scenario_name
        message.executionStartingRequest.\
            currentExecutionInfo.currentScenario.isFailed = False
        message.executionStartingRequest.\
            currentExecutionInfo.currentStep.step.actualStepText = step_name
        message.executionStartingRequest.\
            currentExecutionInfo.currentStep.isFailed = True

        specification = Specification(spec_name, spec_file_name, True, [])
        scenario = Scenario(scenario_name, False, [])
        step = Step(step_name, True)

        context = ExecutionContext(specification, scenario, step)

        expected_execution_context = create_execution_context_from(
            message.executionStartingRequest.currentExecutionInfo)
        self.assertEqual(expected_execution_context, context)
Esempio n. 3
0
def _execute_after_step_hook(request, response, _socket):
    execution_info = create_execution_context_from(
        request.stepExecutionEndingRequest.currentExecutionInfo)
    tags = list(execution_info.scenario.tags) + list(
        execution_info.specification.tags)
    run_hook(request, response, registry.after_step(tags), execution_info)
    response.executionStatusResponse.executionResult.message.extend(
        MessagesStore.pending_messages())
Esempio n. 4
0
def process_spec_execution_starting_request(request):
    execution_info = create_execution_context_from(
        request.currentExecutionInfo)
    response = run_hook(
        request, registry.before_spec(execution_info.specification.tags),
        execution_info)
    _add_message_and_screenshots(response)
    return response
Esempio n. 5
0
def process_step_execution_ending_request(request):
    execution_info = create_execution_context_from(
        request.currentExecutionInfo)
    tags = list(execution_info.scenario.tags) + \
        list(execution_info.specification.tags)
    response = run_hook(request, registry.after_step(tags), execution_info)
    _add_message_and_screenshots(response)
    return response
Esempio n. 6
0
def _execute_after_suite_hook(request, response, _socket):
    execution_info = create_execution_context_from(
        request.executionEndingRequest.currentExecutionInfo)
    run_hook(request, response, registry.after_suite(), execution_info)
    response.executionStatusResponse.executionResult.message.extend(
        MessagesStore.pending_messages())
    response.executionStatusResponse.executionResult.screenshots.extend(
        ScreenshotsStore.pending_screenshots())
Esempio n. 7
0
def _execute_before_spec_hook(request, response, _socket):
    execution_info = create_execution_context_from(
        request.specExecutionStartingRequest.currentExecutionInfo)
    run_hook(request, response,
             registry.before_spec(execution_info.specification.tags),
             execution_info)
    response.executionStatusResponse.executionResult.message.extend(
        MessagesStore.pending_messages())
Esempio n. 8
0
def process_execution_starting_request(request, clear=True):
    if clear:
        registry.clear()
        load_impls(get_step_impl_dirs())
    execution_info = create_execution_context_from(
        request.currentExecutionInfo)
    response = run_hook(request, registry.before_suite(), execution_info)
    _add_message_and_screenshots(response)
    return response
Esempio n. 9
0
def _execute_before_scenario_hook(request, response, _socket):
    execution_info = create_execution_context_from(
        request.scenarioExecutionStartingRequest.currentExecutionInfo)
    tags = list(execution_info.scenario.tags) + \
        list(execution_info.specification.tags)
    run_hook(request, response, registry.before_scenario(tags), execution_info)
    response.executionStatusResponse.executionResult.message.extend(
        MessagesStore.pending_messages())
    response.executionStatusResponse.executionResult.screenshots.extend(
        ScreenshotsStore.pending_screenshots())
Esempio n. 10
0
def _execute_before_suite_hook(request, response, _socket, clear=True):
    if clear:
        registry.clear()
        load_impls(get_step_impl_dir())
    if environ.get('DEBUGGING'):
        ptvsd.enable_attach('',
                            address=('0.0.0.0',
                                     int(environ.get('DEBUG_PORT'))))
        logging.info(ATTACH_DEBUGGER_EVENT)
        ptvsd.wait_for_attach()

    execution_info = create_execution_context_from(
        request.executionStartingRequest.currentExecutionInfo)
    run_hook(request, response, registry.before_suite(), execution_info)
Esempio n. 11
0
def _execute_before_suite_hook(request, response, _socket, clear=True):
    if clear:
        registry.clear()
        load_impls(get_step_impl_dir())
    if environ.get('DEBUGGING'):
        ptvsd.enable_attach('', address=('127.0.0.1', int(environ.get('DEBUG_PORT'))))
        logging.info(ATTACH_DEBUGGER_EVENT)
        t = Timer(int(environ.get("debugger_wait_time", 30)), handle_detached)
        t.start()
        ptvsd.wait_for_attach()
        t.cancel()

    execution_info = create_execution_context_from(request.executionStartingRequest.currentExecutionInfo)
    run_hook(request, response, registry.before_suite(), execution_info)
    response.executionStatusResponse.executionResult.message.extend(MessagesStore.pending_messages())
Esempio n. 12
0
def _execute_before_suite_hook(request, response, _socket, clear=True):
    if clear:
        registry.clear()
        load_impls(get_step_impl_dir())
    if environ.get('DEBUGGING'):
        ptvsd.enable_attach('',
                            address=('127.0.0.1',
                                     int(environ.get('DEBUG_PORT'))))
        logging.info(ATTACH_DEBUGGER_EVENT)
        signal.signal(signal.SIGALRM, handle_detached)
        signal.alarm(int(environ.get("debugger_wait_time", 30)))
        ptvsd.wait_for_attach()

    execution_info = create_execution_context_from(
        request.executionStartingRequest.currentExecutionInfo)
    run_hook(request, response, registry.before_suite(), execution_info)
Esempio n. 13
0
    def test_create_execution_context_from(self):
        message = Message()
        spec_name, spec_file_name, scenario_name, step_name = 'SPEC_NAME', 'SPEC_FILE_NAME', 'SCENARIO_NAME', 'STEP_NAME'
        message.executionStartingRequest.currentExecutionInfo.currentSpec.name = spec_name
        message.executionStartingRequest.currentExecutionInfo.currentSpec.fileName = spec_file_name
        message.executionStartingRequest.currentExecutionInfo.currentSpec.isFailed = True
        message.executionStartingRequest.currentExecutionInfo.currentScenario.name = scenario_name
        message.executionStartingRequest.currentExecutionInfo.currentScenario.isFailed = False
        message.executionStartingRequest.currentExecutionInfo.currentStep.step.actualStepText = step_name
        message.executionStartingRequest.currentExecutionInfo.currentStep.isFailed = True

        specification = Specification(spec_name, spec_file_name, True, [])
        scenario = Scenario(scenario_name, False, [])
        step = Step(step_name, True)

        context = ExecutionContext(specification, scenario, step)

        expected_execution_context = create_execution_context_from(
            message.executionStartingRequest.currentExecutionInfo)
        self.assertEqual(expected_execution_context, context)
Esempio n. 14
0
def _execute_after_spec_hook(request, response, socket):
    execution_info = create_execution_context_from(request.specExecutionEndingRequest.currentExecutionInfo)
    run_hook(request, response, registry.after_spec(execution_info.specification.tags), execution_info)
Esempio n. 15
0
def process_execution_ending_request(request):
    execution_info = create_execution_context_from(
        request.currentExecutionInfo)
    response = run_hook(request, registry.after_suite(), execution_info)
    _add_message_and_screenshots(response)
    return response
Esempio n. 16
0
def _execute_after_scenario_hook(request, response, _socket):
    execution_info = create_execution_context_from(
        request.scenarioExecutionEndingRequest.currentExecutionInfo)
    tags = list(execution_info.scenario.tags) + list(
        execution_info.specification.tags)
    run_hook(request, response, registry.after_scenario(tags), execution_info)
Esempio n. 17
0
def _execute_before_suite_hook(request, response, socket):
    execution_info = create_execution_context_from(request.executionStartingRequest.currentExecutionInfo)
    run_hook(request, response, registry.before_suite(), execution_info)
Esempio n. 18
0
def _execute_after_step_hook(request, response, socket):
    execution_info = create_execution_context_from(request.stepExecutionEndingRequest.currentExecutionInfo)
    tags = list(execution_info.scenario.tags) + list(execution_info.specification.tags)
    run_hook(request, response, registry.after_step(tags), execution_info)
    response.executionStatusResponse.executionResult.message.extend(_MessagesStore.pending_messages())
Esempio n. 19
0
def _execute_before_step_hook(request, response, socket):
    _MessagesStore.clear()
    execution_info = create_execution_context_from(request.stepExecutionStartingRequest.currentExecutionInfo)
    tags = list(execution_info.scenario.tags) + list(execution_info.specification.tags)
    run_hook(request, response, registry.before_step(tags), execution_info)
Esempio n. 20
0
def _execute_after_suite_hook(request, response, socket):
    execution_info = create_execution_context_from(request.executionEndingRequest.currentExecutionInfo)
    run_hook(request, response, registry.after_suite(), execution_info)
Esempio n. 21
0
def _execute_after_suite_hook(request, response, _socket):
    execution_info = create_execution_context_from(
        request.executionEndingRequest.currentExecutionInfo)
    run_hook(request, response, registry.after_suite(), execution_info)
Esempio n. 22
0
def _execute_before_spec_hook(request, response, _socket):
    execution_info = create_execution_context_from(
        request.specExecutionStartingRequest.currentExecutionInfo)
    run_hook(request, response,
             registry.before_spec(execution_info.specification.tags),
             execution_info)
Esempio n. 23
0
def _execute_after_scenario_hook(request, response, socket):
    execution_info = create_execution_context_from(request.scenarioExecutionEndingRequest.currentExecutionInfo)
    tags = list(execution_info.scenario.tags) + list(execution_info.specification.tags)
    run_hook(request, response, registry.after_scenario(tags), execution_info)