-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·89 lines (75 loc) · 2.6 KB
/
run_tests.sh
File metadata and controls
executable file
·89 lines (75 loc) · 2.6 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
#!/bin/bash
# Script to create conda environment, install dependencies, and run tests for customer service bot
set -e # Exit on error
ENV_NAME="customerservice"
REQUIREMENTS_FILE="requirements.txt"
LIVE_MODE=false
# Color codes for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--live)
LIVE_MODE=true
shift
;;
*)
echo -e "${RED}Unknown option: $1${NC}"
echo "Usage: $0 [--live]"
echo " --live: Run live integration tests with OpenRouter API"
exit 1
;;
esac
done
if [ "$LIVE_MODE" = true ]; then
echo "Setting up LIVE test environment for Customer Service Bot..."
else
echo "Setting up test environment for Customer Service Bot..."
fi
# Check if conda is available
if ! command -v conda &> /dev/null; then
echo "Error: conda is not installed or not in PATH"
exit 1
fi
# Check if environment already exists
if conda env list | grep -q "^${ENV_NAME} "; then
echo -e "${YELLOW}Environment ${ENV_NAME} already exists${NC}"
ENV_EXISTS=true
else
echo -e "${GREEN}Creating conda environment: ${ENV_NAME}${NC}"
conda create -n ${ENV_NAME} python=3.12 -y
ENV_EXISTS=false
fi
# Activate the environment
echo -e "${GREEN}Activating conda environment: ${ENV_NAME}${NC}"
eval "$(conda shell.bash hook)"
conda activate ${ENV_NAME}
# Install requirements if environment was just created or if not installed
if [ "$ENV_EXISTS" = false ]; then
echo -e "${GREEN}Installing requirements from ${REQUIREMENTS_FILE}${NC}"
pip install -r ${REQUIREMENTS_FILE}
else
# Try to install requirements anyway to ensure dependencies are up to date
echo -e "${YELLOW}Checking if requirements are installed...${NC}"
pip install -r ${REQUIREMENTS_FILE} --quiet
fi
# Run the tests
if [ "$LIVE_MODE" = true ]; then
# Check if OPENROUTER_API_KEY is set
if [ -z "$OPENROUTER_API_KEY" ]; then
echo -e "${RED}Error: OPENROUTER_API_KEY environment variable is not set${NC}"
echo "Please set it with: export OPENROUTER_API_KEY='your-api-key'"
exit 1
fi
echo -e "${YELLOW}Running LIVE integration tests with OpenRouter API...${NC}"
echo -e "${YELLOW}Note: These tests make real API calls and will consume tokens${NC}"
echo ""
pytest tests/test_live_integration.py -v -s
else
echo -e "${GREEN}Running unit tests (with mocked APIs)...${NC}"
pytest tests/ -v --ignore=tests/test_live_integration.py
fi
echo -e "${GREEN}Tests completed!${NC}"