blob: 6f1b43b97fdae6b11e085258b641856115d0d894 (
plain)
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.'
}
|