Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_RunnerServiceHandler_refactor(self):
handler = RunnerServiceHandler(None)
content = dedent('''\
from getgauge.python import step
@step('Vowels in English language are .')
def foo(vowels):
print(vowels)
''')
self.fs.create_file(os.path.join(
get_step_impl_dirs()[0], 'foo.py'), contents=content)
loader.load_files(get_step_impl_dirs())
request = RefactorRequest()
request.saveChanges = False
request.oldStepValue.stepValue = 'Vowels in English language are {}.'
request.oldStepValue.parameters.append('vowels')
request.newStepValue.parameterizedStepValue = 'Vowels in English language is .'
request.newStepValue.stepValue = 'Vowels in English language is {} {}.'
request.newStepValue.parameters.extend(['vowels', 'bsdfdsf'])
position = ParameterPosition()
position.oldPosition = 0
position.newPosition = 0
param_position = ParameterPosition()
param_position.oldPosition = -1
param_position.newPosition = 1
request.paramPositions.extend([position, param_position])
def test_RunnerServiceHandler_refactor(self):
handler = RunnerServiceHandler(None)
content = dedent('''\
from getgauge.python import step
@step('Vowels in English language are .')
def foo(vowels):
print(vowels)
''')
self.fs.create_file(os.path.join(
get_step_impl_dirs()[0], 'foo.py'), contents=content)
loader.load_files(get_step_impl_dirs())
request = RefactorRequest()
request.saveChanges = False
request.oldStepValue.stepValue = 'Vowels in English language are {}.'
request.oldStepValue.parameters.append('vowels')
request.newStepValue.parameterizedStepValue = 'Vowels in English language is .'
request.newStepValue.stepValue = 'Vowels in English language is {} {}.'
request.newStepValue.parameters.extend(['vowels', 'bsdfdsf'])
position = ParameterPosition()
position.oldPosition = 0
position.newPosition = 0
param_position = ParameterPosition()
param_position.oldPosition = -1
param_position.newPosition = 1
request.paramPositions.extend([position, param_position])
def test_Processor_process_refactor_request(self):
content = dedent('''\
from getgauge.python import step
@step('Vowels in English language are .')
def foo(vowels):
print(vowels)
''')
self.fs.create_file(os.path.join(
get_step_impl_dirs()[0], 'foo.py'), contents=content)
loader.load_files(get_step_impl_dirs())
request = RefactorRequest()
request.saveChanges = False
request.oldStepValue.stepValue = 'Vowels in English language are {}.'
request.oldStepValue.parameters.append('vowels')
request.newStepValue.parameterizedStepValue = 'Vowels in English language is .'
request.newStepValue.stepValue = 'Vowels in English language is {} {}.'
request.newStepValue.parameters.extend(['vowels', 'bsdfdsf'])
position = ParameterPosition()
position.oldPosition = 0
position.newPosition = 0
param_position = ParameterPosition()
param_position.oldPosition = -1
param_position.newPosition = 1
request.paramPositions.extend([position, param_position])
def test_get_step_impl_returns_normalized_impl_dirs_path(self):
os.environ["STEP_IMPL_DIR"] = "test\\step_impl" if os.path.sep == '/' else "test/step_impl"
dirs = get_step_impl_dirs()
expected = ["test" + os.path.sep +"step_impl"]
self.assertEqual(dirs,expected)
def test_LspServerHandler_file_list(self):
handler = LspServerHandler(None)
req = ImplementationFileListRequest()
self.fs.create_file(os.path.join(get_step_impl_dirs()[0], 'foo.py'))
res = handler.GetImplementationFiles(req, None)
self.assertEqual(os.path.basename(
res.implementationFilePaths[0]), 'foo.py')
def test_get_step_impl_returns_array_of_impl_dirs(self):
os.environ["STEP_IMPL_DIR"] = "step_impl, step_impl1"
dirs = get_step_impl_dirs()
expected = ['step_impl','step_impl1']
self.assertEqual(dirs,expected)
def test_get_step_impl_gives_default_if_no_env_Set(self):
dirs = get_step_impl_dirs()
expected = ['step_impl']
self.assertEqual(dirs,expected)
def load_implementations():
d = get_step_impl_dirs()
logger.debug(
"Loading step implementations from {} dirs.".format(', '.join(d)))
for impl_dir in d:
if not path.exists(impl_dir):
logger.error('can not load implementations from {}. {} does not exist.'.format(
impl_dir, impl_dir))
load_files(d)
def GetGlobPatterns(self, request, context):
res = ImplementationFileGlobPatternResponse()
globPatterns = [["{}/**/*.py".format(d)] for d in get_step_impl_dirs()]
res.globPatterns.extend([item for sublist in globPatterns for item in sublist])
return res