@@ -118,7 +118,7 @@ def test_patch_to_one_relationship(self):
118
118
response = self .client .get (url )
119
119
assert response .data == request_data ['data' ]
120
120
121
- def test_patch_to_many_relationship (self ):
121
+ def test_patch_one_to_many_relationship (self ):
122
122
url = '/blogs/{}/relationships/entry_set' .format (self .first_entry .id )
123
123
request_data = {
124
124
'data' : [{'type' : format_resource_type ('Entry' ), 'id' : str (self .first_entry .id )}, ]
@@ -130,6 +130,25 @@ def test_patch_to_many_relationship(self):
130
130
response = self .client .get (url )
131
131
assert response .data == request_data ['data' ]
132
132
133
+ def test_patch_many_to_many_relationship (self ):
134
+ url = '/entries/{}/relationships/authors' .format (self .first_entry .id )
135
+ request_data = {
136
+ 'data' : [
137
+ {
138
+ 'type' : format_resource_type ('Author' ),
139
+ 'id' : str (self .author .id )
140
+ },
141
+ ]
142
+ }
143
+ response = self .client .patch (url ,
144
+ data = json .dumps (request_data ),
145
+ content_type = 'application/vnd.api+json' )
146
+ assert response .status_code == 200 , response .content .decode ()
147
+ assert response .data == request_data ['data' ]
148
+
149
+ response = self .client .get (url )
150
+ assert response .data == request_data ['data' ]
151
+
133
152
def test_post_to_one_relationship_should_fail (self ):
134
153
url = '/entries/{}/relationships/blog' .format (self .first_entry .id )
135
154
request_data = {
0 commit comments