commit 1ccfe31ae93da8a1cd5aa92d688146af95fa30b8
parent e0f5e40ee037fef024d4c0200eed607ea07f469c
Author: lash <dev@holbrook.no>
Date: Sun, 6 Nov 2022 15:19:14 +0000
Prevent resurrection
Diffstat:
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/piknik/basket.py b/piknik/basket.py
@@ -6,7 +6,8 @@ from .error import DeadIssue
class Basket:
def __init__(self, state_factory):
- self.state = state_factory(default_state='backlog')
+ self.no_resurrect = True
+ self.state = state_factory(default_state='backlog', verifier=self.__check_resurrect)
self.state.add('pending')
self.state.add('doing')
self.state.add('review')
@@ -20,6 +21,12 @@ class Basket:
self.issues_rev = {}
+ def __check_resurrect(self, st, k, f, t):
+ if self.no_resurrect:
+ if f & self.state.FINISHED > 0:
+ raise DeadIssue(k)
+
+
def add(self, issue):
self.state.put(issue.id, contents=issue)
self.issues_rev[issue.id] = issue
@@ -51,7 +58,7 @@ class Basket:
def finish(self, issue_id):
- self.state.move(issue_id, self.state.BACKLOG)
+ self.state.move(issue_id, self.state.FINISHED)
def advance(self, issue_id):
diff --git a/requirements.txt b/requirements.txt
@@ -1,2 +1,2 @@
-shep~=0.2.10
+shep~=0.2.11
confini~=0.6.3
diff --git a/test/test_basic.py b/test/test_basic.py
@@ -73,12 +73,16 @@ class TestBasic(unittest.TestCase):
self.b.add(o)
self.b.doing(o.id)
r = self.b.list('doing')
+ self.assertEquals(len(r), 1)
self.b.review(o.id)
r = self.b.list('review')
+ self.assertEquals(len(r), 1)
self.b.backlog(o.id)
r = self.b.list('backlog')
+ self.assertEquals(len(r), 1)
self.b.finish(o.id)
r = self.b.list('finished')
+ self.assertEquals(len(r), 1)
def test_magic_unblock(self):
@@ -91,5 +95,13 @@ class TestBasic(unittest.TestCase):
self.assertNotIn(o.id, self.b.blocked())
+ def test_no_resurrect(self):
+ o = Issue('The first issue')
+ self.b.add(o)
+ self.b.finish(o.id)
+ with self.assertRaises(DeadIssue):
+ self.b.doing(o.id)
+
+
if __name__ == '__main__':
unittest.main()