|
| 1 | +from src.pyspiget.spiget import Spiget, SpigetError |
| 2 | + |
| 3 | +def main(): |
| 4 | + spiget = Spiget() |
| 5 | + |
| 6 | + try: |
| 7 | + # Test get_status |
| 8 | + status = spiget.get_status() |
| 9 | + print("API Status:", status) |
| 10 | + |
| 11 | + # Test get_resources |
| 12 | + resources = spiget.get_resources(size=1) |
| 13 | + print("Resources:", resources) |
| 14 | + if resources: |
| 15 | + resource_id = resources[0].id |
| 16 | + |
| 17 | + # Test get_resource |
| 18 | + resource = spiget.get_resource(resource_id) |
| 19 | + print("Resource:", resource) |
| 20 | + |
| 21 | + # Test get_resource_versions |
| 22 | + resource_versions = spiget.get_resource_versions(resource_id, size=1) |
| 23 | + print("Resource Versions:", resource_versions) |
| 24 | + if resource_versions: |
| 25 | + version_id = resource_versions[0].id |
| 26 | + |
| 27 | + # Test get_resource_version |
| 28 | + resource_version = spiget.get_resource_version(resource_id, version_id) |
| 29 | + print("Resource Version:", resource_version) |
| 30 | + |
| 31 | + # Test get_resource_latest_version |
| 32 | + latest_version = spiget.get_resource_latest_version(resource_id) |
| 33 | + print("Latest Resource Version:", latest_version) |
| 34 | + |
| 35 | + # Test get_resource_updates |
| 36 | + resource_updates = spiget.get_resource_updates(resource_id, size=1) |
| 37 | + print("Resource Updates:", resource_updates) |
| 38 | + |
| 39 | + # Test get_resource_reviews |
| 40 | + resource_reviews = spiget.get_resource_reviews(resource_id, size=1) |
| 41 | + print("Resource Reviews:", resource_reviews) |
| 42 | + |
| 43 | + # Test get_resource_author |
| 44 | + resource_author = spiget.get_resource_author(resource_id) |
| 45 | + print("Resource Author:", resource_author) |
| 46 | + |
| 47 | + # Test get_authors |
| 48 | + authors = spiget.get_authors(size=5) |
| 49 | + print("Authors:", authors) |
| 50 | + if authors: |
| 51 | + author_id = authors[1].id # The first author is empty with id of -1 and name of "...", so we use the second one |
| 52 | + |
| 53 | + # Test get_author |
| 54 | + author = spiget.get_author(author_id) |
| 55 | + print("Author:", author) |
| 56 | + |
| 57 | + # Test get_author_resources |
| 58 | + author_resources = spiget.get_author_resources(author_id, size=1) |
| 59 | + print("Author Resources:", author_resources) |
| 60 | + |
| 61 | + # Test get_categories |
| 62 | + categories = spiget.get_categories(size=1) |
| 63 | + print("Categories:", categories) |
| 64 | + if categories: |
| 65 | + category_id = categories[0].id |
| 66 | + |
| 67 | + # Test get_category |
| 68 | + category = spiget.get_category(category_id) |
| 69 | + print("Category:", category) |
| 70 | + |
| 71 | + # Test get_category_resources |
| 72 | + category_resources = spiget.get_category_resources(category_id, size=1) |
| 73 | + print("Category Resources:", category_resources) |
| 74 | + |
| 75 | + # Test search_resources |
| 76 | + search_resources = spiget.search_resources(query="plugin", size=1) |
| 77 | + print("Search Resources:", search_resources) |
| 78 | + |
| 79 | + # Test search_authors |
| 80 | + search_authors = spiget.search_authors(query="author", size=1) |
| 81 | + print("Search Authors:", search_authors) |
| 82 | + |
| 83 | + except SpigetError as e: |
| 84 | + print("An error occurred:", e) |
| 85 | + |
| 86 | + |
| 87 | +# Run from repo root with `PYTHONPATH=. python3 src/tests/manual_testing.py` |
| 88 | +if __name__ == "__main__": |
| 89 | + main() |
0 commit comments