|
| 1 | +# Marketplace SQLAlchemy Workshop - Task Runner |
| 2 | +# Use 'just --list' to see all available commands |
| 3 | + |
| 4 | +# Default recipe to display help |
| 5 | +default: |
| 6 | + @just --list |
| 7 | + |
| 8 | +# Run the marketplace server |
| 9 | +run: |
| 10 | + uv run python marketsvc/server.py |
| 11 | + |
| 12 | +# Get all customers |
| 13 | +customers: |
| 14 | + curl http://localhost:9090/api/customers |
| 15 | + |
| 16 | +# Get customer orders (specify customer_id, default=1) |
| 17 | +orders customer_id="1": |
| 18 | + curl http://localhost:9090/api/orders/{{customer_id}} |
| 19 | + |
| 20 | +# Get order total cost (specify order_id, default=1) |
| 21 | +order-total order_id="1": |
| 22 | + curl http://localhost:9090/api/order_total/{{order_id}} |
| 23 | + |
| 24 | +# Get orders between dates |
| 25 | +orders-between before="2024-03-22" after="2024-03-14": |
| 26 | + curl "http://localhost:9090/api/orders_between_dates/{{before}}/{{after}}" |
| 27 | + |
| 28 | +# Create a new order |
| 29 | +new-order: |
| 30 | + curl -H "Content-Type: application/json" -d '{"customer_id":1,"items":[{"id":2,"quantity":4},{"id":3,"quantity":6}]}' http://localhost:9090/api/add_new_order |
| 31 | + |
| 32 | +# Create a custom new order (specify customer_id and items as JSON string) |
| 33 | +new-order-custom customer_id items: |
| 34 | + curl -H "Content-Type: application/json" -d '{"customer_id":{{customer_id}},"items":{{items}}}' http://localhost:9090/api/add_new_order |
| 35 | + |
| 36 | +# Install dependencies using uv |
| 37 | +install: |
| 38 | + uv sync |
| 39 | + |
| 40 | +# Install development dependencies |
| 41 | +install-dev: |
| 42 | + uv sync --dev |
| 43 | + |
| 44 | +# Run linting with ruff |
| 45 | +lint: |
| 46 | + uv run ruff check . |
| 47 | + |
| 48 | +# Format code with ruff |
| 49 | +format: |
| 50 | + uv run ruff format . |
| 51 | + |
| 52 | +# Run both linting and formatting |
| 53 | +check: lint format |
| 54 | + |
| 55 | +# Clean up Python cache files |
| 56 | +clean: |
| 57 | + find . -type f -name "*.pyc" -delete |
| 58 | + find . -type d -name "__pycache__" -delete |
| 59 | + |
| 60 | +# Show API endpoints (requires server to be running) |
| 61 | +endpoints: |
| 62 | + @echo "Available API endpoints:" |
| 63 | + @echo " GET http://localhost:9090/" |
| 64 | + @echo " GET http://localhost:9090/api/customers" |
| 65 | + @echo " GET http://localhost:9090/api/orders/{customer_id}" |
| 66 | + @echo " GET http://localhost:9090/api/order_total/{order_id}" |
| 67 | + @echo " GET http://localhost:9090/api/orders_between_dates/{before}/{after}" |
| 68 | + @echo " POST http://localhost:9090/api/add_new_order" |
| 69 | + |
| 70 | +# Test all endpoints (requires server to be running in another terminal) |
| 71 | +test-all: |
| 72 | + @echo "Testing all endpoints..." |
| 73 | + @echo "\n1. Testing root endpoint:" |
| 74 | + -curl -s http://localhost:9090/ |
| 75 | + @echo "\n\n2. Testing customers:" |
| 76 | + -curl -s http://localhost:9090/api/customers |
| 77 | + @echo "\n\n3. Testing customer orders:" |
| 78 | + -curl -s http://localhost:9090/api/orders/1 |
| 79 | + @echo "\n\n4. Testing order total:" |
| 80 | + -curl -s http://localhost:9090/api/order_total/1 |
| 81 | + @echo "\n\n5. Testing orders between dates:" |
| 82 | + -curl -s "http://localhost:9090/api/orders_between_dates/2024-03-22/2024-03-14" |
| 83 | + @echo "\n\n6. Testing new order creation:" |
| 84 | + -curl -s -H "Content-Type: application/json" -d '{"customer_id":1,"items":[{"id":2,"quantity":4},{"id":3,"quantity":6}]}' http://localhost:9090/api/add_new_order |
| 85 | + @echo "\n\nAll tests completed!" |
0 commit comments