Commit Graph

87 Commits

Author SHA1 Message Date
Andrei Zeliankou
c183bd8749 Tests: get rid of classes in test files.
Class usage came from the unittest framework and it was always redundant
after migration to the pytest.  This commit removes classes from files
containing tests to make them more readable and understandable.
2023-06-14 18:20:09 +01:00
Andrei Zeliankou
ce2405ec3d Tests: prerequisites checking reworked.
Prerequisites check moved to the module level to simplify class structure.
Discovery and prerequisites checks functions moved to the separate files.
Introduced "require" fixture to provide per-test requirements check.
2023-06-12 14:16:59 +01:00
Andrei Zeliankou
31ff94add9 Tests: more fixtures.
Common methods from applications/proto.py converted to the fixtures.
sysctl check moved to the specific file where it is using.
Some options moved to the constructor to have early access.
2023-05-29 16:45:49 +01:00
Andrei Zeliankou
3e4fa1e202 Tests: removed unused variables. 2023-05-25 14:26:12 +01:00
Andrei Zeliankou
7934dcabbc Tests: switched to using f-strings.
Previously, it was necessary to support older versions of Python for
compatibility.  F-strings were released in Python 3.6.  Python 3.5 was
marked as unsupported by the end of 2020, so now it's possible to start
using f-strings safely for better readability and performance.
2023-02-21 17:21:29 +00:00
Andrei Zeliankou
fcabbf09d8 Tests: added Python tests with encoding. 2023-02-21 15:35:38 +00:00
OutOfFocus4
6dae517ebd Python: Added "prefix" to configuration.
This patch gives users the option to set a `"prefix"` attribute
for Python applications, either at the top level or for specific
`"target"`s. If the attribute is present, the value of `"prefix"`
must be a string beginning with `"/"`. If the value of the `"prefix"`
attribute is longer than 1 character and ends in `"/"`, the
trailing `"/"` is stripped.

The purpose of the `"prefix"` attribute is to set the `SCRIPT_NAME`
context value for WSGI applications and the `root_path` context
value for ASGI applications, allowing applications to properly route
requests regardless of the path that the server uses to expose the
application.

The context value is only set if the request's URL path begins with
the value of the `"prefix"` attribute. In all other cases, the
`SCRIPT_NAME` or `root_path` values are not set. In addition, for
WSGI applications, the value of `"prefix"` will be stripped from
the beginning of the request's URL path before it is sent to the
application.

Reviewed-by: Andrei Zeliankou <zelenkov@nginx.com>
Reviewed-by: Artem Konev <artem.konev@nginx.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-12-14 11:30:30 +01:00
Andrei Zeliankou
8e1e047191 Tests: don't try to return response when "no_recv" is True. 2022-10-11 13:49:10 +01:00
Andrei Zeliankou
c65e04682e Tests: minor fixes. 2022-09-07 01:11:04 +01:00
Andrei Zeliankou
03a7701133 Tests: added more tests with reconfiguration. 2022-05-09 10:14:29 +01:00
Andrei Zeliankou
0f72534660 Tests: style. 2022-04-11 21:05:14 +01:00
Andrei Zeliankou
39adb292d5 Tests: style. 2021-10-18 01:10:11 +01:00
Max Romanov
74b1b1fc17 Tests: preserving unit.log when run without restart.
Introducing "unit.log.Log" class for "unit.log" file management.
Moving "findall()" function into TestApplicationProto.
Using "os.kill()" to send signals.
2021-04-08 19:11:11 +03:00
Andrei Zeliankou
6c97a1a069 Tests: style. 2021-04-05 14:03:05 +01:00
Andrei Zeliankou
11f7d833a9 Tests: increased timeout in wait_for_record(). 2021-02-10 16:34:37 +00:00
Andrei Zeliankou
42725137f7 Tests: added tests for "path" option in Python application. 2021-02-04 15:09:54 +00:00
Andrei Zeliankou
d43a84139d Tests: added missing checks for configuration results. 2021-01-14 03:04:20 +00:00
Andrei Zeliankou
6dc9c47ccd Tests: style. 2021-01-13 06:22:43 +00:00
Andrei Zeliankou
f5ac143246 Tests: unit_stop() removed where possible.
Since wait_for_record() was introduced there is no need
to stop Unit before parsing unit.log.
2021-01-12 06:20:23 +00:00
Andrei Zeliankou
b2e767819f Tests: skip_alert() converted to the fixture. 2020-12-08 14:37:33 +00:00
Andrei Zeliankou
07789a23e9 Tests: options moved to the separate class.
This change is necessary to separate the logic
and prevent possible circular dependency.
2020-12-06 16:01:59 +00:00
Max Romanov
567f0a7b30 Tests: fixing tests interrupt in terminal.
KeyboardInterrupt re-raised.
2020-11-16 20:37:01 +03:00
Max Romanov
a8a9d80f8d Tests: supporting instant app parameters in load(). 2020-11-10 22:27:08 +03:00
Max Romanov
f27953af61 Tests: added Python threading tests. 2020-11-05 00:05:02 +03:00
Andrei Zeliankou
54837759f3 Tests: fixed unit.log print. 2020-10-19 22:25:29 +01:00
Andrei Zeliankou
6ec0ff3596 Tests: minor fixes. 2020-10-07 23:18:43 +01:00
Max Romanov
449652afa1 Tests: added multiple headers concatenation test. 2020-09-21 21:18:13 +03:00
Max Romanov
af964488ba Tests: changing Python application callable name. 2020-09-21 10:32:14 +03:00
Andrei Zeliankou
d5e9159340 Tests: migrated to the pytest. 2020-09-16 21:31:15 +01:00
Andrei Zeliankou
8032686a57 Tests: added test with error on loading application. 2020-08-13 13:17:27 +01:00
Andrei Zeliankou
ce4a2bbd05 Tests: style. 2020-05-15 04:20:56 +01:00
Andrei Zeliankou
6a9a4fe0d4 Tests: introduced module version specification in prerequisites. 2020-04-24 05:08:56 +01:00
Andrei Zeliankou
3c58a4bfc1 Tests: added test with rescheduling requests. 2020-04-14 03:02:16 +01:00
Andrei Zeliankou
0bfa09dfa0 Tests: minor fixes and style. 2020-04-14 02:35:04 +01:00
Max Romanov
f3e6726098 Tests: added Python input readline and iterator tests. 2020-03-12 17:54:15 +03:00
Tiago Natel
c6a11260e8 Tests: added tests for setting user and group. 2019-11-11 14:36:22 +00:00
Tiago Natel
01103c5005 Tests: parsing of "Transfer-Encoding: chunked" responses. 2019-11-26 15:58:25 +00:00
Andrei Zeliankou
1072c94829 Tests: Python exception tests. 2019-11-14 18:46:28 +03:00
Andrei Zeliankou
45d75ee2cb Tests: added Python test with threading. 2019-11-13 16:51:12 +03:00
Andrey Zelenkov
13b4538fc7 Tests: added test with invalid "working_directory" value. 2019-10-23 16:59:53 +03:00
Valentin Bartenev
6352c21a58 HTTP parser: fixed parsing of target after literal space character.
In theory, all space characters in request target must be encoded; however,
some clients may violate the specification.  For the sake of interoperability,
Unit supports unencoded space characters.

Previously, if there was a space character before the extension or arguments
parts, those parts weren't recognized.  Also, quoted symbols and complex
target weren't detected after a space character.
2019-09-17 18:40:21 +03:00
Andrey Zelenkov
65ca2d7b19 Tests: refactored prerequisites model. 2019-09-14 14:44:35 +03:00
Andrey Zelenkov
90c5d3f5c0 Tests: adjusted skipping tests. 2019-05-30 16:46:04 +03:00
Andrey Zelenkov
5d15d8449d Tests: read_timeout increased for incomplete requests.
Also fixed test without \"Host\" header.
2019-04-22 18:52:35 +03:00
Andrey Zelenkov
29b4e4431f Tests: speed up tests. 2019-04-09 20:59:35 +03:00
Andrey Zelenkov
549f0873c2 Tests: wait_for_record() introduced. 2019-04-09 16:14:42 +03:00
Andrey Zelenkov
8c7411415a Tests: style. 2019-04-09 16:14:42 +03:00
Andrey Zelenkov
af24e4dec4 Tests: simplified module checking. 2019-04-09 16:14:42 +03:00
Andrey Zelenkov
19eba1730a Tests: unit module refactoring. 2019-03-28 18:43:13 +03:00
Andrey Zelenkov
281899fcef Tests: style. 2019-03-26 23:38:30 +03:00