piknik

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

commit 0d1d11b94be1fd98aaa2ccc23ab9fca85f5bb1a2
parent 3f0bbc1aca8a9f0eca07b25cd4eee31f109c22c7
Author: lash <dev@holbrook.no>
Date:   Fri,  2 Dec 2022 11:47:41 +0000

Rehabilitate render test

Diffstat:
Mpiknik/render/base.py | 13+++++++++----
Mpiknik/wrap.py | 7+++++--
Mtests/test_render.py | 11++++++++---
3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/piknik/render/base.py b/piknik/render/base.py @@ -56,6 +56,10 @@ class Renderer: pass + def apply_message_part(self, state, issue, tags, envelope, message, message_date, message_content, accumulator=None): + pass + + def apply_issue_pre(self, state, issue, tags, accumulator=None): pass @@ -81,10 +85,11 @@ class Renderer: def message_callback(message, message_id, message_date): envelope = None - if self.w != None: - (envelope, message) = self.w.process_message(envelope, message, message_id, message_date) - else: - logg.warning('no wrapper defined. no message parts will be output') + if self.w == None: + logg.warning('no wrapper defined. no message parts will be output {}'.format(message)) + return (envelope, message,) + + (envelope, message) = self.w.process_message(envelope, message, message_id, message_date) initial = True while True: diff --git a/piknik/wrap.py b/piknik/wrap.py @@ -25,8 +25,11 @@ class Wrapper: self.envelope_state = 0 - def process_message(self, envelope, msg, message_id, message_data): - raise NotImplementedError() + def process_message(self, envelope, msg, message_id, message_date): + if msg.get('X-Piknik-Msg-Id') == None: + self.add(envelope, message_id, msg) + return (envelope, msg,) + #raise NotImplementedError() def add(self, envelope, message_id, message): diff --git a/tests/test_render.py b/tests/test_render.py @@ -18,6 +18,7 @@ from piknik import ( ) from piknik.msg import IssueMessage from piknik.render.base import Renderer +from piknik.wrap import Wrapper # test imports from tests.common import TestStates @@ -46,7 +47,7 @@ def test_unwrapper(msg, message_callback=None, part_callback=None): class TestRenderer(Renderer): def __init__(self, basket, accumulator=None): - super(TestRenderer, self).__init__(basket, accumulator=accumulator) + super(TestRenderer, self).__init__(basket, accumulator=accumulator, wrapper=Wrapper()) self.p = 0 self.e = 0 @@ -57,12 +58,15 @@ class TestRenderer(Renderer): return r - def apply_message(self, state, issue, tags, envelope, message, message_id, accumulator=None): +# def apply_message(self, state, issue, tags, envelope, message, message_id, message_date, accumulator=None): + def apply_message_part(self, state, issue, tags, envelope, message, message_date, message_content, accumulator=None): r = self.p self.p += 1 return r + + class TestRendererComposite(TestRenderer): def __init__(self, basket, accumulator=None): @@ -71,7 +75,7 @@ class TestRendererComposite(TestRenderer): self.m = [] - def apply_message_post(self, state, issue, tags, envelope, message, message_id, accumulator=None): + def apply_message_post(self, state, issue, tags, envelope, message, message_id, message_date, accumulator=None): if self.last_message_id != message_id: self.m.append(message_id) self.last_message_id = message_id @@ -95,6 +99,7 @@ class TestMsg(unittest.TestCase): def test_idlepass(self): + wrapper = Wrapper() renderer = TestRenderer(self.b, accumulator=self.accumulate) issue_one = Issue('foo') self.b.add(issue_one)