2022-11-21 17:08:03 +03:00
|
|
|
# In each request, we sent a multiline body and get
|
|
|
|
# the same body as response. Request body is tested server side
|
|
|
|
# and we assert the response here.
|
|
|
|
|
|
|
|
POST http://localhost:8000/multilines/plain-text
|
|
|
|
```
|
|
|
|
line1
|
|
|
|
line2
|
|
|
|
line3
|
|
|
|
```
|
2022-11-15 14:00:29 +03:00
|
|
|
|
2022-11-11 16:25:00 +03:00
|
|
|
HTTP 200
|
2022-11-21 17:08:03 +03:00
|
|
|
# Different ways of testing body response:
|
|
|
|
# with explicit asserts:
|
2021-07-01 21:02:47 +03:00
|
|
|
[Asserts]
|
|
|
|
body == "line1\nline2\nline3\n"
|
|
|
|
body == ```
|
|
|
|
line1
|
|
|
|
line2
|
|
|
|
line3
|
|
|
|
```
|
2022-11-21 17:08:03 +03:00
|
|
|
# Or we can just test the body (implicit assert):
|
2022-11-15 14:00:29 +03:00
|
|
|
```
|
2022-11-21 17:08:03 +03:00
|
|
|
line1
|
|
|
|
line2
|
|
|
|
line3
|
2022-11-15 14:00:29 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
|
2022-11-21 17:08:03 +03:00
|
|
|
POST http://localhost:8000/multilines/json
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"foo": "bar"
|
|
|
|
"baz": 123456
|
|
|
|
}
|
|
|
|
```
|
2022-11-15 14:00:29 +03:00
|
|
|
|
|
|
|
HTTP 200
|
2022-11-21 17:08:03 +03:00
|
|
|
# Different ways of testing body response:
|
|
|
|
# with explicit asserts:
|
|
|
|
[Asserts]
|
|
|
|
body == "{\n \"foo\": \"bar\"\n \"baz\": 123456\n}\n"
|
|
|
|
body == ```json
|
|
|
|
{
|
|
|
|
"foo": "bar"
|
|
|
|
"baz": 123456
|
|
|
|
}
|
|
|
|
```
|
|
|
|
# Or we can just test the body (implicit assert):
|
2022-11-15 14:00:29 +03:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"foo": "bar"
|
|
|
|
"baz": 123456
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2022-11-21 17:08:03 +03:00
|
|
|
|
|
|
|
POST http://localhost:8000/multilines/xml
|
|
|
|
```xml
|
|
|
|
<?xml version="1.0"?>
|
|
|
|
<catalog>
|
|
|
|
<book id="bk101">
|
|
|
|
<author>Gambardella, Matthew</author>
|
|
|
|
<title>XML Developer's Guide</title>
|
|
|
|
<genre>Computer</genre>
|
|
|
|
<price>44.95</price>
|
|
|
|
<publish_date>2000-10-01</publish_date>
|
|
|
|
<description>An in-depth look at creating applications
|
|
|
|
with XML.</description>
|
|
|
|
</book>
|
|
|
|
</catalog>
|
|
|
|
```
|
2022-11-15 14:00:29 +03:00
|
|
|
|
|
|
|
HTTP 200
|
2022-11-21 17:08:03 +03:00
|
|
|
# Different ways of testing body response:
|
|
|
|
# with explicit asserts:
|
|
|
|
[Asserts]
|
|
|
|
body == "<?xml version=\"1.0\"?>\n<catalog>\n <book id=\"bk101\">\n <author>Gambardella, Matthew</author>\n <title>XML Developer's Guide</title>\n <genre>Computer</genre>\n <price>44.95</price>\n <publish_date>2000-10-01</publish_date>\n <description>An in-depth look at creating applications\n with XML.</description>\n </book>\n</catalog>\n"
|
|
|
|
body == ```xml
|
|
|
|
<?xml version="1.0"?>
|
|
|
|
<catalog>
|
|
|
|
<book id="bk101">
|
|
|
|
<author>Gambardella, Matthew</author>
|
|
|
|
<title>XML Developer's Guide</title>
|
|
|
|
<genre>Computer</genre>
|
|
|
|
<price>44.95</price>
|
|
|
|
<publish_date>2000-10-01</publish_date>
|
|
|
|
<description>An in-depth look at creating applications
|
|
|
|
with XML.</description>
|
|
|
|
</book>
|
|
|
|
</catalog>
|
|
|
|
```
|
|
|
|
# Or we can just test the body (implicit assert):
|
2022-11-15 14:00:29 +03:00
|
|
|
```xml
|
|
|
|
<?xml version="1.0"?>
|
|
|
|
<catalog>
|
2022-11-21 17:08:03 +03:00
|
|
|
<book id="bk101">
|
|
|
|
<author>Gambardella, Matthew</author>
|
|
|
|
<title>XML Developer's Guide</title>
|
|
|
|
<genre>Computer</genre>
|
|
|
|
<price>44.95</price>
|
|
|
|
<publish_date>2000-10-01</publish_date>
|
|
|
|
<description>An in-depth look at creating applications
|
|
|
|
with XML.</description>
|
|
|
|
</book>
|
2022-11-15 14:00:29 +03:00
|
|
|
</catalog>
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-11-21 17:08:03 +03:00
|
|
|
POST http://localhost:8000/multilines/graphql
|
|
|
|
```graphql
|
|
|
|
{
|
|
|
|
hero {
|
|
|
|
name
|
|
|
|
# Queries can have comments!
|
|
|
|
friends {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
2022-11-15 14:00:29 +03:00
|
|
|
HTTP 200
|
2022-11-21 17:08:03 +03:00
|
|
|
# Different ways of testing body response:
|
|
|
|
# with explicit asserts:
|
|
|
|
[Asserts]
|
2022-11-24 18:14:44 +03:00
|
|
|
body == "{\"query\":\"{\\n hero {\\n name\\n # Queries can have comments!\\n friends {\\n name\\n }\\n }\\n}\"}"
|
2022-11-21 17:08:03 +03:00
|
|
|
body == ```graphql
|
|
|
|
{
|
|
|
|
hero {
|
|
|
|
name
|
|
|
|
# Queries can have comments!
|
|
|
|
friends {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
# Or we can just test the body (implicit assert):
|
2022-11-15 14:00:29 +03:00
|
|
|
```graphql
|
|
|
|
{
|
|
|
|
hero {
|
|
|
|
name
|
|
|
|
# Queries can have comments!
|
|
|
|
friends {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|