You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`--> python3 manage.py test --failfast
Creating test database for alias 'default'...
................F
======================================================================
FAIL: test_create_author_multipart (testapp.tests.TestEndpoint)
Exercise multipart/form-data POST
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/cleber/code/third-party/django-restless/testproject/testapp/tests.py", line 346, in test_create_author_multipart
self.assertEqual(r.status_code, 201, r.content)
AssertionError: 400 != 201 : b'{"error": "invalid author data", "details": {"name": ["This field is required."]}}'
I made a slight modification on asserEqual so it could print r.content. Aparently, although name is indeed being present on the payload (see below), it's not being recognized somewhere.
The test:
def test_create_author_multipart(self):
"""Exercise multipart/form-data POST"""
r = self.client.post('author_list', data={
'name': 'New User',
}) # multipart/form-data is default in test client
self.assertEqual(r.status_code, 201, r.content)
self.assertEqual(r.json['name'], 'New User')
self.assertEqual(r.json['name'],
Author.objects.get(id=r.json['id']).name)
The text was updated successfully, but these errors were encountered:
cleberzavadniak
changed the title
multipart payload not working on Django 1.10.6
multipart payload TEST not working on Django 1.10.6
Mar 3, 2017
Hi @cleberzavadniak, Django 1.10 introduces content_type attribute on the HttpRequest thus clashing with content_type we used. Django's attribute can be normally used from restless, but ours doesn't behave exactly as Django expects, thus the errors.
I had a fix sitting in the branch waiting for validation since Dec, but noticed I hadn't merged it. I have now (see #28 and #27 for related bug report). Please let me know if this fixes your problem.
I made a slight modification on asserEqual so it could print
r.content
. Aparently, althoughname
is indeed being present on the payload (see below), it's not being recognized somewhere.The test:
The text was updated successfully, but these errors were encountered: