ab-ms-core / tests /unit /test_curl.sh
PupaClic
Add comprehensive unit tests for various endpoints and features
7ff20d3
#!/bin/bash
echo "=== Customer Name Filter Testing ==="
echo
# Start the server in background
echo "Starting FastAPI server..."
cd /Users/mukeshkapoor/projects/aquabarrier/ab-ms-core
source venv/bin/activate
uvicorn app.app:app --host 0.0.0.0 --port 8000 &
SERVER_PID=$!
# Wait for server to start
sleep 3
echo "Testing Customer API endpoints..."
echo
# Test 1: No filter
echo "1. All customers (no filter):"
curl -s "http://localhost:8000/api/v1/customers/?page=1&page_size=2" | python3 -c "import sys, json; data=json.load(sys.stdin); print(f' Total: {data[\"total\"]} customers'); [print(f' - {item[\"name\"]} (ID: {item[\"id\"]})') for item in data['items'][:2]]"
echo
# Test 2: Filter by 'corp'
echo "2. Customers with 'corp' in name:"
curl -s "http://localhost:8000/api/v1/customers/?name=corp&page=1&page_size=2" | python3 -c "import sys, json; data=json.load(sys.stdin); print(f' Found: {data[\"total\"]} customers'); [print(f' - {item[\"name\"]} (ID: {item[\"id\"]})') for item in data['items'][:2]]"
echo
# Test 3: Filter by 'aqua'
echo "3. Customers with 'aqua' in name:"
curl -s "http://localhost:8000/api/v1/customers/?name=aqua&page=1&page_size=2" | python3 -c "import sys, json; data=json.load(sys.stdin); print(f' Found: {data[\"total\"]} customers'); [print(f' - {item[\"name\"]} (ID: {item[\"id\"]})') for item in data['items'][:2]]"
echo
# Test 4: Combined with ordering
echo "4. Customers with 'inc' ordered by name:"
curl -s "http://localhost:8000/api/v1/customers/?name=inc&order_by=name&order_dir=asc&page=1&page_size=2" | python3 -c "import sys, json; data=json.load(sys.stdin); print(f' Found: {data[\"total\"]} customers'); [print(f' - {item[\"name\"]} (ID: {item[\"id\"]})') for item in data['items'][:2]]"
echo
# Cleanup
echo "Stopping server..."
kill $SERVER_PID
wait $SERVER_PID 2>/dev/null
echo "✅ Customer name filtering test completed!"