Spaces:
Sleeping
Sleeping
File size: 3,446 Bytes
db020d5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
#!/usr/bin/env python3
"""
Test script to verify the wiki_service.py API functions are working correctly.
Run this script to check if all API functions return the expected data structures.
"""
from services import wiki_service
def test_api_functions():
"""Test all API functions and print results"""
print("Testing wiki_service.py API functions...")
# Test search_wiki
print("\n1. Testing search_wiki()...")
search_results = wiki_service.search_wiki("cardio exercise")
print(f" Success: {search_results['success']}")
print(f" Results found: {len(search_results['results'])}")
# Test get_article_details
print("\n2. Testing get_article_details()...")
article_details = wiki_service.get_article_details("Physical exercise")
print(f" Title: {article_details.get('title', 'Not found')}")
print(f" Extract length: {len(article_details.get('extract', ''))}")
# Test get_featured_content
print("\n3. Testing get_featured_content()...")
featured = wiki_service.get_featured_content()
print(f" Article title: {featured['article_of_the_day']['title']}")
print(f" Facts provided: {len(featured['did_you_know'])}")
# Test search_fitness_exercise
print("\n4. Testing search_fitness_exercise()...")
exercise = wiki_service.search_fitness_exercise("squats")
print(f" Found: {exercise.get('found', False)}")
print(f" Title: {exercise.get('title', 'Not found')}")
# Test get_nutrition_information
print("\n5. Testing get_nutrition_information()...")
nutrition = wiki_service.get_nutrition_information("protein")
print(f" Found: {nutrition.get('found', False)}")
print(f" Title: {nutrition.get('title', 'Not found')}")
# Test get_fitness_category_articles
print("\n6. Testing get_fitness_category_articles()...")
category = wiki_service.get_fitness_category_articles("Physical_exercise")
print(f" Category: {category.get('category', 'Unknown')}")
print(f" Articles found: {category.get('count', 0)}")
# Test get_exercise_comparison
print("\n7. Testing get_exercise_comparison()...")
comparison = wiki_service.get_exercise_comparison("cardio")
print(f" Exercise type: {comparison.get('exercise_type', 'Unknown')}")
print(f" Comparison items: {comparison.get('count', 0)}")
# Test get_latest_fitness_research
print("\n8. Testing get_latest_fitness_research()...")
research = wiki_service.get_latest_fitness_research()
print(f" Topic: {research.get('topic', 'Unknown')}")
print(f" Articles found: {research.get('count', 0)}")
# Test get_workout_plan_by_goal
print("\n9. Testing get_workout_plan_by_goal()...")
workout = wiki_service.get_workout_plan_by_goal("strength")
print(f" Goal: {workout.get('goal', 'Unknown')}")
print(f" Title: {workout.get('title', 'Unknown')}")
print(f" Days in plan: {len(workout.get('days', []))}")
# Test search_fitness_remedy
print("\n10. Testing search_fitness_remedy()...")
remedy = wiki_service.search_fitness_remedy("back pain")
print(f" Ailment: {remedy.get('ailment', 'Unknown')}")
print(f" Found: {remedy.get('found', False)}")
print(f" Remedies: {len(remedy.get('remedies', []))}")
print(f" Exercises: {len(remedy.get('exercises', []))}")
print("\nAll tests completed!")
if __name__ == "__main__":
test_api_functions()
|