def main(stages, path, recipe): stage_list = stages.split(u",") stage_list = map(unicode.strip, stage_list) stage_list = filter(None, stage_list) formatted_stages = [] config = {} params = {} for stage in stage_list: formatted_stages.append({"NAME": stage, "LOCAL": stage == "local"}) if utils.has_git_repro(path): repro_url = utils.get_git_remote(path) repro_url = click.prompt("git repository", default=repro_url) config["git"] = True params["repro_url"] = repro_url if recipe: for stage in formatted_stages: stage["RECIPE"] = recipe gen = generator.Generator(stages=formatted_stages, path=path, config=config, params=params) gen.create_index() gen.create_stages()
def test_ssh_stage_info(self): stages = [{"NAME": "stage", "FORWARD_AGENT": "True"}] gen = generator.Generator(stages=stages, path="./tmp") gen.create_stages() contents = read_file("./tmp/stages/stage.py") self.assertTrue("env.forward_agent = True" in contents)
def test_local_stage_generation(self): stages = [{"NAME": "local", "LOCAL": True}] gen = generator.Generator(stages=stages, path="./tmp") gen.create_stages() self.assertTrue(os.path.exists("./tmp/stages/local.py")) contents = read_file("./tmp/stages/local.py") self.assertTrue("env.run = elocal" in contents)
def test_stages_generation(self): stages = [{ "NAME": "demo", }, { "NAME": "stage" }] gen = generator.Generator(stages=stages, path="./tmp") gen.create_stages() self.assertTrue(os.path.exists("./tmp/stages/demo.py")) self.assertTrue(os.path.exists("./tmp/stages/stage.py"))
def test_stage_generation(self): stages = [{ "NAME": "demo", }, { "NAME": "stage" }] gen = generator.Generator(stages=stages, path="./tmp") gen.create_stage(name="demo") self.assertTrue(os.path.exists("./tmp/stages/demo.py")) contents = read_file("./tmp/stages/demo.py") self.assertTrue("def demo():" in contents)
def test_fabricrc_settings(self): stages = [{ "NAME": "stage", "FORWARD_AGENT": "True" }, { "NAME": "prod", "FORWARD_AGENT": "True" }] gen = generator.Generator(stages=stages, path="./tmp") gen.create_index() self.assertTrue(os.path.exists("./tmp/fabricrc.txt")) contents = read_file("./tmp/fabricrc.txt") self.assertTrue("STAGE_HOST=" in contents)
def test_index_generation(self): stages = [{ "NAME": "demo", }, { "NAME": "stage" }] gen = generator.Generator(stages=stages, path="./tmp") gen.create_index() self.assertTrue(os.path.exists("./tmp/stages")) self.assertTrue(os.path.exists("./tmp/fabfile.py")) self.assertTrue(os.path.exists("./tmp/stages/__init__.py")) with self.assertRaises(OSError) as cm: gen.create_index() contents = read_file("./tmp/stages/__init__.py") self.assertTrue("from demo import demo" in contents)
def test_invalid_stagename(self): stages = [{"NAME": "demo!"}] with self.assertRaises(Exception) as cm: generator.Generator(stages=stages, path="./tmp")