Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 6384:66a061e52435 | 6385:8c43129f29ca |
|---|---|
| 161 | 161 |
| 162 # use dict comprehension to remove fields like date, | 162 # use dict comprehension to remove fields like date, |
| 163 # content-length etc. from f.headers. | 163 # content-length etc. from f.headers. |
| 164 self.assertDictEqual({ key: value for (key, value) in f.headers.items() if key in expected }, expected) | 164 self.assertDictEqual({ key: value for (key, value) in f.headers.items() if key in expected }, expected) |
| 165 | 165 |
| 166 def test_rest_endpoint_element_options(self): | 166 def test_rest_endpoint_attribute_options(self): |
| 167 # use basic auth for rest endpoint | 167 # use basic auth for rest endpoint |
| 168 f = requests.options(self.url_base() + '/rest/data/user/1/username', | 168 f = requests.options(self.url_base() + '/rest/data/user/1/username', |
| 169 auth=('admin', 'sekrit'), | 169 auth=('admin', 'sekrit'), |
| 170 headers = {'content-type': ""}) | 170 headers = {'content-type': ""}) |
| 171 print(f.status_code) | 171 print(f.status_code) |
| 181 | 181 |
| 182 # use dict comprehension to remove fields like date, | 182 # use dict comprehension to remove fields like date, |
| 183 # content-length etc. from f.headers. | 183 # content-length etc. from f.headers. |
| 184 self.assertDictEqual({ key: value for (key, value) in f.headers.items() if key in expected }, expected) | 184 self.assertDictEqual({ key: value for (key, value) in f.headers.items() if key in expected }, expected) |
| 185 | 185 |
| 186 | 186 ## test a read only property. |
| 187 | 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) | |
| 210 | |
| 211 |
