def step_then_5(context): """Step implementation for: Then destination directory is created """ dest = context.dest with bhv.testdir(context): if not os.path.isdir(dest): raise Exception("directory " + dest + " was not found")
def step_then_5(context): """Step implementation for: Then destination directory is created """ dest = context.dest with bhv.testdir(context): if not os.path.isdir(dest): raise Exception("directory "+dest+" was not found")
def step_given_5(context, destination_directory): """Step implementation for: And the {destination_directory} does not exist """ context.dest = destination_directory with bhv.testdir(context): if os.path.isdir(destination_directory): raise Exception("directory "+destination_directory+ " must NOT be present for this test to start")
def step_given_5(context, destination_directory): """Step implementation for: And the {destination_directory} does not exist """ context.dest = destination_directory with bhv.testdir(context): if os.path.isdir(destination_directory): raise Exception("directory " + destination_directory + " must NOT be present for this test to start")
def step_then_3(context): """Step implementation for: And the step file is saved into default destination directory """ with bhv.testdir(context): ffile = os.path.join("ghen", context.step_file) if not os.path.isfile(ffile): raise Exception("Step file: "+ffile+" not found") bhv.cleanup_temp_dir(context)
def step_then_3(context): """Step implementation for: And the step file is saved into default destination directory """ with bhv.testdir(context): ffile = os.path.join("ghen", context.step_file) if not os.path.isfile(ffile): raise Exception("Step file: " + ffile + " not found") bhv.cleanup_temp_dir(context)
def step_then_4(context): """Step implementation for: And step file is saved into the destination directory """ step_file = context.step_file with bhv.testdir(context): if not os.path.isfile(step_file): raise Exception("step file not found") bhv.cleanup_temp_dir(context)
def step_when_4(context, ghenerate_command): """Step implementation for: When I run {ghenerate_command} with the option specifying destination directory """ context.step_file = os.path.join(context.dest, "test.py") with bhv.testdir(context): ghencom = ghenerate_command+" "+"test.feature" err_msg = "Command "+ghenerate_command+" failed" bhv.shell_command(context, ghencom, err_msg=err_msg)
def step_when_2(context): """Step implementation for: When I run the ghenerate script with the name of the feature file """ context.feature_file = "test.feature" context.step_file = "test.py" with bhv.testdir(context): bhv.shell_command(context, "ghenerate "+context.feature_file, err_msg="Command ghenerate "+context.feature_file+ " failed")
def step_given_2(context): """Step implementation for: And current directory contains a feature file """ bhv.secure_temp_dir(context) with bhv.testdir(context): ffile = "test.feature" bhv.fetch_test_feature_file(context, ffile) if not os.path.isfile(ffile): raise Exception("Feature file: " + ffile + " not found")
def step_when_4(context, ghenerate_command): """Step implementation for: When I run {ghenerate_command} with the option specifying destination directory """ context.step_file = os.path.join(context.dest, "test.py") with bhv.testdir(context): ghencom = ghenerate_command + " " + "test.feature" err_msg = "Command " + ghenerate_command + " failed" bhv.shell_command(context, ghencom, err_msg=err_msg)
def step_given_2(context): """Step implementation for: And current directory contains a feature file """ bhv.secure_temp_dir(context) with bhv.testdir(context): ffile = "test.feature" bhv.fetch_test_feature_file(context, ffile) if not os.path.isfile(ffile): raise Exception("Feature file: "+ffile+" not found")
def step_when_2(context): """Step implementation for: When I run the ghenerate script with the name of the feature file """ context.feature_file = "test.feature" context.step_file = "test.py" with bhv.testdir(context): bhv.shell_command(context, "ghenerate " + context.feature_file, err_msg="Command ghenerate " + context.feature_file + " failed")
def step_given_3(context): """Step implementation for: And the default destination directory exists """ from pathlib import Path with bhv.testdir(context): path = os.path.join(context.tempdir.name, "ghen") my_file = Path(path) if not my_file.exists(): my_file.mkdir() if not my_file.is_dir(): raise Exception("Defailt destination directory does not exist.")
def step_given_4(context, destination_directory): """Step implementation for: And {destination_directory} exists """ from pathlib import Path with bhv.testdir(context): my_file = Path(destination_directory) my_file.mkdir() context.dest = destination_directory if not my_file.is_dir(): raise Exception("Destination directory " + destination_directory + " does not exist")
def step_given_4(context, destination_directory): """Step implementation for: And {destination_directory} exists """ from pathlib import Path with bhv.testdir(context): my_file = Path(destination_directory) my_file.mkdir() context.dest = destination_directory if not my_file.is_dir(): raise Exception("Destination directory "+destination_directory+ " does not exist")
def step_when_2(context): """ When I fetch all examples one by one """ failures = [] with bhv.testdir(context): for file in context.files: bhv.shell_command(context, "qrhei fetch --examples "+file) print(context.output.decode("utf-8")) if not os.path.isfile(file): failures.append("File: "+file+" was not fetched") context.failures = failures
def step_given_1(context): """ Given that I have a list of examples from qrhei list """ bhv.secure_temp_dir(context) with bhv.testdir(context): bhv.shell_command(context, "qrhei list --examples") text = context.output.decode("utf-8") items = text.split() files_to_fetch = [] for item in items: if item.startswith("ex_"): files_to_fetch.append(item) context.files = files_to_fetch