This guide explains how to configure and run tests that require external service credentials (Zenodo, GitHub, arXiv) and local tools (LaTeX).
The test suite includes tests that make real API calls to external services. These tests are marked with special pytest markers and will automatically skip if credentials are not available.
-
Copy the example files:
cp .env.example .env cp test_credentials.yaml.example test_credentials.yaml
-
Add your credentials to
.env(see sections below) -
Run all tests (external service tests will be skipped if credentials not configured):
pytest tests/
-
Run only tests that don't require external services:
pytest tests/ -m "not requires_credentials"
Create a .env file in the repository root with your credentials:
# Zenodo Sandbox (recommended for testing)
ZENODO_SANDBOX_TOKEN=your_sandbox_token_here
# GitHub
GITHUB_TOKEN=your_github_pat_here
GITHUB_REPO=username/test-repository
# arXiv (optional)
ARXIV_USERNAME=your_username
ARXIV_PASSWORD=your_passwordOptionally, create test_credentials.yaml for additional configuration:
zenodo:
use_sandbox: true # Always use sandbox for tests!
github:
test_tag_prefix: "test-release-"
cleanup:
auto_cleanup: true # Automatically delete test artifacts- Create account at https://sandbox.zenodo.org/
- Navigate to: Account Settings → Applications → Personal access tokens
- Create new token with scopes:
deposit:write,deposit:actions - Copy token to
.envasZENODO_SANDBOX_TOKEN
Important: Use the sandbox environment for testing, not production Zenodo!
- Go to https://github.com/settings/tokens/new
- Create token with scopes:
repo(full repository access)write:packages(for release assets)delete_repo(optional, for test cleanup)
- Set expiration and create token
- Copy token to
.envasGITHUB_TOKEN
Repository Setup:
- Create a test repository on GitHub (e.g.,
username/test-automation) - Add repository name to
.envasGITHUB_REPO=username/test-automation - Tests will create and delete releases in this repository
arXiv submission tests are optional and require SWORD API credentials:
- Register for arXiv account
- Contact arXiv to enable SWORD API access (not available by default)
- Add credentials to
.env
Most users can skip arXiv tests as they're not required for the core test suite.
Ollama tests require a running Ollama server with at least one model installed:
-
Install Ollama:
# macOS brew install ollama # Linux curl -fsSL https://ollama.ai/install.sh | sh # Windows # Download from https://ollama.ai/download
-
Start Ollama server:
ollama serve
-
Install at least one model:
# Recommended models for testing ollama pull llama3.1:latest # 4.7GB, good quality ollama pull llama3-gradient # 4.7GB, 256K context ollama pull gemma2:2b # 2GB, fast and lightweight # Verify models are available ollama list
-
Optional: Configure Ollama host (if not using default):
export OLLAMA_HOST=http://localhost:11434
Note: Ollama tests will automatically skip if the server is not running or no models are available. No credentials are required - tests use the local Ollama installation.
Tests are marked with the following markers:
| Marker | Description | Skip Condition |
|---|---|---|
requires_ollama |
Needs Ollama server running | Ollama not running or no models |
requires_zenodo |
Needs Zenodo API access | No ZENODO_SANDBOX_TOKEN |
requires_github |
Needs GitHub API access | No GITHUB_TOKEN or GITHUB_REPO |
requires_arxiv |
Needs arXiv API access | No ARXIV_USERNAME |
requires_latex |
Needs LaTeX installed | No pdflatex or xelatex |
requires_network |
Needs internet access | Offline environment |
requires_credentials |
Needs any external credentials | General credential marker |
pytest tests/pytest tests/ -m "not requires_credentials"pytest tests/ -m requires_zenodopytest tests/ -m requires_github# Ensure Ollama server is running first
ollama serve
# Then run tests
pytest tests/ -m requires_ollamapytest tests/ -m "not requires_network"pytest tests/ -m "not requires_latex"# Run tests that need neither credentials nor LaTeX
pytest tests/ -m "not requires_credentials and not requires_latex"
# Run all external service tests
pytest tests/ -m "requires_zenodo or requires_github"Tests automatically clean up after themselves:
- Zenodo: Test depositions are deleted after test completion
- GitHub: Test releases and tags are deleted after test completion
- Files: Temporary files are cleaned up using pytest's
tmp_pathfixtures
If cleanup fails (e.g., network error), you may need to manually delete test artifacts:
# Visit Zenodo sandbox and delete test depositions
https://sandbox.zenodo.org/deposit# Delete test releases via GitHub web UI or CLI
gh release delete test-release-12345678 --repo username/test-repo
# Delete test tags
git push --delete origin test-release-12345678-
Never commit credentials:
.envandtest_credentials.yamlare in.gitignore- Always use
.env.examplefor templates
-
Use sandbox environments:
- Always use Zenodo sandbox, not production
- Create dedicated test repositories on GitHub
-
Rotate tokens regularly:
- GitHub tokens: Set expiration dates
- Zenodo tokens: Regenerate periodically
- Delete unused tokens
-
Limit token scopes:
- Only grant minimum required permissions
- Use separate tokens for different purposes
-
Protect your
.envfile:chmod 600 .env # Owner read/write only
Problem: Tests marked with requires_* are being skipped
Solution:
- Check
.envfile exists and has correct credentials - Verify environment variables are loaded:
echo $ZENODO_SANDBOX_TOKEN - Run with
-vto see skip reasons:pytest tests/ -v
Problem: Zenodo tests fail with authentication errors
Solutions:
- Verify token is for sandbox, not production
- Check token has
deposit:writeanddeposit:actionsscopes - Ensure token hasn't expired
- Test token manually:
curl -H "Authorization: Bearer YOUR_TOKEN" https://sandbox.zenodo.org/api/deposit/depositions
Problem: Tests fail with rate limit errors
Solutions:
- Authenticated requests have higher rate limits
- Wait for rate limit reset (check
X-RateLimit-Resetheader) - Use a dedicated test account to avoid conflicts with personal usage
Problem: Rendering tests fail
Solutions:
- Install LaTeX:
sudo apt-get install texlive-latex-base texlive-xetex(Ubuntu) orbrew install mactex(macOS) - Verify installation:
which pdflatex - Skip LaTeX tests:
pytest tests/ -m "not requires_latex"
Problem: Test artifacts not being deleted
Solutions:
- Check token permissions include deletion rights
- Manually delete via web UI
- Check cleanup logs for specific errors
# Install LaTeX
sudo apt-get update
sudo apt-get install -y texlive-latex-base texlive-xetex pandoc
# Install Python dependencies
uv sync
# Configure credentials
cp .env.example .env
nano .env # Add your credentials
# Run tests
pytest tests/# Install LaTeX
brew install --cask mactex
brew install pandoc
# Install Python dependencies
uv sync
# Configure credentials
cp .env.example .env
nano .env # Add your credentials
# Run tests
pytest tests/# Install MiKTeX or TeX Live
# Install pandoc from https://pandoc.org/
# Install Python dependencies
uv sync
# Configure credentials
copy .env.example .env
notepad .env # Add your credentials
# Run tests
pytest tests/For continuous integration, store credentials as secrets:
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup credentials
run: |
echo "ZENODO_SANDBOX_TOKEN=${{ secrets.ZENODO_SANDBOX_TOKEN }}" >> .env
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> .env
echo "GITHUB_REPO=${{ secrets.GITHUB_REPO }}" >> .env
- name: Install LaTeX
run: |
sudo apt-get update
sudo apt-get install -y texlive-latex-base pandoc
- name: Run tests
run: pytest tests/For issues or questions:
- Check this documentation
- Review test output with
-vflag for detailed skip reasons - Verify credentials are correctly configured
- Check external service status pages
- File an issue with details of the problem
- tests/AGENTS.md - Test suite documentation
- tests/infra_tests/AGENTS.md - Infrastructure test suite layout
- AGENTS.md - System documentation