Debian Codegraph @

pecan/scaffolds/rest-api/+package+/tests/test_functional.py_tmpl

raw
1 import json
2 from ${package}.tests import FunctionalTest
3
4
5 class TestRootController(FunctionalTest):
6
7 def test_get_all(self):
8 response = self.app.get('/people/')
9 assert response.status_int == 200
10 assert response.namespace[1] == 'Luke'
11 assert response.namespace[2] == 'Leia'
12 assert response.namespace[3] == 'Han'
13 assert response.namespace[4] == 'Anakin'
14
15 def test_get_one(self):
16 response = self.app.get('/people/1/')
17 assert response.status_int == 200
18 assert response.body.decode() == 'Luke'
19
20 def test_post(self):
21 response = self.app.post('/people/')
22 assert response.status_int == 201
23
24 def test_put(self):
25 response = self.app.put('/people/1/')
26 assert response.status_int == 204
27
28 def test_delete(self):
29 response = self.app.delete('/people/1/')
30 assert response.status_int == 204
31
32 def test_not_found(self):
33 response = self.app.get('/missing/', expect_errors=True)
34 assert response.status_int == 404
35 assert json.loads(response.body.decode()) == {
36 'reason': 'The resource could not be found.'
37 }