def testMessageParser(self):
        WidgetMessage = messages.model_message(Widget)

        message = WidgetMessage(title='The Doctor', content='Time Lord')
        request = Bunch(body=unicode(protojson.encode_message(message)))

        parser = MessageParser().process(request, WidgetMessage)

        assert parser.validate()
        assert parser.container == message
    def testMessageParser(self):
        WidgetMessage = messages.model_message(Widget)

        message = WidgetMessage(title='The Doctor', content='Time Lord')
        request = Bunch(body=unicode(protojson.encode_message(message)))

        parser = MessageParser().process(request, WidgetMessage)

        assert parser.validate()
        assert parser.container == message

        w = Widget()
        parser.update(w)

        assert w.title == message.title
        assert w.content == message.content

        # Partial update
        message = WidgetMessage(title='Susan')
        request = Bunch(body=unicode(protojson.encode_message(message)))
        parser = MessageParser().process(request, WidgetMessage)
        parser.update(w)

        assert w.title == 'Susan'
        assert w.content == 'Time Lord'
    def testMessageParser(self):
        WidgetMessage = messages.model_message(Widget)

        message = WidgetMessage(title='The Doctor', content='Time Lord')
        request = Bunch(body=unicode(protojson.encode_message(message)))

        parser = MessageParser().process(request, WidgetMessage)

        assert parser.validate()
        assert parser.container == message

        w = Widget()
        parser.update(w)

        assert w.title == message.title
        assert w.content == message.content

        # Partial update
        message = WidgetMessage(title='Susan')
        request = Bunch(body=unicode(protojson.encode_message(message)))
        parser = MessageParser().process(request, WidgetMessage)
        parser.update(w)

        assert w.title == 'Susan'
        assert w.content == 'Time Lord'