Esempio n. 1
0
    def test_continue_on_failure(self):
        step1 = registry.get_info_for('Step 1').impl
        step2 = registry.get_info_for('Step 2').impl

        self.assertEqual(
            registry.is_continue_on_failure(step1, RuntimeError()), False)
        self.assertEqual(
            registry.is_continue_on_failure(step2, RuntimeError()), True)
Esempio n. 2
0
def _execute_step(request, response, _socket):
    params = []
    for p in request.executeStepRequest.parameters:
        params.append(Table(p.table) if p.parameterType in [Parameter.Table, Parameter.Special_Table] else p.value)
    set_response_values(request, response)
    impl = registry.get_info_for(request.executeStepRequest.parsedStepText).impl
    execute_method(params, impl, response, registry.is_continue_on_failure)
Esempio n. 3
0
def _execute_step(request, response, socket):
    params = []
    for param in request.executeStepRequest.parameters:
        params.append(Table(param.table)) if param.parameterType in [Parameter.Table, Parameter.Special_Table] else params.append(param.value)
    set_response_values(request, response)
    impl = registry.get_info_for(request.executeStepRequest.parsedStepText).impl
    execute_method(params, impl, response, registry.is_continue_on_failure)
Esempio n. 4
0
def _send_step_name(request, response, socket):
    response.messageType = Message.StepNameResponse
    info = registry.get_info_for(request.stepNameRequest.stepValue)
    response.stepNameResponse.isStepPresent = False
    if info.step_text is not None:
        response.stepNameResponse.isStepPresent = True
        response.stepNameResponse.stepName.append(info.step_text)
    response.stepNameResponse.hasAlias = info.has_alias
Esempio n. 5
0
def process_execute_step_request(request):
    params = []
    for p in request.parameters:
        params.append(
            Table(p.table) if p.parameterType in
            [Parameter.Table, Parameter.Special_Table] else p.value)
    response = create_execution_status_response()
    info = registry.get_info_for(request.parsedStepText)
    execute_method(params, info, response, registry.is_continue_on_failure)
    return response
    def test_loader_populates_registry_for_with_aliases(self):
        content = """
        @step(["print hello", "say hello"])
        def print():
            print("hello")

        """
        load_steps(content, "foo.py")

        self.assertTrue(registry.is_implemented("say hello"))
        self.assertTrue(registry.get_info_for("say hello").has_alias)
Esempio n. 7
0
    def test_loader_populates_registry_for_with_aliases(self):
        content = dedent("""
        @step(["print hello", "say hello"])
        def printf():
            print("hello")

        """)

        load_steps(PythonFile.parse("foo.py", content))

        self.assertTrue(registry.is_implemented("say hello"))
        self.assertTrue(registry.get_info_for("say hello").has_alias)
Esempio n. 8
0
def process_step_name_request(request):
    response = StepNameResponse()
    info = registry.get_info_for(request.stepValue)
    response.isStepPresent = False
    if info.step_text is not None:
        response.isStepPresent = True
        if info.has_alias:
            for alias in info.aliases:
                response.stepName.append(alias)
        else:
            response.stepName.append(info.step_text)
        response.fileName = info.file_name
        response.span.start = info.span['start']
        response.span.startChar = info.span['startChar']
        response.span.end = info.span['end']
        response.span.endChar = info.span['endChar']
    response.hasAlias = info.has_alias
    return response
Esempio n. 9
0
def refactor_step(request, response):
    if registry.has_multiple_impls(request.oldStepValue.stepValue):
        step = request.oldStepValue.parameterizedStepValue
        raise Exception('Multiple Implementation found for `{}`'.format(step))
    info = registry.get_info_for(request.oldStepValue.stepValue)
    impl_file = open(info.file_name, 'r+')
    content = _refactor_content(impl_file.read(), info, request)
    if request.saveChanges:
        impl_file.seek(0)
        impl_file.truncate()
        impl_file.write(content)
    impl_file.close()
    response.refactorResponse.fileChanges.add(**{
        'fileName': info.file_name,
        'fileContent': content
    })
    response.refactorResponse.success = True
    response.refactorResponse.filesChanged.append(info.file_name)
Esempio n. 10
0
def refactor_step(request, response, with_location=True):
    if registry.has_multiple_impls(request.oldStepValue.stepValue):
        raise Exception('Multiple Implementation found for `{}`'.format(
            request.oldStepValue.parameterizedStepValue))
    info = registry.get_info_for(request.oldStepValue.stepValue)
    impl_file = PythonFile.parse(info.file_name)
    diffs = impl_file.refactor_step(
        info.step_text,
        request.newStepValue.parameterizedStepValue,
        _new_parameter_positions(request),
    )
    content = impl_file.get_code()
    if request.saveChanges:
        with open(info.file_name, 'w') as f:
            f.write(content)
    response.refactorResponse.success = True
    response.refactorResponse.filesChanged.append(info.file_name)
    response.refactorResponse.fileChanges.add(
        fileName=info.file_name,
        fileContent=content,  # FIXME: Remove deprecated field
        diffs=[TextDiff(span=Span(**d[0]), content=d[1]) for d in diffs],
    )
Esempio n. 11
0
 def GetStepName(self, request, context):
     res = Message()
     info = registry.get_info_for(request.stepValue)
     processor.step_name_response(info, res)
     return res.stepNameResponse
Esempio n. 12
0
def _send_step_name(request, response, _socket):
    response.messageType = Message.StepNameResponse
    info = registry.get_info_for(request.stepNameRequest.stepValue)
    step_name_response(info, response)
Esempio n. 13
0
    def test_continue_on_failure(self):
        step1 = registry.get_info_for('Step 1').impl
        step2 = registry.get_info_for('Step 2').impl

        self.assertEqual(registry.is_continue_on_failure(step1, RuntimeError()), False)
        self.assertEqual(registry.is_continue_on_failure(step2, RuntimeError()), True)