If my view uses this pattern for working with forms

appstruct = deform_form.validate(request.POST.items())

Then to unit test it I do something like this

post = collections.OrderedDict([
    ('somefield', 'somevalue'),
    ('__start__', 'somedate:mapping'),
    ('year', '1111'),
    ('month', '11'),
    ('day', '11'),
    ('__end__', 'somedate:mapping'),
]))
request = testing.DummyRequest(post=post)
response = views.someview(request)

With more complex forms this test code gets messy and less readable with 
__start__, __end__, :sequence, :mapping all over the place.

I've skimmed through the code for peppercorn/deform/pyramid and I can find 
ways to turn the POSTed values into an appstruct, but I can't find any way 
to turn an appstruct into these peppercorn POST values. The closest hints I 
could find is https://github.com/Pylons/deform/search?q=__start__ and 
https://github.com/Pylons/deform/search?q=start_mapping

Is there a way to do something like

post = some_function({
    'somefield': 'somevalue',
    'somedate': some_date
})
request = testing.DummyRequest(post=post)
response = views.someview(request)

which would be equivalent to the first example? If not would it be a worthy 
feature request for deform or peppercorn?

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to