Automated Testing Strategy Guide
Instructions for running and extending automated tests across MetaPilot.
Running Backend Unit & Integration Tests
MetaPilot supports both the standard Django Test Runner and Pytest.
1. Running Standard Django Tests
From :
services/apibash
python manage.py test
To run tests for a specific application:
bash
python manage.py test tenants
python manage.py test users
2. Running Pytest Suite
bash
# Run specific test file
python -m pytest tests/unit/security/test_tenant_encryption.py
# Run all unit tests
python -m pytest tests/unit/
Writing Model & API Tests
Example: Testing Fernet Encryption (test_tenant_encryption.py
)
test_tenant_encryption.pypython
@pytest.mark.skipif(not _has_cryptography(), reason='cryptography not installed')
def test_encrypt_decrypt_roundtrip(self):
"""Encrypting then decrypting returns original value."""
fernet, key = self._make_fernet()
config = self._make_config(key)
config.set_value('my_secret_api_token_12345')
decrypted = config.get_value()
assert decrypted == 'my_secret_api_token_12345'
Running Frontend Tests & Linters
From :
appsbash
yarn lint
yarn build