GenNet

Testing Guide

Test Structure

The GenNet platform includes comprehensive test coverage across all components:

Test Types

  1. Unit Tests (@pytest.mark.unit)
    • Test individual functions and classes in isolation
    • Fast execution, no external dependencies
    • Located in services/*/tests/test_*.py
  2. Integration Tests (@pytest.mark.integration)
    • Test service interactions and API endpoints
    • May require test databases/services
    • Located in services/*/tests/test_*_api.py
  3. End-to-End Tests (@pytest.mark.e2e)
    • Test full workflows across services
    • Require full stack running
    • Located in tests/integration/

Running Tests

All Tests

make test

Unit Tests Only

make test-unit

Integration Tests Only

make test-integration

E2E Tests

make test-e2e

With Coverage

make test-coverage

Specific Service

pytest services/auth-service/tests/

Specific Test File

pytest services/auth-service/tests/test_auth.py

Test Requirements

For Unit Tests

For Integration Tests

For E2E Tests

Writing Tests

Example Unit Test

@pytest.mark.unit
def test_password_hashing():
    password = "testpassword"
    hashed = get_password_hash(password)
    assert verify_password(password, hashed)

Example Integration Test

@pytest.mark.integration
def test_create_network(client, auth_token):
    response = client.post(
        "/networks",
        json={"name": "Test", "nodes": [], "edges": []},
        headers={"Authorization": f"Bearer {auth_token}"}
    )
    assert response.status_code == 201

Example E2E Test

@pytest.mark.e2e
def test_workflow_e2e():
    # Register user
    # Create network
    # Run workflow
    # Check results

Test Fixtures

Common fixtures are defined in conftest.py:

Frontend Tests

Frontend uses Jest and React Testing Library:

cd frontend/web
npm test

Continuous Integration

Tests run automatically on:

Coverage Goals