@@ -129,6 +129,7 @@ def test_412_on_single_record_has_last_modified_timestamp(self):
129
129
self .assertIsNotNone (error .headers .get ('Last-Modified' ))
130
130
131
131
def test_create_returns_412_if_changed_meanwhile (self ):
132
+ self .resource .request .validated = {'data' : {'field' : 'new' }}
132
133
self .assertRaises (httpexceptions .HTTPPreconditionFailed ,
133
134
self .resource .collection_post )
134
135
@@ -159,16 +160,39 @@ def test_put_returns_412_if_deleted_meanwhile(self):
159
160
self .assertRaises (httpexceptions .HTTPPreconditionFailed ,
160
161
self .resource .put )
161
162
162
- def test_if_none_match_star_fails_if_record_exists (self ):
163
+ def test_put_if_none_match_star_fails_if_record_exists (self ):
163
164
self .resource .request .headers .pop ('If-Match' )
164
165
self .resource .request .headers ['If-None-Match' ] = '*'
165
166
self .resource .record_id = self .stored ['id' ]
166
167
self .assertRaises (httpexceptions .HTTPPreconditionFailed ,
167
168
self .resource .put )
169
+
170
+ def test_put_if_none_match_star_succeeds_if_record_does_not_exist (self ):
171
+ self .resource .request .headers .pop ('If-Match' )
172
+ self .resource .request .headers ['If-None-Match' ] = '*'
168
173
self .resource .request .validated = {'data' : {'field' : 'new' }}
169
174
self .resource .record_id = self .resource .model .id_generator ()
170
175
self .resource .put () # not raising.
171
176
177
+ def test_post_if_none_match_star_fails_if_record_exists (self ):
178
+ self .resource .request .headers .pop ('If-Match' )
179
+ self .resource .request .headers ['If-None-Match' ] = '*'
180
+ self .resource .request .json = self .resource .request .validated = {
181
+ 'data' : {
182
+ 'id' : self .stored ['id' ],
183
+ 'field' : 'new' }}
184
+ self .assertRaises (httpexceptions .HTTPPreconditionFailed ,
185
+ self .resource .collection_post )
186
+
187
+ def test_post_if_none_match_star_succeeds_if_record_does_not_exist (self ):
188
+ self .resource .request .headers .pop ('If-Match' )
189
+ self .resource .request .headers ['If-None-Match' ] = '*'
190
+ self .resource .request .validated = {
191
+ 'data' : {
192
+ 'id' : self .resource .model .id_generator (),
193
+ 'field' : 'new' }}
194
+ self .resource .collection_post () # not raising.
195
+
172
196
def test_patch_returns_412_if_changed_meanwhile (self ):
173
197
self .resource .record_id = self .stored ['id' ]
174
198
self .assertRaises (httpexceptions .HTTPPreconditionFailed ,
0 commit comments