commit 170f65e207ab45496152abc9c2e64384669f1ea4
parent 81eb4ba5fd6347dbe65af4a72a5b090ae99d62f4
Author: lash <dev@holbrook.no>
Date: Sat, 22 Apr 2023 15:17:02 +0100
Add alias support for dep
Diffstat:
8 files changed, 67 insertions(+), 28 deletions(-)
diff --git a/.piknik/.msg/.master b/.piknik/.msg/.master
Binary files differ.
diff --git a/CHANGELOG b/CHANGELOG
@@ -1,3 +1,5 @@
+- 0.3.11:
+ * Make msg, tag and dep work with alias
- 0.3.10
* Fix backward compatibilty for issue structs without alias
- 0.3.9
diff --git a/piknik/basket.py b/piknik/basket.py
@@ -57,7 +57,7 @@ class Basket:
def get(self, issue_id):
- logg.debug("basked issue get {}".format(issue_id))
+ logg.debug("basket issue get {}".format(issue_id))
r = self.state.get(issue_id)
if r == None:
aliased_issue_id = self.__alias.get(issue_id)
@@ -135,31 +135,33 @@ class Basket:
except AttributeError:
self.__tags.add(tag)
v = self.__tags.from_name(tag)
-
+
+ o = self.get(issue_id)
move = False
try:
- r = self.__tags.state(issue_id)
+ r = self.__tags.state(o.id)
if r == 0:
move = True
except shep.error.StateItemNotFound:
- self.__tags.put(issue_id)
+ self.__tags.put(o.id)
move = True
if move:
- self.__tags.move(issue_id, v)
+ self.__tags.move(o.id, v)
else:
- self.__tags.set(issue_id, v)
+ self.__tags.set(o.id, v)
def untag(self, issue_id, tag):
v = self.__tags.from_name(tag)
- self.__tags.unset(issue_id, v, allow_base=True)
+ o = self.get(issue_id)
+ self.__tags.unset(o.id, v, allow_base=True)
def tags(self, issue_id):
o = self.get(issue_id)
- v = self.__tags.state(o.id) #issue_id)
+ v = self.__tags.state(o.id)
r = self.__tags.elements(v)
if r == 'UNTAGGED':
r = '(' + r + ')'
@@ -167,9 +169,7 @@ class Basket:
def __get_msg(self, issue_id, envelope_callback=None, message_callback=None, post_callback=None):
- #r = self.state.get(issue_id)
o = self.get(issue_id)
- #o = Issue.from_str(r)
try:
v = self.__msg.get(o.id)
m = IssueMessage.parse(o, v.decode('utf-8'), envelope_callback=envelope_callback, message_callback=message_callback, post_callback=post_callback)
@@ -185,31 +185,23 @@ class Basket:
def dep(self, issue_id, dependency_issue_id):
- #r = self.state.get(issue_id)
o = self.get(issue_id)
- #self.state.get(dependency_issue_id)
- self.get(dependency_issue_id)
- #o = Issue.from_str(r)
- r = o.dep(dependency_issue_id)
+ od = self.get(dependency_issue_id)
+ r = o.dep(od.id)
self.state.replace(o.id, contents=str(o))
return r
def undep(self, issue_id, dependency_issue_id):
- #r = self.state.get(issue_id)
o = self.get(issue_id)
- #self.state.get(dependency_issue_id)
self.get(dependency_issue_id)
- #o = Issue.from_str(r)
r = o.undep(dependency_issue_id)
self.state.replace(o.id, contents=str(o))
return r
def assign(self, issue_id, identity):
- #r = self.state.get(issue_id)
o = self.get(issue_id)
- #o = Issue.from_str(r)
v = Identity(identity)
r = o.assign(v)
self.state.replace(o.id, contents=str(o))
@@ -217,9 +209,7 @@ class Basket:
def owner(self, issue_id, identity):
- #r = self.state.get(issue_id)
o = self.get(issue_id)
- #o = Issue.from_str(r)
v = Identity(identity)
r = o.set_owner(v)
self.state.replace(o.id, contents=str(o))
@@ -227,9 +217,7 @@ class Basket:
def unassign(self, issue_id, identity):
- #r = self.state.get(issue_id)
o = self.get(issue_id)
- #o = Issue.from_str(r)
v = Identity(identity)
r = o.unassign(v)
self.state.replace(o.id, contents=str(o))
@@ -237,8 +225,9 @@ class Basket:
def msg(self, issue_id, *args):
- m = self.__get_msg(issue_id)
+ o = self.get(issue_id)
+ m = self.__get_msg(o.id)
m.add(*args, wrapper=self.__msg_wrap)
ms = m.as_bytes()
- self.__msg.put(issue_id, ms)
+ self.__msg.put(o.id, ms)
return m
diff --git a/test_cli.sh b/test_cli.sh
@@ -9,6 +9,7 @@ d=`mktemp -d`
g=`mktemp -d`
# works with gnupg 2.2.41
+export GNUPGHOME=$g
gpg --homedir $g --passphrase '' --quick-generate-key --pinentry loopback --yes testuser
fp=`gpg --list-keys --homedir $g testuser 2> /dev/null | awk '/^ / {print $1;}'`
@@ -17,7 +18,7 @@ i_bar=`python piknik/runnable/cmd.py add "bar"`
python piknik/runnable/cmd.py mod --accept -i $i_foo
python piknik/runnable/cmd.py mod --finish -i $i_bar
-GNUPGHOME=$g python piknik/runnable/cmd.py comment -s $fp -x bazbazbaz -i $i_foo
+python piknik/runnable/cmd.py comment -s $fp -x bazbazbaz -i $i_foo
python piknik/runnable/cmd.py show
python piknik/runnable/cmd.py show -r html
python piknik/runnable/cmd.py show -i $i_foo
diff --git a/tests/test_basic.py b/tests/test_basic.py
@@ -126,6 +126,5 @@ class TestBasic(unittest.TestCase):
with self.assertRaises(FileNotFoundError):
o = self.b.get("first")
-
if __name__ == '__main__':
unittest.main()
diff --git a/tests/test_dep.py b/tests/test_dep.py
@@ -4,11 +4,15 @@ import logging
import json
# local imports
+from piknik import Basket
from piknik import Issue
from piknik.identity import Identity
from piknik.error import UnknownIdentityError
from piknik.error import ExistsError
+# tests imports
+from tests.common import TestStates
+
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
@@ -30,5 +34,23 @@ class TestAssign(unittest.TestCase):
self.assertEqual(len(one.dependencies), 1)
+ def test_dep_alias(self):
+ one = Issue('foo', alias='inky')
+ two = Issue('bar', alias='pinky')
+ three = Issue('baz')
+ self.b = Basket(TestStates())
+ issue_id_one = self.b.add(one)
+ issue_id_two = self.b.add(two)
+ issue_id_three = self.b.add(three)
+ self.b.dep('inky', 'pinky')
+ self.b.dep(issue_id_three, 'inky')
+
+ with self.assertRaises(ExistsError):
+ self.b.dep(issue_id_one, 'pinky')
+
+ with self.assertRaises(ExistsError):
+ self.b.dep(issue_id_three, issue_id_one)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/test_msg.py b/tests/test_msg.py
@@ -96,6 +96,22 @@ class TestMsg(unittest.TestCase):
m = b.get_msg(v, envelope_callback=render_envelope, message_callback=render_message)
+ def test_render_alias(self):
+ b = Basket(self.store, message_wrapper=test_wrapper)
+ o = Issue('bar', alias='xyzzy')
+ v = b.add(o)
+ m = b.msg(v, 's:foo')
+ m = b.msg(v, 's:bar', 's:baz')
+
+ def render_envelope(msg, hdr):
+ print('eeeeeenvvv {} {}'.format(hdr, msg))
+
+ def render_message(envelope, msg, mid):
+ print('rendeeeer {} {}'.format(mid, msg))
+
+ m = b.get_msg('xyzzy', envelope_callback=render_envelope, message_callback=render_message)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/test_tag.py b/tests/test_tag.py
@@ -37,6 +37,16 @@ class TestBasic(unittest.TestCase):
self.b.tag(v, 'pinky')
self.b.untag(v, 'pinky')
+
+ def test_setget_alias(self):
+ o = Issue('foo', alias='bar')
+ v = self.b.add(o)
+ self.b.tag('bar', 'inky')
+ self.b.tag('bar', 'pinky')
+ self.b.untag('bar', 'pinky')
+ self.assertEqual(self.b.tags('bar'), ['INKY'])
+
+
if __name__ == '__main__':
unittest.main()