Test Modules

test_api_server.py

Integration test script for the Flask REST server.

Base URL: http://127.0.0.1:5001

Functions

Pretty-print status code and JSON body (or raw text).

test_health_check()

Send GET /health and print the response.

test_list_apis()

Send GET /api/list and print the response.

test_authentication(username, password)

Send POST /api/auth and 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/auth and return True on 200.

create_asset(asset_data)

Send POST /api/create with the provided asset JSON.

load_config()

Load evercycle-api/config/create.json and return the parsed dict.

main()
  1. Load create config.

  2. Prompt for credentials (or read from argv).

  3. Authenticate.

  4. Randomize serial_number and asset_reference to avoid conflicts.

  5. Optionally allow interactive customization of all body fields.

  6. Send the create request.

Usage:

python3 test_create_api.py <username> <password>