Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent "Saved data" view from raising an exception if a field is not found #382

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

frapell
Copy link
Member

@frapell frapell commented Nov 24, 2022

fixes gh-381

Copy link
Member

@fredvd fredvd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frapell Looks good to me. But can we add a test for this? I think we can just duplicate the test linked below and add a "stalefield" to the test at saver.showFields = assignment. With your fix it should no longer crash.

def testSaverDataFormShowFields(self):
"""test saver data form show fields"""
self.createSaver()
self.assertTrue("saver" in get_actions(self.ff1))
saver = get_actions(self.ff1)["saver"]
self.assertEqual(saver.itemsSaved(), 0)
request = FakeRequest(
topic="test subject", replyto="[email protected]", comments="test comments"
)
saver.showFields = ("topic", "comments")
saver.onSuccess(request.form, request)
view = self.ff1.restrictedTraverse("@@actions")
view = view.publishTraverse(view.request, "saver")
view = view.publishTraverse(view.request, "data")
view.update()
form = view.form_instance
message = form.description()
self.assertEqual(message.mapping, {"items": 1})
item = form.get_items()[0]
self.assertEqual(item[1]["id"], item[0])
self.assertEqual(item[1]["topic"], "test subject")
self.assertEqual(item[1]["comments"], "test comments")
self.assertTrue("replyto" not in item[1])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants