piknik

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

commit c7866af91e293332f7b1c0bb28039b26cfb2e3ee
parent d08471cb0cd2f4e781d7ad8d677ce008131b06a6
Author: lash <dev@holbrook.no>
Date:   Sun,  6 Nov 2022 14:57:26 +0000

Enable blocking, auto-unblock on advance, test full advance

Diffstat:
Mpiknik/basket.py | 27+++++++++++++++++++++++++++
Mtest/test_basic.py | 24+++++++++++++++++++++++-
2 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/piknik/basket.py b/piknik/basket.py @@ -1,5 +1,7 @@ import shep +from .error import DeadIssue + class Basket: @@ -10,6 +12,10 @@ class Basket: self.state.add('review') self.state.add('finished') self.state.add('blocked') + + self.state.alias('doingblocked', self.state.DOING | self.state.BLOCKED) + self.state.alias('pendingblocked', self.state.PENDING | self.state.BLOCKED) + self.limit = self.state.FINISHED self.issues_rev = {} @@ -34,3 +40,24 @@ class Basket: def doing(self, issue_id): self.state.move(issue_id, self.state.DOING) + + + def advance(self, issue_id): + if self.state.state(issue_id) & self.limit > 0: + raise DeadIssue(issue_id) + self.unblock(issue_id) + self.state.next(issue_id) + + + def unblock(self, issue_id): + if self.state.state(issue_id) & self.state.BLOCKED > 0: + print('unset') + self.state.unset(issue_id, self.state.BLOCKED) + + + def block(self, issue_id): + self.state.set(issue_id, self.state.BLOCKED) + + + def blocked(self): + return self.list('blocked') diff --git a/test/test_basic.py b/test/test_basic.py @@ -9,6 +9,7 @@ from piknik import ( Basket, Issue, ) +from piknik.error import DeadIssue def debug_out(self, k, v): @@ -42,7 +43,18 @@ class TestBasic(unittest.TestCase): self.assertEqual(len(r), 2) - def test_progress(self): + def test_progres(self): + o = Issue('The first issue') + self.b.add(o) + self.b.advance(o.id) + self.b.advance(o.id) + self.b.advance(o.id) + self.b.advance(o.id) + with self.assertRaises(DeadIssue): + self.b.advance(o.id) + + + def test_jump(self): o = Issue('The first issue') self.b.add(o) o = Issue('The second issue') @@ -56,5 +68,15 @@ class TestBasic(unittest.TestCase): self.assertEqual(len(r), 1) + def test_magic_unblock(self): + o = Issue('The first issue') + self.b.add(o) + self.b.advance(o.id) + self.b.block(o.id) + self.assertIn(o.id, self.b.blocked()) + self.b.advance(o.id) + self.assertNotIn(o.id, self.b.blocked()) + + if __name__ == '__main__': unittest.main()