Debian Codegraph @

debian/tests/functional

raw
1 #!/bin/bash
2 #
3 # Functional testing for flask-caching
4 #
5 # Copyright (C) 2022 Emanuele Rocca <[email protected]>
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 set -ex
21
22 function cleanup {
23 kill $(cat $AUTOPKGTEST_TMP/flask.pid)
24 }
25
26 for p in $(py3versions -s); do
27 echo "Testing with $p..."
28
29 $p debian/tests/testapp.py &
30 echo $! > $AUTOPKGTEST_TMP/flask.pid
31 sleep 3
32
33 # The / endpoint returns counter=N. The counter increases at each
34 # invocation.
35 curl http://127.0.0.1:5000/ 2>&1 | grep '^counter=1$'
36
37 # The following two are cached responses.
38 curl http://127.0.0.1:5000/ 2>&1 | grep '^counter=1$'
39 curl http://127.0.0.1:5000/ 2>&1 | grep '^counter=1$'
40
41 # Wait for the cache to expire, see debian/tests/testapp.py
42 sleep 10
43
44 # This response is not cached.
45 curl http://127.0.0.1:5000/ 2>&1 | grep '^counter=2$'
46
47 # This one is.
48 curl http://127.0.0.1:5000/ 2>&1 | grep '^counter=2$'
49
50 # Cleanup post each test
51 cleanup
52 done