File size: 1,601 Bytes
4a2ab42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import json
import sys

import requests

BASE_URL = "http://localhost:8001/api/v1"


def test_endpoint(name, url, method="GET", body=None):
    print(f"Testing {name} ({method} {url})...")
    try:
        if method == "GET":
            response = requests.get(f"{BASE_URL}{url}")
        elif method == "POST":
            response = requests.post(f"{BASE_URL}{url}", json=body)

        if response.status_code == 200:
            print(f"โœ… {name} Passed")
            print(json.dumps(response.json(), indent=2))
            return True
        else:
            print(f"โŒ {name} Failed: {response.status_code}")
            print(response.text)
            return False
    except Exception as e:
        print(f"โŒ {name} Error: {e}")
        return False


def run_tests():
    passed = True

    # Test 1: Case Analytics
    if not test_endpoint("Case Analytics", "/analytics/cases"):
        passed = False

    # Test 2: Transaction Analytics
    if not test_endpoint("Transaction Analytics", "/analytics/transactions"):
        passed = False

    # Test 3: System Overview
    if not test_endpoint("System Overview", "/analytics/overview"):
        passed = False

    # Test 4: Export Report
    if not test_endpoint(
        "Export Report",
        "/reporting/export",
        "POST",
        {"case_ids": ["CASE-123"], "format": "pdf"},
    ):
        passed = False

    if passed:
        print("\n๐ŸŽ‰ All Reporting Endpoints Verified!")
        sys.exit(0)
    else:
        print("\n๐Ÿ’ฅ Some tests failed.")
        sys.exit(1)


if __name__ == "__main__":
    run_tests()