Running Tests - NatLabRockies/alfalfa GitHub Wiki

Running tests locally

There are three stages of tests: unit tests, docker-based simulation tests, and integration tests. To run the tests, first run the following commands, then jump to the section of interest below.

  1. Install Docker Desktop for your platform
  2. Install Poetry: pip install poetry
  3. Install dependencies: poetry install

Unit Tests

  1. Run unit tests: poetry run pytest

Docker-based Simulation Tests

  1. Run docker dev stack locally (in detached mode)

    docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --build -d
    
  2. Call Modelica tests

    docker exec alfalfa_worker bash -c "cd /alfalfa && pytest -m docker tests/jobs/modelica"
    
  3. Call OpenStudio tests:

    docker exec alfalfa_worker bash -c "cd /alfalfa && pytest -m docker tests/jobs/openstudio"
    
  4. Clean up stack: docker-compose down

Integration Tests

  1. Run stack locally in detached mode: docker-compose up --build -d
  2. Run integration tests: poetry run pytest -m "integration"
  3. Clean up stack: docker-compose down