diff --git a/tests/test_project/test_app/tests/test_basic.py b/tests/test_project/test_app/tests/test_basic.py index 3a3c03b..0bf255f 100644 --- a/tests/test_project/test_app/tests/test_basic.py +++ b/tests/test_project/test_app/tests/test_basic.py @@ -913,6 +913,19 @@ def test_referencedlistnonfull(self): self.assertEqual(response['name'], 'Person 1') + def test_embeddedreferencedlist_create(self): + response = self.c.post(self.resourceListURI('person'), '{"name": "Person 1"}', content_type='application/json') + self.assertEqual(response.status_code, 201) + + person1_uri = response['location'] + + response = self.c.post(self.resourceListURI('embeddedreferencedlistfieldtest'), '{"embedded": {"referencedlist": ["' + self.fullURItoAbsoluteURI(person1_uri) + '"]}}', content_type='application/json') + self.assertEqual(response.status_code, 201) + + person = resources.PersonResource().get_via_uri(self.fullURItoAbsoluteURI(person1_uri)) + obj = resources.EmbeddedReferencedListFieldTestResource().get_via_uri(self.fullURItoAbsoluteURI(response['location'])) + self.assertListEqual(obj.embedded.referencedlist, [person]) + def test_embeddedreferencedlist_get(self): person = documents.Person.objects.create(name="Person 1") obj = documents.EmbeddedReferencedListFieldTest.objects.create(embedded=documents.EmbeddedWithReferencedList(referencedlist=[person])) @@ -925,6 +938,20 @@ def test_embeddedreferencedlist_get(self): self.assertIn('referencedlist', embedded) self.assertEqual(embedded['referencedlist'], [resources.PersonResource().get_resource_uri(person)]) + def test_listofembeddedreferencedlist_create(self): + response = self.c.post(self.resourceListURI('person'), '{"name": "Person 1"}', content_type='application/json') + self.assertEqual(response.status_code, 201) + + person1_uri = response['location'] + + response = self.c.post(self.resourceListURI('listofembeddedreferencedlistfieldtest'), '{"embeddedlist": [{"referencedlist": ["' + self.fullURItoAbsoluteURI(person1_uri) + '"]}]}', content_type='application/json') + self.assertEqual(response.status_code, 201) + + person = resources.PersonResource().get_via_uri(self.fullURItoAbsoluteURI(person1_uri)) + obj = resources.ListOfEmbeddedReferencedListFieldTestResource().get_via_uri(self.fullURItoAbsoluteURI(response['location'])) + self.assertEqual(len(obj.embeddedlist), 1) + self.assertListEqual(obj.embeddedlist[0].referencedlist, [person]) + def test_listofembeddedreferencedlist_get(self): person = documents.Person.objects.create(name="Person 1") obj = documents.ListOfEmbeddedReferencedListFieldTest.objects.create(embeddedlist=[