/usr/lib/python2.7/dist-packages/pecan/scaffolds/rest-api/+package+/tests/test_functional.py_tmpl is in python-pecan 0.6.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | import json
from ${package}.tests import FunctionalTest
class TestRootController(FunctionalTest):
def test_get_all(self):
response = self.app.get('/people/')
assert response.status_int == 200
assert response.namespace[1] == 'Luke'
assert response.namespace[2] == 'Leia'
assert response.namespace[3] == 'Han'
assert response.namespace[4] == 'Anakin'
def test_get_one(self):
response = self.app.get('/people/1/')
assert response.status_int == 200
assert response.body.decode() == 'Luke'
def test_post(self):
response = self.app.post('/people/')
assert response.status_int == 201
def test_put(self):
response = self.app.put('/people/1')
assert response.status_int == 204
def test_delete(self):
response = self.app.delete('/people/1')
assert response.status_int == 204
def test_not_found(self):
response = self.app.get('/missing/', expect_errors=True)
assert response.status_int == 404
assert json.loads(response.body.decode()) == {
'reason': 'The resource could not be found.'
}
|