@@ -163,7 +163,7 @@ def test_rest_endpoint_item_options(self):
163163 # content-length etc. from f.headers.
164164 self .assertDictEqual ({ key : value for (key , value ) in f .headers .items () if key in expected }, expected )
165165
166- def test_rest_endpoint_element_options (self ):
166+ def test_rest_endpoint_attribute_options (self ):
167167 # use basic auth for rest endpoint
168168 f = requests .options (self .url_base () + '/rest/data/user/1/username' ,
169169 auth = ('admin' , 'sekrit' ),
@@ -183,5 +183,29 @@ def test_rest_endpoint_element_options(self):
183183 # content-length etc. from f.headers.
184184 self .assertDictEqual ({ key : value for (key , value ) in f .headers .items () if key in expected }, expected )
185185
186+ ## test a read only property.
187+
188+ f = requests .options (self .url_base () + '/rest/data/user/1/creator' ,
189+ auth = ('admin' , 'sekrit' ),
190+ headers = {'content-type' : "" })
191+ print (f .status_code )
192+ print (f .headers )
193+
194+ self .assertEqual (f .status_code , 204 )
195+ expected1 = dict (expected )
196+ expected1 ['Allow' ] = 'OPTIONS, GET'
197+
198+ # use dict comprehension to remove fields like date,
199+ # content-length etc. from f.headers.
200+ self .assertDictEqual ({ key : value for (key , value ) in f .headers .items () if key in expected }, expected1 )
201+
202+ ## test a property that doesn't exist
203+ f = requests .options (self .url_base () + '/rest/data/user/1/zot' ,
204+ auth = ('admin' , 'sekrit' ),
205+ headers = {'content-type' : "" })
206+ print (f .status_code )
207+ print (f .headers )
208+
209+ self .assertEqual (f .status_code , 404 )
186210
187211
0 commit comments