Exemple #1
0
    def test_Processor_valid_step_validate_request(self):
        registry.add_step('Step <a> with <b>', 'func', '')
        registry.add_step('Step 4', 'func1', '')

        request = StepValidateRequest()
        request.stepText = 'Step {} with {}'
        response = processor.process_validate_step_request(request)

        self.assertTrue(isinstance(response, StepValidateResponse))
        self.assertTrue(response.isValid)
Exemple #2
0
    def test_Processor_process_validate_step_request(self):
        self.load_content_steps('''\
        @step('foo')
        def foo():
            pass
        ''')
        step_value = ProtoStepValue(stepValue='foo',
                                    parameterizedStepValue='foo')

        req = StepValidateRequest(stepText='foo',
                                  stepValue=step_value,
                                  numberOfParameters=0)
        res = processor.process_validate_step_request(req)
        self.assertTrue(res.isValid)
Exemple #3
0
    def test_Processor_invalid_step_validate_request_when_duplicate_impl_found(
            self):
        registry.add_step('Step <a> with <b>', impl, '', {'start': 0})
        registry.add_step('Step <a> with <b>', impl, '', {'start': 2})

        response = Message()

        request = StepValidateRequest()
        request.stepText = 'Step {} with {}'

        response = processor.process_validate_step_request(request)

        self.assertTrue(isinstance(response, StepValidateResponse))
        self.assertFalse(response.isValid)
        self.assertEqual(StepValidateResponse.DUPLICATE_STEP_IMPLEMENTATION,
                         response.errorType)
Exemple #4
0
    def test_Processor_invalid_step_validate_request_when_no_impl_found(self):
        registry.add_step('Step <a> with <b>', 'func', '')
        registry.add_step('Step 4', 'func1', '')

        request = StepValidateRequest()
        request.stepText = 'Step2'
        request.stepValue.stepValue = 'Step2'

        response = processor.process_validate_step_request(request)

        self.assertTrue(isinstance(response, StepValidateResponse))
        self.assertFalse(response.isValid)
        self.assertEqual(StepValidateResponse.STEP_IMPLEMENTATION_NOT_FOUND,
                         response.errorType)
        self.assertTrue(
            '@step("")\ndef step2():\n    assert False, "Add implementation code"'
            in response.suggestion)
Exemple #5
0
 def ValidateStep(self, request, context):
     return processor.process_validate_step_request(request)