Skip to content

Testing Quick Setup

crocodilestick edited this page Oct 24, 2025 · 2 revisions

Testing Quick Setup for Contributors

Prerequisites

  1. Python 3.12+ installed
  2. Docker installed and running
  3. Git (you already have this if you cloned the repo)

Initial Setup (One-Time)

# 1. Clone the repository
git clone https://github.com/crocodilestick/Calibre-Web-Automated.git
cd Calibre-Web-Automated

# 2. Create virtual environment
python3 -m venv .venv

# 3. Activate virtual environment
source .venv/bin/activate  # Linux/Mac
# OR
.venv\Scripts\activate  # Windows

# 4. Install dependencies
pip install -r requirements.txt
pip install pytest pytest-timeout pytest-flask pytest-mock faker testcontainers

# 5. You're ready to test!
./run_tests.sh

Custom Port (Optional)

If port 8085 is already in use on your system, you can specify a custom port:

# Use port 9090 instead
export CWA_TEST_PORT=9090
./run_tests.sh

Or set it inline:

CWA_TEST_PORT=9090 ./run_tests.sh

Note: The default test port is 8085 to avoid conflicts with production instances running on 8083.

Troubleshooting

Docker not running

Error: Docker daemon not running

Solution: Start Docker Desktop or Docker daemon

Port already in use

Error: Port 8083 already allocated

Solution: Use CWA_TEST_PORT to specify a different port (see above)

Missing dependencies

Error: pytest not found

Solution: Make sure venv is activated and dependencies installed:

source .venv/bin/activate
pip install pytest pytest-timeout pytest-flask pytest-mock faker testcontainers

Python version

Error: Python 3.12+ required

Solution: Update Python or use pyenv:

pyenv install 3.12.3
pyenv local 3.12.3

What Gets Tested?

  • Unit Tests - Fast, no Docker needed (111 tests)
  • Integration Tests - Docker required (20 tests)
  • Smoke Tests - Quick environment checks (13 tests)
  • ⚠️ Docker Tests - Require running container (9 tests)

Running Specific Tests

# Just unit tests (fastest)
pytest tests/unit/ -v

# Just integration tests
pytest tests/integration/ -v

# Specific test file
pytest tests/unit/test_helper.py -v

# Single test
pytest tests/unit/test_helper.py::TestGetValidFilename::test_basic_valid_filename -v

VSCode Integration

The .venv will auto-activate in VSCode terminals. Just open a new terminal and start testing!

Next Steps

Clone this wiki locally