Files
AutoMarket/backend/test_flowwow_api.py

45 lines
1.3 KiB
Python

import os
import sys
from dotenv import load_dotenv
# Add parent dir to path so we can import backend packages
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from backend.flowwow_api import FlowwowAPI
from backend.flowwow_api.exceptions import FlowwowAPIError
def test_flowwow_api():
# Load environment variables
env_path = os.path.join(os.path.dirname(__file__), '.env')
load_dotenv(env_path)
# Check if key is loaded
api_token = os.getenv('FLOWWOW_API_TOKEN')
if not api_token:
print("Error: FLOWWOW_API_TOKEN must be in backend/.env")
return
print("Initializing FlowwowAPI...")
api = FlowwowAPI()
try:
# Test 1: Get Products
print("\n--- Testing Products API ---")
products_response = api.products.get_list(limit=5)
print("Success! Response keys:", products_response.keys())
items = products_response.get("items", [])
if not items:
items = products_response.get("data", [])
print(f"Found {len(items)} products in Flowwow catalog.")
except FlowwowAPIError as e:
print(f"API Error: {e}")
except Exception as e:
print(f"Unexpected Error: {e}")
if __name__ == '__main__':
test_flowwow_api()