Skip to content

Commit af88107

Browse files
committed
Merge branch 'master' into feature-extensionloading
2 parents c68e48e + 6c0b674 commit af88107

5 files changed

+75
-14
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ sudo yum install rpm-build
490490
## Why not pure-python tests?
491491
- This is written for an environment where Python is not the sole or primary langauge
492492
- **You totally can do pure-Python tests if you want!**
493-
- Gotcha: I will break back compatibility of the implementation often and badly, at least at first
493+
- Gotcha: the project is still young, so internal implementation may change often, much more than YAML features
494+
- Extensions are intended specifically for adding functionality, they will be the most stable part
494495
- Read before you assume: template handling is more complex than you think.
495496
- Framework run/execute methods in pyresttest/resttest.py do *quite* a bit of heavy lifting
496497

advanced_guide.md

+65-12
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,71 @@ To demonstrate static variable binding, this does binding for both first and las
5959
Currently, templating is only supported for the request body and URL.
6060
There are technical challenges adding it everywhere, but plans to add it where needed to other options.
6161

62+
# Generators Listing
63+
List of all generators and their configuration elements (required, optional, and meaning).
64+
65+
| Description | Name (in YAML): | Output Type | Parameters |
66+
|----------------------------------------------------------------|-----------------|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
67+
| Environment Variable | env_variable | any | required: 'variable_name', type: string (environment variable to use, no $ or % prefix) |
68+
| Environment String, with variable subsitution | env_string | string | required: 'string', type: string with env variables to substitute |
69+
| Integer sequence | number_sequence | integer | optional: 'start', type: integer, default: 1 optional: 'increment', type: integer, default 1 |
70+
| Integer - Random (32 bit) | random_int | integer | |
71+
| Text - Random | random_test | string | optional: 'character set' OR 'characters', type: string, default: string.ascii_letters optional: 'min_length', type: integer, default: 8 optional: 'max_length', type: integer, default: 8 optional: 'length', (can either have length or min/min), type integer |
72+
| Choice of random values from input list | choice | any | required: 'values', type: array of anything |
73+
| Sequence of values from input list of values, looping in order | fixed_sequence | any | required: 'values, type: array of anything | |
74+
75+
## Additional Details For Generators
76+
### env_variable: explanation
77+
The variable name is used to lookup the environment variable.
78+
For example, if you used $HOST in a shellscript, the 'variable_name' value for the generator would be 'HOST'
79+
80+
### env_string: explanation
81+
This is a string substitution with potentially multiple environment variables used.
82+
BASH: `echo "$USER logged into $HOSTNAME"`
83+
becomes generator:
84+
```yaml
85+
{type: 'env_string', 'string': "$USER logged into $HOSTNAME"}
86+
```
87+
88+
### random_text: explanation
89+
This generates strings of random characters.
90+
All it needs is the:
91+
- legal length ranges:
92+
+ a 'length' sets it to a constant, fixed length
93+
+ a 'min_length' and 'max_length' allow it to be randomly size, in that range
94+
95+
- valid characters to use, defined one of two ways:
96+
+ a 'characters': you supply a list of valid characters to use, as a string
97+
+ a 'character_set': a named character set of values, see below for table
98+
99+
### Character Sets Reference
100+
Python internal character sets come from the [String constants](https://docs.python.org/2/library/string.html#string-constants) in the string module.
101+
102+
**Reference:**
103+
104+
| Description | Text Name | Source |
105+
|-------------------------------------------------------------------|--------------------|-----------------------------------------------|
106+
| ASCII Letters, upper and lowercase, no whitespace | ascii_letters | Python internal |
107+
| ASCII Letters, lowercase, no whitespace | ascii_lowercase | Python internal |
108+
| ASCII Letters, uppercase only, no whitespace | ascii_uppercase | Python internal |
109+
| Digits, 0-9 | digits | Python internal |
110+
| Hexadecimal digits, mixed upper and lowercase | hexdigits | Python internal |
111+
| Hexadecimal digits, all lowercase | hex_lower | string.digits+abcdef, |
112+
| Hexadecimal digits, all uppercase | hex_upper | string.digits+ABCDEF, |
113+
| Letters | letters | Python internal, locale-dependent |
114+
| Lowercase letters | lowercase | Python internal, locale-dependent |
115+
| Octal digits (0-7) | octdigits | Python internal |
116+
| Punctuation characters, pipe plus !"#$%&'()*+,-./:;<=>?@[\]^_`{}~ | punctuation | Python internal |
117+
| All printable characters, includes whitespace | printable | Python internal, locale-dependent |
118+
| Uppercase letters | uppercase | Python internal, locale-dependent |
119+
| Whitespace characters | whitespace | Python internal, locale-dependent |
120+
| URL Slug characters (lowercase ASCII and dashes) | url.slug | string.ascii_lowercase + string.digits + '-' |
121+
| URL Safe (unreserved characters from RFC3986) | url.safe | string.ascii_letters + string.digits + '-~_.' |
122+
| Alphanumeric | alphanumeric | string.ascii_letters + string.digits |
123+
| Alphanumeric, lowercase only | alphanumeric_lower | string.ascii_lowercase + string.digits |
124+
| Alphanumeric, uppercase only | alphanumeric_upper | string.ascii_uppercase + string.digits |
125+
126+
62127
# Extractors Basics
63128
Extractors are query-based ways to extract some part of an HTTP response body for use.
64129

@@ -229,16 +294,4 @@ Optionally, validators can return a ValidationFailure which evaluates to False,
229294
* Benchmarks track a static failure count, to account for network issues
230295
* Benchmarks will try to optimize out as much templating as they can safely.
231296
232-
# Generators Listing
233-
List of all generators and their configuration elements (required, optional, and meaning).
234-
235-
## env_variable
236-
Read an environment variable
237-
238-
### Configuration elements:
239-
- variable_name: environment variable name, without prefix
240-
241-
### Example:
242-
Example here
243-
244297

pyresttest/generators.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@
2929
'punctuation': string.punctuation,
3030
'printable': string.printable,
3131
'uppercase': string.uppercase,
32-
'whitespace': string.whitespace
32+
'whitespace': string.whitespace,
33+
'url.slug': string.ascii_lowercase+string.digits+'-',
34+
'url.safe': string.ascii_letters+string.digits+'-~_.',
35+
'alphanumeric': string.ascii_letters + string.digits,
36+
'alphanumeric_lower': string.ascii_lowercase + string.digits,
37+
'alphanumeric_upper': string.ascii_uppercase + string.digits
3338
}
3439

3540
def factory_generate_ids(starting_id=1, increment=1):

0 commit comments

Comments
 (0)