aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_api_edge.py
blob: f6638341308d2f405c094c9b430ef5ab768258d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import requests

BASE = "https://jsonplaceholder.typicode.com"

def test_get_posts_filter_by_userid():
    r = requests.get(f"{BASE}/posts?userId=1")
    assert r.status_code == 200
    for post in r.json():
        assert post["userId"] == 1

def test_patch_post_partial_update():
    payload = {"title": "updated by qa"}
    r = requests.patch(f"{BASE}/posts/1", json=payload)
    assert r.status_code == 200
    assert r.json()["title"] == "updated by qa"

def test_delete_post_status_200():
    r = requests.delete(f"{BASE}/posts/1")
    assert r.status_code == 200

def test_get_comments_by_postid():
    r = requests.get(f"{BASE}/comments?postId=1")
    assert r.status_code == 200
    assert len(r.json()) > 0