-
Notifications
You must be signed in to change notification settings - Fork 2
Add regression test suite #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| """Shared fixtures for all tests.""" | ||
|
|
||
| import os | ||
| import time | ||
| import uuid | ||
| from collections.abc import Generator | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_env_clear(monkeypatch: pytest.MonkeyPatch) -> Generator[None, None, None]: | ||
| """Clear all Vercel-related environment variables for testing. | ||
|
|
||
| This ensures tests don't accidentally use real credentials from the environment. | ||
| """ | ||
| env_vars_to_clear = [ | ||
| # General Vercel | ||
| "VERCEL_TOKEN", | ||
| "VERCEL_TEAM_ID", | ||
| "VERCEL_PROJECT_ID", | ||
| # Blob storage | ||
| "BLOB_READ_WRITE_TOKEN", | ||
| "BLOB_STORE_ID", | ||
| # OIDC | ||
| "VERCEL_OIDC_TOKEN", | ||
| "VERCEL_OIDC_TOKEN_HEADER", | ||
| # Cache | ||
| "VERCEL_CACHE_API_TOKEN", | ||
| "VERCEL_CACHE_API_URL", | ||
| # Functions | ||
| "VERCEL_URL", | ||
| "VERCEL_ENV", | ||
| "VERCEL_REGION", | ||
| ] | ||
| for var in env_vars_to_clear: | ||
| monkeypatch.delenv(var, raising=False) | ||
| yield | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_token() -> str: | ||
| """Mock Vercel API token for testing.""" | ||
| return "test_token_123456789" | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_team_id() -> str: | ||
| """Mock Vercel team ID for testing.""" | ||
| return "team_test123456789" | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_project_id() -> str: | ||
| """Mock Vercel project ID for testing.""" | ||
| return "prj_test123456789" | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_blob_token() -> str: | ||
| """Mock blob storage token for testing.""" | ||
| return "vercel_blob_rw_test_token_123456789" | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def unique_test_name() -> str: | ||
| """Generate a unique test resource name with timestamp.""" | ||
| timestamp = int(time.time()) | ||
| unique_id = uuid.uuid4().hex[:8] | ||
| return f"vercel-py-test-{timestamp}-{unique_id}" | ||
|
|
||
|
|
||
| def has_vercel_credentials() -> bool: | ||
| """Check if Vercel API credentials are available.""" | ||
| return bool(os.getenv("VERCEL_TOKEN") and os.getenv("VERCEL_TEAM_ID")) | ||
|
|
||
|
|
||
| def has_blob_credentials() -> bool: | ||
| """Check if Blob storage credentials are available.""" | ||
| return bool(os.getenv("BLOB_READ_WRITE_TOKEN")) | ||
|
|
||
|
|
||
| def has_sandbox_credentials() -> bool: | ||
| """Check if Sandbox credentials are available.""" | ||
| return has_vercel_credentials() | ||
|
|
||
|
|
||
| # Skip markers for live tests | ||
| requires_vercel_credentials = pytest.mark.skipif( | ||
| not has_vercel_credentials(), | ||
| reason="Requires VERCEL_TOKEN and VERCEL_TEAM_ID environment variables", | ||
| ) | ||
|
|
||
| requires_blob_credentials = pytest.mark.skipif( | ||
| not has_blob_credentials(), | ||
| reason="Requires BLOB_READ_WRITE_TOKEN environment variable", | ||
| ) | ||
|
|
||
| requires_sandbox_credentials = pytest.mark.skipif( | ||
| not has_sandbox_credentials(), | ||
| reason="Requires VERCEL_TOKEN and VERCEL_TEAM_ID environment variables for sandbox", | ||
| ) |
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an actual behavioral change that is intentional. Someone flag if there is a reason why the async version uses
DEFAULT_TIMEOUT(which is 60 seconds) and the sync version uses 30 seconds.