commit 1e3dc968ff9e1ced72ff5c413469a0fb2f6c79da
parent 8d942a7b2191c471de29c839d5ae35f98ad51d56
Author: lash <dev@holbrook.no>
Date: Tue, 8 Nov 2022 16:29:29 +0000
Test resume msg when using filestore
Diffstat:
5 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/piknik/msg.py b/piknik/msg.py
@@ -13,10 +13,9 @@ from email.policy import Compat32
logg = logging.getLogger(__name__)
-class IssueMessage: #(Message):
+class IssueMessage:
def __init__(self, issue):
- #super(IssueMessage, self).__init__()
self.__m = Message()
self.__m.add_header('Subject', issue.title)
diff --git a/piknik/store/__init__.py b/piknik/store/__init__.py
@@ -23,7 +23,7 @@ class MsgDir(HexDir):
def get(self, k):
fp = self.to_filepath(k)
f = None
- f = open(fp, 'r')
+ f = open(fp, 'rb')
r = f.read()
f.close()
return r
diff --git a/tests/common.py b/tests/common.py
@@ -29,13 +29,13 @@ class TestMsgStore:
class TestStates:
- def create_states(*args, **kwargs):
+ def create_states(self, *args, **kwargs):
return shep.State(6, *args, event_callback=debug_out, **kwargs)
- def create_tags(*args, **kwargs):
+ def create_tags(self, *args, **kwargs):
return shep.State(0, *args, event_callback=debug_out, check_alias=False, **kwargs)
- def create_messages(*args):
+ def create_messages(self, *args):
return TestMsgStore()
diff --git a/tests/test_msg.py b/tests/test_msg.py
@@ -12,6 +12,7 @@ from piknik.msg import IssueMessage
# test imports
from tests.common import TestStates
+from tests.common import TestMsgStore
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
@@ -21,7 +22,8 @@ logg = logging.getLogger()
class TestMsg(unittest.TestCase):
def setUp(self):
- self.b = Basket(TestStates())
+ self.store = TestStates()
+ self.b = Basket(self.store)
def test_basic(self):
@@ -57,5 +59,6 @@ class TestMsg(unittest.TestCase):
print(m)
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/test_store.py b/tests/test_store.py
@@ -84,5 +84,16 @@ class TestStore(unittest.TestCase):
m = self.b.msg(issue_id, 'bar')
+
+ def test_msg_resume(self):
+ o = Issue('foo')
+ v = self.b.add(o)
+ m = self.b.msg(v, 's:bar')
+
+ b = Basket(self.store_factory)
+ m = b.msg(v, 's:baz')
+ print(m)
+
+
if __name__ == '__main__':
unittest.main()