|
2 | 2 | PyRestTest provides hooks for extending built-in components with your own Python code.
|
3 | 3 |
|
4 | 4 | # What Can An Extension Do?
|
| 5 | + |
| 6 | +- In general: use more advanced dependencies while not making them required for installation |
5 | 7 | - Generators: generate data for templating URL/request body/tests/etc
|
6 |
| -- Extractors: get data from HTTP response body/headers |
7 |
| -- Validators: write custom tests of headers & request bodies |
| 8 | +- Extractors: get data from HTTP response body/headers and use it in future tests |
| 9 | +- Validators: write custom tests using headers & response bodies |
8 | 10 | - Test Functions: for the ExtractTest validator, validate a single condition
|
9 | 11 | - Comparator function:s for the ComparatorValidator, compare expected and actual values
|
10 | 12 |
|
@@ -49,8 +51,8 @@ It shows an extension for all extensible functions.
|
49 | 51 |
|
50 | 52 | # What Doe An Extension Need To Work?
|
51 | 53 |
|
52 |
| -1. Function to run |
53 |
| -2. Registry Entries |
| 54 | +1. Function(s) to run |
| 55 | +2. Registry Entries: these are special ALLCAPS variables binding extension names |
54 | 56 |
|
55 | 57 | ## Functions (different for each type)
|
56 | 58 |
|
@@ -128,7 +130,7 @@ class HeaderExtractor(AbstractExtractor):
|
128 | 130 |
|
129 | 131 | ### Validators
|
130 | 132 | Validators should extend AbstractValidator.
|
131 |
| -The parse function below will be registered in the registry. |
| 133 | +The parse function below will be registered in the registry VALIDATORS. |
132 | 134 |
|
133 | 135 | ```python
|
134 | 136 | class ExtractTestValidator(AbstractValidator):
|
@@ -187,7 +189,7 @@ Each one maps to the same registry in pyresttest.validators.
|
187 | 189 |
|
188 | 190 | # Use Case Suggestions
|
189 | 191 | - **Need to generate complex, formatted data?**
|
190 |
| - - Write a generator extension, multiple generators may be used together to yield pieces of a result. |
| 192 | + - Write a generator extension, or multiple generators may be used together to create a complex result |
191 | 193 | - **Want to test whether API results fit a business rule?**
|
192 | 194 | - Write a validator extension, your logic can be as complex as you like
|
193 | 195 | - **Want to apply a business rule to the output and use the result?**
|
|
0 commit comments