ontocast.cli.test_api¶
Test API client for OntoCast.
This module provides a simple command-line client for testing the OntoCast API. It can send requests to the API server with either a default payload, a JSON file, or a PDF file.
The client supports: - Custom server URLs - JSON or PDF file uploads - Default test payload for Apple 10-Q document - Response formatting and display
Example
Send default test payload¶
python test_api.py --url http://localhost:8999
Send a JSON file (as multipart/form-data)¶
python test_api.py --url http://localhost:8999 --file sample.json
Send a PDF file¶
python test_api.py --url http://localhost:8999 --file document.pdf
main(url, file)
¶
Send a test request to the OntoCast API server.
This function sends a POST request to the /process endpoint with either: - A file upload (JSON or PDF) as multipart/form-data - A JSON text payload as application/json - A default test payload if no file or json-text is provided
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
The base URL of the API server (e.g. http://localhost:8999). |
required | |
file
|
Optional path to a JSON or PDF file to upload. |
required |
Example
main("http://localhost:8999", None, None)
Sends default Apple 10-Q payload¶
main("http://localhost:8999", pathlib.Path("document.pdf"), None)
Sends PDF file as multipart/form-data¶
main("http://localhost:8999", None, '{"text": "Hello"}')
Sends JSON text payload¶
Source code in ontocast/cli/test_api.py
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |