def test_existing_site(): site_id = V.existing_site_id r = requests.get(api_url + f"/stats?site_id={site_id}", headers=auth_header) assert_valid_response(r, V.result_fields) assert len(r.json()["result"]) <= 30 assert set([x["site_id"] for x in r.json()["result"]]) == {site_id}
def test_existing_urls(): urls = V.existing_urls for u in urls: r = requests.get(api_url + f"/articles?url={u}", headers=auth_header) assert_valid_response(r, V.result_fields) for article in r.json()["result"]: normalized_u = url_normalize(u) assert (article["url"] == normalized_u or article["redirect_to"] == normalized_u)
def test_existing_site_id(): site_id = V.existing_site_id r = requests.get(api_url + f"/sites/{site_id}", headers=auth_header) assert_valid_response(r, V.result_fields, dict_result=True) r = requests.get(api_url + f"/sites/{site_id}/article_count", headers=auth_header) assert_valid_response(r, result_fields={"site", "article_count"}, dict_result=True) result = r.json()["result"] assert isinstance(result["article_count"], int) assert isinstance(result["site"], dict) r = requests.get(api_url + f"/sites/{site_id}/latest_article", headers=auth_header) assert_valid_response(r, result_fields={"site", "latest_article"}, dict_result=True) result = r.json()["result"] assert isinstance(result["latest_article"], dict) assert isinstance(result["site"], dict)
def test_get_active_sites(): r = requests.get(api_url + f"/sites/active", headers=auth_header) assert_valid_response(r, V.result_fields) assert {x["is_active"] for x in r.json()["result"]} == {1}
def test_route(): r = requests.get(api_url + f"/sites", headers=auth_header) assert_valid_response(r, V.result_fields)
def test_date_with_stats(): date = V.date_with_stats r = requests.get(api_url + f"/stats?date={date}", headers=auth_header) assert_valid_response(r, V.result_fields) assert set([x["date"] for x in r.json()["result"]]) == {date}
def test_existing_id(): article_id = V.existing_article_id r = requests.get(api_url + f"/articles/{article_id}", headers=auth_header) assert_valid_response(r, V.result_fields, dict_result=True)
def test_route(): r = requests.get(api_url + f"/articles", headers=auth_header) assert_valid_response(r, V.result_fields) assert len(r.json()["result"]) == 10