Esempio n. 1
0
def main(stages, path, copy_method, 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 copy_method == 'git' and gitext.has_git_repro(path):
        repro_url = gitext.get_git_remote(path)
        repro_url = click.prompt("git repository", default=repro_url)

        config["git"] = True
        params["repro_url"] = repro_url

    config["copy_method"] = copy_method

    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()
Esempio n. 2
0
    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)
Esempio n. 3
0
    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)
Esempio n. 4
0
    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"))
Esempio n. 5
0
    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)
Esempio n. 6
0
    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)
Esempio n. 7
0
    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:  # NOQA
            gen.create_index()

        contents = read_file("./tmp/stages/__init__.py")
        self.assertTrue("from demo import demo" in contents)
Esempio n. 8
0
    def test_invalid_stagename(self):
        stages = [{"NAME": "demo!"}]

        with self.assertRaises(Exception) as cm:  # NOQA
            generator.Generator(stages=stages, path="./tmp")