From 9394ad5a613652fdfa54f4084b48e7c6d134d867 Mon Sep 17 00:00:00 2001 From: Jeremy Cline Date: Wed, 27 Feb 2019 15:05:38 -0500 Subject: [PATCH] Fix the mailman_schema example to work with Message.body The message ``body`` variable is used by the Message class, but the example schema is still defining a property using that name. See https://pagure.io/fedora-commops/fedora-happiness-packets/issue/96 Signed-off-by: Jeremy Cline --- docs/sample_schema_package/mailman_schema/schema.py | 12 +++++++----- .../mailman_schema/tests/test_schema.py | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/sample_schema_package/mailman_schema/schema.py b/docs/sample_schema_package/mailman_schema/schema.py index 78c9e490..6eb93c13 100644 --- a/docs/sample_schema_package/mailman_schema/schema.py +++ b/docs/sample_schema_package/mailman_schema/schema.py @@ -29,7 +29,9 @@ class BaseMessage(message.Message): def __str__(self): """Return a complete human-readable representation of the message.""" - return "Subject: {subj}\n{body}\n".format(subj=self.subject, body=self.body) + return "Subject: {subj}\n{body}\n".format( + subj=self.subject, body=self.email_body + ) @property def summary(self): @@ -42,9 +44,9 @@ def subject(self): return 'Message did not implement "subject" property' @property - def body(self): + def email_body(self): """The email message body.""" - return 'Message did not implement "body" property' + return 'Message did not implement "email_body" property' @property def url(self): @@ -133,7 +135,7 @@ def subject(self): return self.body["msg"]["subject"] @property - def body(self): + def email_body(self): """The email message body.""" return self.body["msg"]["body"] @@ -187,7 +189,7 @@ def subject(self): return self.body["subject"] @property - def body(self): + def email_body(self): """The email message body.""" return self.body["body"] diff --git a/docs/sample_schema_package/mailman_schema/tests/test_schema.py b/docs/sample_schema_package/mailman_schema/tests/test_schema.py index 75e2543e..af3107d0 100644 --- a/docs/sample_schema_package/mailman_schema/tests/test_schema.py +++ b/docs/sample_schema_package/mailman_schema/tests/test_schema.py @@ -100,7 +100,7 @@ def test_body(self): """Assert the message provides a "body" attribute.""" message = self.msg_class(body=self.full_message) - self.assertEqual("hello world", message.body) + self.assertEqual("hello world", message.email_body) def test_url(self): """Assert the message provides a "url" attribute."""