Update test script for comprehensive testing
This commit is contained in:
parent
da13778063
commit
25a2e6f7cc
20
test_api.py
20
test_api.py
|
|
@ -53,6 +53,26 @@ def test_custom():
|
||||||
print(f"Error: {data['Error']}")
|
print(f"Error: {data['Error']}")
|
||||||
|
|
||||||
|
|
||||||
|
def test_include_comments_false():
|
||||||
|
"""Test that include_comments=false skips comment extraction."""
|
||||||
|
url = "http://localhost:8000/scrape/subreddit/python"
|
||||||
|
params = {"limit": 1, "time_range": "week", "include_comments": False}
|
||||||
|
|
||||||
|
response = requests.get(url, params=params)
|
||||||
|
print("\n=== Include Comments=False Test ===")
|
||||||
|
data = response.json()
|
||||||
|
if "Error" not in data:
|
||||||
|
print(f"Request with include_comments=false successful")
|
||||||
|
print(f"Posts found: {data['posts_count']}")
|
||||||
|
if data.get('data'):
|
||||||
|
post = data['data'][0]
|
||||||
|
has_comments = 'comments' in post and len(post['comments']) > 0
|
||||||
|
print(f"Has comments field: {'comments' in post}")
|
||||||
|
print(f"Comments empty: {not has_comments}")
|
||||||
|
else:
|
||||||
|
print(f"Error: {data['Error']}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
test_health()
|
test_health()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue