Ejemplo n.º 1
0
 def to_states_list(self):
     u"""
     Converts a Lifecycle to a :class:`.LifecycleList` (a list of strings)
     """
     if self._states_list is None:
         lcs = self.lifecyclestates_set.order_by("rank")
         self._states_list = LifecycleList(
             self.name, self.official_state.name,
             *lcs.values_list("state__name", flat=True))
     return LifecycleList(self.name, self.official_state,
                          *self._states_list)
Ejemplo n.º 2
0
    def test_promote_with_unknown_repository(self):
        self.controller.repository_uri = "http://example.org/plop"
        self.controller.save()

        self.assertEqual(self.controller.state.name, "draft")
        self.controller.promote()
        self.assertEqual(self.controller.state.name, "official")

        # should not fail even is the repository is wrong
        # the svn_revision should just not change
        self.assertEqual("HEAD", self.controller.svn_revision)

        self.assertFalse(self.controller.is_editable)

        lcl = LifecycleList("diop", "official", "draft", "issue1", "official",
                            "deprecated")
        lc = models.Lifecycle.from_lifecyclelist(lcl)
        self.controller.lifecycle = lc
        self.controller.state = models.State.objects.get(name="draft")
        self.controller.save()
        self.controller.promote()
        self.assertEqual(self.controller.state.name, "issue1")
        self.assertEqual("HEAD", self.controller.svn_revision)
        self.controller.demote()
        self.assertEqual(self.controller.state.name, "draft")
        self.assertTrue(self.controller.is_editable)
Ejemplo n.º 3
0
 def test_promote(self):
     self.controller.add_file(self.get_file())
     self.assertEqual(self.controller.state.name, "draft")
     self.controller.promote()
     self.assertEqual(self.controller.state.name, "official")
     self.assertFalse(self.controller.is_editable)
     lcl = LifecycleList("diop", "official", "draft", "issue1", "official",
                         "deprecated")
     lc = models.Lifecycle.from_lifecyclelist(lcl)
     self.controller.lifecycle = lc
     self.controller.state = models.State.objects.get(name="draft")
     self.controller.save()
     self.controller.promote()
     self.assertEqual(self.controller.state.name, "issue1")
     self.controller.demote()
     self.assertEqual(self.controller.state.name, "draft")
     self.assertTrue(self.controller.is_editable)
Ejemplo n.º 4
0
    def setUp(self):
        super(PartDocControllerTestCase, self).setUp()
        self.other_owner = self.get_contributor("Otherowner")
        self.other_owner.groups.add(self.group)
        self.other_owner.save()

        lcl = LifecycleList("dpop", "official", "draft", "proposed",
                            "official", "deprecated")
        lc = models.Lifecycle.from_lifecyclelist(lcl)
        self.states = dict((s, models.State.objects.get(name=s)) for s in lcl)
        self.states["cancelled"] = models.get_cancelled_state()
        self.lifecycles = dict.fromkeys(lcl, lc)
        self.lifecycles["cancelled"] = models.get_cancelled_lifecycle()
        data = self.DATA.copy()
        data["lifecycle"] = lc
        self.part = PartController.create("p1", "Part", "a", self.user, data,
                                          True, True)
        self.doc = DocumentController.create("d1", "Document", "a", self.user,
                                             data, True, True)
Ejemplo n.º 5
0
    def test_promote(self):
        self.assertEqual(self.controller.state.name, "draft")
        self.controller.promote()
        self.assertEqual(self.controller.state.name, "official")
        # check that the revision has been updated
        self.assertTrue(int(self.controller.svn_revision) > 600)
        self.assertFalse(self.controller.is_editable)

        lcl = LifecycleList("diop", "official", "draft", "issue1", "official",
                            "deprecated")
        lc = models.Lifecycle.from_lifecyclelist(lcl)
        self.controller.lifecycle = lc
        self.controller.state = models.State.objects.get(name="draft")
        self.controller.svn_revision = "HEAD"
        self.controller.save()
        self.controller.promote()
        self.assertEqual(self.controller.state.name, "issue1")
        self.assertEqual("HEAD", self.controller.svn_revision)
        self.controller.demote()
        self.assertEqual(self.controller.state.name, "draft")
        self.assertTrue(self.controller.is_editable)
Ejemplo n.º 6
0
 def test_lifecycle(self):
     self.attach_to_official_document()
     response = self.get(self.base_url + "lifecycle/")
     lifecycles = self._remove_link_id(response.context["object_lifecycle"])
     wanted = (("draft", True, [self.user.username]),
               ("official", False, [self.user.username]), ("deprecated",
                                                           False, []))
     self.assertFalse(response.context["cancelled_revisions"])
     self.assertFalse(response.context["deprecated_revisions"])
     self.assertEqual(lifecycles, wanted)
     # promote
     self.assertTrue(self.controller.is_promotable())
     response = self.post(self.base_url + "lifecycle/apply/", {
         "promote": "on",
         "password": "******"
     })
     lifecycles = self._remove_link_id(response.context["object_lifecycle"])
     wanted = (("draft", False, [self.user.username]),
               ("official", True, [self.user.username]), ("deprecated",
                                                          False, []))
     self.assertEqual(lifecycles, wanted)
     # demote
     lcl = LifecycleList("diop", "official", "draft", "issue1", "official",
                         "deprecated")
     lc = m.Lifecycle.from_lifecyclelist(lcl)
     self.controller.lifecycle = lc
     self.controller.state = m.State.objects.get(name="draft")
     self.controller.save()
     self.controller.promote()
     self.assertEqual(self.controller.state.name, "issue1")
     response = self.post(self.base_url + "lifecycle/apply/", {
         "demote": "on",
         "password": "******"
     })
     lifecycles = self._remove_link_id(response.context["object_lifecycle"])
     wanted = (("draft", True, [self.user.username
                                ]), ("issue1", False, [self.user.username]),
               ("official", False, []), ("deprecated", False, []))
     self.assertEqual(lifecycles, wanted)
Ejemplo n.º 7
0
 def get_issue_lifecycle(self):
     lcl = LifecycleList("lc_asm", O, D, P, I, O, DE)
     return models.Lifecycle.from_lifecyclelist(lcl)
Ejemplo n.º 8
0
 def test_iteration(self):
     cycle = LifecycleList("cycle_name", "b", "a", "b", "c")
     lifecycle = Lifecycle.from_lifecyclelist(cycle)
     for i, state in enumerate(lifecycle):
         self.assertEqual(state, cycle[i])
Ejemplo n.º 9
0
 def test_from_list(self):
     cycle = LifecycleList("cycle_name", "b", "a", "b", "c")
     lifecycle = Lifecycle.from_lifecyclelist(cycle)
     self.assertEqual(cycle.name, lifecycle.name)