This document explains how to run tests for msgraphfs.
To run the basic test suite that doesn't require real SharePoint credentials:
uv run pytest
# or explicitly skip live tests
uv run pytest -m "not live"These tests cover:
- Unit tests for OAuth2 functionality
- URL parsing tests
- fsspec integration tests
- Mock-based tests for filesystem operations
To run tests that require real SharePoint credentials:
uv run pytest -m "live"Prerequisites: Set the following environment variables:
MSGRAPHFS_CLIENT_ID: Your Azure AD application client IDMSGRAPHFS_TENANT_ID: Your Azure AD tenant IDMSGRAPHFS_CLIENT_SECRET: Your Azure AD application client secret
Important: Live tests will be automatically skipped if credentials are not provided.
To run both basic and live tests (if credentials are available):
uv run pytest tests/tests/test_oauth2.py- OAuth2 authentication tests (no credentials required)tests/test_fsspec_integration.py- fsspec integration tests (no credentials required)tests/test_url_parsing.py- URL parsing tests (no credentials required)tests/test_read.py- File reading tests (credentials required via fixtures)tests/test_write.py- File writing tests (credentials required via fixtures)tests/test_live_url_features.py- Live URL feature tests (marked with@pytest.mark.live)
The GitHub Actions workflow automatically:
- Runs basic tests on all Python versions (3.9-3.12) for every PR/push
- Runs live tests only on the main branch and only if credentials are configured
- Skips live tests gracefully if credentials are not available
@pytest.mark.live- Tests that require real SharePoint credentials@pytest.mark.credentials- Tests that require credentials (reserved for future use)
Test configuration is defined in pyproject.toml:
[tool.pytest.ini_options]
markers = [
"live: marks tests as requiring live credentials (deselect with '-m \"not live\"')",
"credentials: marks tests as requiring credentials (deselect with '-m \"not credentials\"')",
]