|
1 | 1 | import pytest |
2 | 2 | import requests |
3 | 3 | import time |
| 4 | +import os |
4 | 5 | from typing import Dict, List |
5 | 6 |
|
6 | | -# Configuration |
7 | | -SCENARIO_SERVICE_URL = "http://localhost:8000" |
8 | | -BILL_PAY_SERVICE_URL = "http://localhost:5000" |
| 7 | +# Configuration - use environment variables with local defaults |
| 8 | +SCENARIO_SERVICE_URL = os.getenv("SCENARIO_SERVICE_URL", "http://localhost:8000/scenario-runner") |
| 9 | +BILL_PAY_SERVICE_URL = os.getenv("BASE_URL", "http://localhost:5000") |
9 | 10 | NUM_PAYMENT_ATTEMPTS = 50 # Send enough to trigger scenarios |
10 | 11 |
|
11 | 12 | @pytest.fixture |
12 | 13 | def reset_scenarios(): |
13 | 14 | """Reset all scenarios before and after tests""" |
14 | | - response = requests.post(f"{SCENARIO_SERVICE_URL}/scenario-runner/api/payment-scenarios/reset") |
| 15 | + response = requests.post(f"{SCENARIO_SERVICE_URL}/api/payment-scenarios/reset") |
15 | 16 | assert response.status_code == 200 |
16 | 17 | yield |
17 | 18 | # Cleanup after test |
18 | | - requests.post(f"{SCENARIO_SERVICE_URL}/scenario-runner/api/payment-scenarios/reset") |
| 19 | + requests.post(f"{SCENARIO_SERVICE_URL}/api/payment-scenarios/reset") |
19 | 20 |
|
20 | 21 |
|
21 | 22 | def enable_scenario(scenario_name: str, probability: float = None, delay: float = None) -> Dict: |
22 | 23 | """Enable a payment scenario""" |
23 | 24 | endpoints = { |
24 | | - "gateway_timeout": f"{SCENARIO_SERVICE_URL}/scenario-runner/api/payment-scenarios/gateway-timeout", |
25 | | - "card_decline": f"{SCENARIO_SERVICE_URL}/scenario-runner/api/payment-scenarios/card-decline", |
26 | | - "stolen_card": f"{SCENARIO_SERVICE_URL}/scenario-runner/api/payment-scenarios/stolen-card" |
| 25 | + "gateway_timeout": f"{SCENARIO_SERVICE_URL}/api/payment-scenarios/gateway-timeout", |
| 26 | + "card_decline": f"{SCENARIO_SERVICE_URL}/api/payment-scenarios/card-decline", |
| 27 | + "stolen_card": f"{SCENARIO_SERVICE_URL}/api/payment-scenarios/stolen-card" |
27 | 28 | } |
28 | 29 |
|
29 | 30 | params = {"enabled": True} |
@@ -196,7 +197,7 @@ def test_scenario_reset(reset_scenarios): |
196 | 197 | enable_scenario("stolen_card", probability=100.0) |
197 | 198 |
|
198 | 199 | # Reset all scenarios |
199 | | - response = requests.post(f"{SCENARIO_SERVICE_URL}/scenario-runner/api/payment-scenarios/reset") |
| 200 | + response = requests.post(f"{SCENARIO_SERVICE_URL}/api/payment-scenarios/reset") |
200 | 201 | assert response.status_code == 200 |
201 | 202 | print("Reset all scenarios") |
202 | 203 |
|
|
0 commit comments