Example #1
0
class BasicPushTest(TestCase):
    def test_push(self):
        self.u = UserFactory()
        self.d = DeploymentFactory()
        self.setting = SettingFactory(deployment=self.d)
        self.recipe = RecipeFactory()
        self.shell_recipe = ShellRecipeFactory()
        self.stage = StageFactory(
            deployment=self.d,
            recipe=self.recipe)
        self.stage2 = StageFactory(
            deployment=self.d,
            recipe=self.shell_recipe,
            name="test stage 2",
        )
        push = self.d.new_push(self.u, "test push")
        # haven't run anything so it should be inprogress
        self.assertEquals(push.status, "inprogress")
        for s in self.d.stage_set.all():
            push.run_stage(s.id)
        # should have completed successfully
        self.assertEquals(push.status, "ok")
        # and let's make sure a setting variable has round-tripped
        ps = push.pushstage_set.get(stage=self.stage2)
        self.assertEquals(ps.stdout(), "TEST_BAR\n")
        self.assertEquals(ps.stderr(), "")

        self.assertEquals(self.d.most_recent_push(), push)
        self.assertEquals(self.d.status(), push.status)
        self.assertEquals(self.d.last_message(), push.comment)
        self.assertEquals(self.d.last_push_date(), push.start_time)

        self.assertEquals(push.get_absolute_url(),
                          "/push/%d/" % push.id)

        push.run_stage(self.stage.id, rollback_id=self.stage.id)

        for pstage in push.reverse_pushstages():
            self.assertEquals(pstage.setting('foo'), '')

    def test_recipe_absolute_url(self):
        self.recipe = RecipeFactory()
        self.assertEquals(
            self.recipe.get_absolute_url(),
            "/cookbook/%d/" % self.recipe.id)

    def test_stage_absolute_url(self):
        self.stage = StageFactory()
        self.assertEquals(
            self.stage.get_absolute_url(),
            "/stage/%d/" % self.stage.id)

    def test_stage_all_recipes(self):
        self.shell_recipe = ShellRecipeFactory()
        self.stage = StageFactory()
        self.stage2 = StageFactory(recipe=self.shell_recipe)

        self.assertEquals(
            [r.id for r in self.stage.all_recipes()],
            [self.shell_recipe.id])
Example #2
0
    def test_stage_all_recipes(self):
        self.shell_recipe = ShellRecipeFactory()
        self.stage = StageFactory()
        self.stage2 = StageFactory(recipe=self.shell_recipe)

        self.assertEquals(
            [r.id for r in self.stage.all_recipes()],
            [self.shell_recipe.id])
Example #3
0
    def test_push(self):
        self.u = UserFactory()
        self.d = DeploymentFactory()
        self.setting = SettingFactory(deployment=self.d)
        self.recipe = RecipeFactory()
        self.shell_recipe = ShellRecipeFactory()
        self.stage = StageFactory(
            deployment=self.d,
            recipe=self.recipe)
        self.stage2 = StageFactory(
            deployment=self.d,
            recipe=self.shell_recipe,
            name="test stage 2",
        )
        push = self.d.new_push(self.u, "test push")
        # haven't run anything so it should be inprogress
        self.assertEquals(push.status, "inprogress")
        tempdir = tempfile.mkdtemp()
        with self.settings(SCRIPT_DIR=tempdir):
            for s in self.d.stage_set.all():
                push.run_stage(s.id)
        shutil.rmtree(tempdir)
        # should have completed successfully
        self.assertEquals(push.status, "ok")
        # and let's make sure a setting variable has round-tripped
        ps = push.pushstage_set.get(stage=self.stage2)
        self.assertEquals(ps.stdout(), "TEST_BAR\n")
        self.assertEquals(ps.stderr(), "")

        self.assertEquals(self.d.most_recent_push(), push)
        self.assertEquals(self.d.status(), push.status)
        self.assertEquals(self.d.last_message(), push.comment)
        self.assertEquals(self.d.last_push_date(), push.start_time)

        self.assertEquals(push.get_absolute_url(),
                          "/push/%d/" % push.id)

        push.run_stage(self.stage.id, rollback_id=self.stage.id)

        for pstage in push.reverse_pushstages():
            self.assertEquals(pstage.setting('foo'), '')
Example #4
0
 def test_stage_absolute_url(self):
     self.stage = StageFactory()
     self.assertEquals(
         self.stage.get_absolute_url(),
         "/stage/%d/" % self.stage.id)