I have created two dictionary in python
self.post_data={
'name' : 'Org 1',
'url' : 'http://www.org1.com',
'summary' : 'This is an example org1'
}
second
self.post_data1={
'name' : 'Org 2',
'url' : 'http://www.org2.com',
'summary' : 'This is an example org2'
}
Now my test_post_list
function is
def test_post_list(self):
self.create_session()
self.assertEqual(Org.objects.count(), 0)
self.assertHttpCreated(self.api_client.post('/members/api/v1/org/', format='json', data=[{self.post_data},{self.post_data1}]))
self.assertEqual(Org.objects.count(), 1)
if I pass data like this to test case, it raises an error
>ERROR: test_post_list (members.tests.test_org_resource.OrgTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\Sanky\amber\members\tests\test_org_resource.py", line 51, in te
st_post_list
self.assertHttpCreated(self.api_client.post('/members/api/v1/org/', format='json', data={self.post_data,self.post_data1}))
TypeError: unhashable type: 'dict'`
How I will be able to pass list as data to test
function.
Do something like this
data=[self.post_data,self.post_data1]
instead of this --
data=[{self.post_data},{self.post_data1}]
i.e no need to include dictionary inside {}