Skip to main content

Sentinel-MAS Unit Tests (pytest)

How to run

  1. Ensure your source tree looks like this (package directory name matters):
<repo-root>/
  sentinel_mas/
    policy_sentinel/
    tools/
    agents/
    app/
    ...
  tests/
  1. Copy the tests/ folder from this bundle into your repo root so that tests/ sits next to the sentinel_mas/ folder.

  2. (Recommended) Create a virtualenv and install test deps:

pip install -r requirements-test.txt
  1. Run tests with coverage:
pip install -e .[test]
pytest --cov=sentinel_mas --cov-report=term-missing


If your package directory is not named sentinel_mas, either rename it or update the imports inside the tests accordingly.

Usage

1. Run locally

# Make scripts executable
chmod +x scripts/*.sh
chmod +x scripts/*.py

# Setup development environment
./scripts/setup_dev.sh

# Activate virtual environment
source .venv/bin/activate

# Run the full pipeline locally
./scripts/lint.sh
pytest tests/ --junitxml=test-results/junit.xml --cov=src
python scripts/generate_report.py

Local Sanity Check:

# Run isort to automatically fix import sorting
uv run isort .
uv run black .
uv run flake8 .
uv run mypy sentinel_mas tests
uv run pytest


## Verify the fixes:
isort --check-only .
black --check .

# Check only (CI mode)
./scripts/lint.sh

# Auto-fix all issues (development mode)
./scripts/lint.sh --fix

SonarCube Integration

## Download SonarCube
cd /d/NUS/Mtech\ IS/Year\ 2\ Sem\ 2/Practice\ Module/Development/sentinel/
curl -L -o sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-windows.zip
unzip sonar-scanner.zip -d tools


## update environment variable
export PATH="$PWD/tools/sonar-scanner-5.0.1.3006-windows/bin:$PATH"

## Verify
sonar-scanner -v

Configuration

This project uses separate environment files:

  • .env.sentinel - Sentinel MAS package configuration
  • .env.api - API service configuration
  • .env.shared - Shared configuration

Setup

  1. Copy example files:
cp .env.sentinel.example .env.sentinel
cp .env.api.example .env.api
cp .env.shared.example .env.shared
  1. Edit .env.sentinel:

    • Set OPENAI_API_KEY with your OpenAI key
  2. Edit .env.api:

    • Generate SECRET_KEY: openssl rand -hex 32
  3. Run the application:

python scripts/start_api.py

Environment Files

File Purpose Required Variables
.env.sentinel Package config OPENAI_API_KEY
.env.api API config SECRET_KEY
.env.shared Shared config None (has defaults)

---

## Migration Steps

1. **Backup your current .env:**
```bash
cp .env .env.backup
  1. Create the three new files:

    • Copy .env.sentinel content
    • Copy .env.api content
    • Copy .env.shared content
  2. Migrate your values:

    • From old .env, copy values to appropriate new files
    • Remove SENTINEL_ and API_ prefixes
  3. Update config files:

    • Replace sentinel_mas/config.py
    • Replace api_service/config.py
  4. Update .gitignore:

    • Add the new environment files
  5. Test:

python -c "from sentinel_mas.config import Config; print(f'Model: {Config.OPENAI_MODEL}')"
python -c "from api_service.config import get_api_config; print(f'Port: {get_api_config().PORT}')"
  1. Start the API:
python scripts/start_api.py

---

## Docker Update

**Update `docker/Dockerfile.api`:**

```dockerfile
# Copy environment files
COPY .env.sentinel .env.api .env.shared ./

Update docker-compose.yml:

services:
  api:
    volumes:
      - ./.env.sentinel:/app/.env.sentinel
      - ./.env.api:/app/.env.api
      - ./.env.shared:/app/.env.shared

Metadata

Release files for sentinel-mas 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sentinel-mas 0.1.0
File Size Uploaded
sentinel_mas-0.1.0.tar.gz 674.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sentinel-mas 0.1.0
File Interpreter ABI Platform
sentinel_mas-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.4 MB

Release files / sentinel_mas-0.1.0.tar.gz

Download URL sentinel_mas-0.1.0.tar.gz
Size 674.9 kB
Tags Source
SHA-256 checksum
How to use checksums
436ecaa6a4d87912b4050f557cb6c2cb4adae710d50234a3932ddea4682e74dc
BLAKE2b-256 checksum
How to use checksums
7d89a79e1d7ce409c5b60c86d00e5d2057f2660aa3ff48181af7ad43c5a98425
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2025.

Transparency log

Release files / sentinel_mas-0.1.0-py3-none-any.whl

Download URL sentinel_mas-0.1.0-py3-none-any.whl
Size 701.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9319c08ce197976804415231793117ba30e7bf97a2d591dc01ccbd37c114e49
BLAKE2b-256 checksum
How to use checksums
7202304af38e6b4b019c811342191b1cf3f26f4b7838b2e57b83beda58759591
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page