Mercurial > p > roundup > code
diff test/test_liveserver.py @ 6385:8c43129f29ca
Rename test: element => attribute; test readonly and missing attribute
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 21 Apr 2021 14:43:58 -0400 |
| parents | 66a061e52435 |
| children | 2a2da73e1e26 |
line wrap: on
line diff
--- a/test/test_liveserver.py Wed Apr 21 00:48:28 2021 -0400 +++ b/test/test_liveserver.py Wed Apr 21 14:43:58 2021 -0400 @@ -163,7 +163,7 @@ # content-length etc. from f.headers. self.assertDictEqual({ key: value for (key, value) in f.headers.items() if key in expected }, expected) - def test_rest_endpoint_element_options(self): + def test_rest_endpoint_attribute_options(self): # use basic auth for rest endpoint f = requests.options(self.url_base() + '/rest/data/user/1/username', auth=('admin', 'sekrit'), @@ -183,5 +183,29 @@ # content-length etc. from f.headers. self.assertDictEqual({ key: value for (key, value) in f.headers.items() if key in expected }, expected) + ## test a read only property. + + f = requests.options(self.url_base() + '/rest/data/user/1/creator', + auth=('admin', 'sekrit'), + headers = {'content-type': ""}) + print(f.status_code) + print(f.headers) + + self.assertEqual(f.status_code, 204) + expected1 = dict(expected) + expected1['Allow'] = 'OPTIONS, GET' + + # use dict comprehension to remove fields like date, + # content-length etc. from f.headers. + self.assertDictEqual({ key: value for (key, value) in f.headers.items() if key in expected }, expected1) + + ## test a property that doesn't exist + f = requests.options(self.url_base() + '/rest/data/user/1/zot', + auth=('admin', 'sekrit'), + headers = {'content-type': ""}) + print(f.status_code) + print(f.headers) + + self.assertEqual(f.status_code, 404)
