Reputation: 3596
I'm writing a Django unit test against an app I inherited.
In the context of a unit test I am doing something like:
data = {'foo':'bar','color':'blue'}
self.client.post(url,data=data)
However, the app expects muiltiple form data for "color" in the same key in the HTTP request, such as:
foo: bar
color: orange
color: blue
What's the best and most pythonic way to handle this? Is there a django class I should be using that already covers this?
I obviously can't create a python dict with duplicate keys, so I am not sure what I should use to get the above desired HTTP POST.
I can't change the underlying app, I'm interfacing with something that already exists!
Upvotes: 0
Views: 115
Reputation: 3596
I hate to answer my own question here, but as soon as I asked I got it to work without using any extra python stuff.
Apparently the Django client post understands will take the following input:
data = {'foo':'bar','color':['orange','blue']}
self.client.post(url,data=data)
into the desired output.
Upvotes: 1