1
- # FlaskTester - fixtures for Flask internal and external pytest tests
1
+ # FlaskTester - Pytest fixtures for Flask internal and external tests
2
2
3
3
This package allows to run authenticated tests against a Flask application,
4
4
either with internal Flask tests (aka ` test_client ` ) or external tests (with
@@ -7,6 +7,15 @@ either with internal Flask tests (aka `test_client`) or external tests (with
7
7
Only one set of tests is needed, switching from internal to external is
8
8
achieved through environment variables.
9
9
10
+ ![ Status] ( https://github.com/zx80/flask-tester/actions/workflows/package.yml/badge.svg?branch=master&style=flat )
11
+ ![ Tests] ( https://img.shields.io/badge/tests-2%20✓-success )
12
+ ![ Coverage] ( https://img.shields.io/badge/coverage-0%25-success )
13
+ ![ Issues] ( https://img.shields.io/github/issues/zx80/flask-tester?style=flat )
14
+ ![ Python] ( https://img.shields.io/badge/python-3-informational )
15
+ ![ Version] ( https://img.shields.io/pypi/v/FlaskTester )
16
+ ![ Badges] ( https://img.shields.io/badge/badges-8-informational )
17
+ ![ License] ( https://img.shields.io/pypi/l/flasktester?style=flat )
18
+
10
19
## Fixtures
11
20
12
21
The package provides two fixtures:
@@ -51,12 +60,16 @@ assigning them through `os.environ`.
51
60
52
61
## Classes
53
62
54
- The implementation of these fixtures is based on four classes:
63
+ The implementation of these fixtures is based on five classes:
55
64
56
65
- ` Authenticator ` class to store test credentials.
57
66
58
67
Use ` setPass ` and ` setToken ` to add user credentials.
59
68
69
+ - ` RequestFlaskResponse ` class to turn a ` requests ` response into
70
+ a Flask-looking response, with the following attributes: ` status_code ` ,
71
+ ` data ` , ` text ` , ` headers ` , ` cookies ` , ` is_json ` and ` json ` .
72
+
60
73
- ` Client ` abstract class to run test, with two implementations.
61
74
62
75
The class provides usual ` get ` , ` post ` … per-HTTP-method methods,
@@ -69,21 +82,30 @@ The implementation of these fixtures is based on four classes:
69
82
otherwise allowed schemes are tried, with tokens first.
70
83
- ` status ` for the expected HTTP status code.
71
84
85
+ For the check methods, the mandatory parameters are the method, the path
86
+ and the expected status.
87
+
72
88
- ` FlaskClient ` implementation class for internal tests.
89
+
90
+ This class is mostly the standard ` test_client ` with the above parameters
91
+ extensions.
92
+
73
93
- ` RequestClient ` implementation class for external (real HTTP) tests.
74
94
95
+ The path is relative to the URL provided to the constructor.
96
+
97
+
75
98
## TODO
76
99
77
100
- API documentation generation
78
101
- coverage tests
79
- - useless but decorative badges
80
- - pypi distribution
81
102
82
103
## Versions
83
104
84
105
### 0.10 on ?
85
106
86
107
Add ` FLASK_TESTER_DEFAULT ` environment configuration to ` ft_client ` .
108
+ Improve documentation, including incredible badges.
87
109
88
110
### 0.9 on 2024-03-11
89
111
0 commit comments