Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
RefactorTests.path = os.path.join(tempfile.gettempdir(), 'step_impl.py')
RefactorTests.file = open(RefactorTests.path, 'w')
RefactorTests.file.write("""@step("Vowels in English language are .")
def assert_default_vowels(arg0):
Messages.write_message("Given vowels are {0}".format(given_vowels))
assert given_vowels == "".join(vowels)\n""")
RefactorTests.file.close()
RefactorTests.file = open(RefactorTests.path, 'r')
RefactorTests.data = RefactorTests.file.read()
RefactorTests.file.close()
registry.add_step('Vowels in English language are .', None,
RefactorTests.path)
def test_Processor_execute_step_request_with_param(self):
registry.add_step('Step <a> with <b>', impl, '')
registry.add_step('Step 4', 'func1', '')
request = ExecuteStepRequest()
request.parsedStepText = 'Step {} with {}'
parameter = Parameter()
parameter.value = 'param 1'
parameter1 = Parameter()
parameter1.value = 'param 2'
request.parameters.extend([parameter, parameter1])
response = processor.process_execute_step_request(request)
self.assertTrue(isinstance(response, ExecutionStatusResponse))
self.assertEqual(
False, response.executionResult.failed)
self.assertEqual(
'', response.executionResult.errorMessage)</b></a>
def test_Processor_step_name_request(self):
registry.add_step('Step <a> with <b>', 'func', '', {
'start': 1, 'startChar': 0, 'end': 3, 'endChar': 10})
registry.add_step('Step 4', 'func1', '', {
'start': 5, 'startChar': 0, 'end': 6, 'endChar': 10})
request = StepNameRequest()
request.stepValue = 'Step {} with {}'
response = processor.process_step_name_request(request)
self.assertTrue(isinstance(response, StepNameResponse))
self.assertEqual(['Step </b></a><b><a> with <b>'], response.stepName)
self.assertEqual(True, response.isStepPresent)
request = StepNameRequest()
self.assertEqual(False, response.hasAlias)
request.stepValue = 'Step 4'
response = processor.process_step_name_request(request)
self.assertTrue(isinstance(response, StepNameResponse))
self.assertEqual(['Step 4'], response.stepName)</b></a></b>
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)
</b></a>
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)
</b></a>
def test_Processor_failed_execute_step_request_with_continue_on_failure(self):
registry.add_step('Step 4', failing_impl, '')
registry.continue_on_failure(failing_impl, [IndexError])
request = ExecuteStepRequest()
request.parsedStepText = 'Step 4'
response = processor.process_execute_step_request(request)
self.assertTrue(isinstance(response, ExecutionStatusResponse))
self.assertEqual(
True, response.executionResult.failed)
self.assertEqual(ProtoExecutionResult.ASSERTION,
response.executionResult.errorType)
self.assertNotEqual('', response.executionResult.errorMessage)
self.assertNotEqual('', response.executionResult.stackTrace)
self.assertEqual(True, response.executionResult.recoverableError)
def load_steps(python_file):
for funcStep in python_file.iter_steps():
registry.add_step(funcStep[0], funcStep[1],
python_file.file_path, funcStep[2])