-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·93 lines (82 loc) · 2.61 KB
/
run_tests.sh
File metadata and controls
executable file
·93 lines (82 loc) · 2.61 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
# Test execution script for roex-python SDK
set -e # Exit on error
# Color codes for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}RoEx Python SDK - Test Runner${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
# Check if pytest is installed
if ! command -v pytest &> /dev/null; then
echo -e "${RED}Error: pytest not found!${NC}"
echo "Please install test dependencies:"
echo " pip install -r requirements-dev.txt"
exit 1
fi
# Function to run unit tests
run_unit_tests() {
echo -e "${GREEN}Running Unit Tests (Fast)...${NC}"
pytest tests/unit -m unit -v --tb=short
echo ""
}
# Function to run integration tests
run_integration_tests() {
echo -e "${GREEN}Running Integration Tests (Requires API Key)...${NC}"
# Check for API key
if [ -z "$ROEX_API_KEY" ]; then
echo -e "${YELLOW}Warning: ROEX_API_KEY not set!${NC}"
echo "Integration tests require a valid API key."
echo "Set it with: export ROEX_API_KEY='your_key_here'"
echo "Skipping integration tests..."
return 1
fi
pytest tests/integration -m integration -v --tb=short --maxfail=3
echo ""
}
# Function to run tests with coverage
run_with_coverage() {
echo -e "${GREEN}Running Tests with Coverage...${NC}"
pytest tests/unit -m unit --cov=roex_python --cov-report=html --cov-report=term
echo ""
echo -e "${GREEN}Coverage report generated in htmlcov/index.html${NC}"
}
# Parse command line arguments
case "${1:-all}" in
unit)
run_unit_tests
;;
integration)
run_integration_tests
;;
coverage)
run_with_coverage
;;
all)
run_unit_tests
if [ -n "$ROEX_API_KEY" ]; then
read -p "Run integration tests? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
run_integration_tests
fi
fi
;;
*)
echo "Usage: $0 {unit|integration|coverage|all}"
echo ""
echo "Commands:"
echo " unit - Run unit tests only (fast, no API calls)"
echo " integration - Run integration tests (requires API key)"
echo " coverage - Run unit tests with coverage report"
echo " all - Run all tests (default)"
exit 1
;;
esac
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}Tests Complete!${NC}"
echo -e "${GREEN}========================================${NC}"