File: test_api.py

package info (click to toggle)
httpcore 1.0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 868 kB
  • sloc: python: 9,383; sh: 101; makefile: 41
file content (20 lines) | stat: -rw-r--r-- 521 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import json

import httpcore


def test_request(httpbin):
    response = httpcore.request("GET", httpbin.url)
    assert response.status == 200


def test_stream(httpbin):
    with httpcore.stream("GET", httpbin.url) as response:
        assert response.status == 200


def test_request_with_content(httpbin):
    url = f"{httpbin.url}/post"
    response = httpcore.request("POST", url, content=b'{"hello":"world"}')
    assert response.status == 200
    assert json.loads(response.content)["json"] == {"hello": "world"}