From 512e27f48f9814bbb2d5e961d802e22550918524 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 22 Oct 2018 12:03:10 +0200 Subject: [PATCH 3/3] rename as_json_attachment to as_json (to be squashed) --- tests/test_workflows.py | 4 ++-- wcs/variables.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_workflows.py b/tests/test_workflows.py index 7df31ef5..6757b550 100644 --- a/tests/test_workflows.py +++ b/tests/test_workflows.py @@ -1213,14 +1213,14 @@ def test_email_attachments(pub, emails): assert len(emails.emails['foobar']['msg'].get_payload()) == 3 emails.empty() - sendmail.attachments = ['form.as_json_attachment', 'form.as_json_attachment_with_files'] + sendmail.attachments = ['utils.attachment(form.as_json)', 'utils.attachment(form.as_json_with_files)'] sendmail.perform(formdata) get_response().process_after_jobs() assert emails.count() == 1 assert emails.emails['foobar']['msg'].is_multipart() assert emails.emails['foobar']['msg'].get_content_subtype() == 'mixed' assert emails.emails['foobar']['msg'].get_payload(0).get_content_type() == 'text/html' - assert emails.emails['foobar']['msg'].get_payload(1).get_content_type() == 'application/json' + assert emails.emails['foobar']['msg'].get_payload(1).get_content_type() == 'application/octet-stream' payload1 = emails.emails['foobar']['msg'].get_payload(1) payload2 = emails.emails['foobar']['msg'].get_payload(2) assert json.loads(formdata.export_to_json(include_files=False)) == json.loads(payload1.get_payload(decode=True)) diff --git a/wcs/variables.py b/wcs/variables.py index 84f07a5e..82fdc8e6 100644 --- a/wcs/variables.py +++ b/wcs/variables.py @@ -259,12 +259,12 @@ class LazyFormData(LazyFormDef): } @property - def as_json_attachment(self): - return self.__to_json_attachment() + def as_json(self): + return self.formdata.export_to_json(include_files=False) @property - def as_json_attachment_with_files(self): - return self.__to_json_attachment(include_files=True) + def as_json_with_files(self): + return self.formdata.export_to_json(include_files=True) def __getitem__(self, key): try: -- 2.18.0