Test Modules
test_api_server.py
Integration test script for the Flask REST server.
Base URL: http://127.0.0.1:5001
Functions
- print_response(response)
Pretty-print status code and JSON body (or raw text).
- test_health_check()
Send
GET /healthand print the response.
- test_list_apis()
Send
GET /api/listand print the response.
- test_authentication(username, password)
Send
POST /api/authand return True if status is 200.
- test_get_all_assets()
Send
GET /api/get-all?page_num=1&per_page=5.
- test_get_asset_by_id(asset_id)
Send
GET /api/get-asset-id?id={asset_id}.
- main()
Orchestrate tests in order: health → list → auth → get-all → get-by-id (if auth succeeds).
Usage:
python3 test_api_server.py <username> <password>
test_create_api.py
End-to-end test for the create asset endpoint.
Functions
- print_response(response)
Pretty-print status code and JSON body.
- authenticate(username, password)
Send
POST /api/authand return True on 200.
- create_asset(asset_data)
Send
POST /api/createwith the provided asset JSON.
- load_config()
Load
evercycle-api/config/create.jsonand return the parsed dict.
- main()
Load create config.
Prompt for credentials (or read from argv).
Authenticate.
Randomize
serial_numberandasset_referenceto avoid conflicts.Optionally allow interactive customization of all body fields.
Send the create request.
Usage:
python3 test_create_api.py <username> <password>