Skip to content

Commit 38e4223

Browse files
committed
Make SDK integration tests environment-configurable via MPAK_REGISTRY_URL
Read MPAK_REGISTRY_URL env var in both TypeScript and Python SDK integration tests to allow running against staging or production. Python tests now use a shared registry_client fixture. Defaults to production when unset.
1 parent 47008e8 commit 38e4223

4 files changed

Lines changed: 43 additions & 33 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
11
"""Pytest configuration and shared fixtures."""
2+
3+
import os
4+
5+
import pytest
6+
7+
from mpak import MpakClient
8+
from mpak.types import MpakClientConfig
9+
10+
11+
@pytest.fixture()
12+
def registry_client():
13+
"""MpakClient configured via MPAK_REGISTRY_URL env var (defaults to production)."""
14+
base_url = os.environ.get("MPAK_REGISTRY_URL", "https://registry.mpak.dev")
15+
config = MpakClientConfig(base_url=base_url)
16+
with MpakClient(config) as client:
17+
yield client

packages/sdk-python/tests/test_integration.py

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import pytest
1212

13-
from mpak import MpakClient, MpakNotFoundError
13+
from mpak import MpakNotFoundError
1414
from mpak.types import BundleDownloadResponse
1515

1616
# Well-known bundle that exists on the registry
@@ -22,10 +22,9 @@
2222
class TestGetBundleDownload:
2323
"""Tests for resolving bundle download metadata from the live registry."""
2424

25-
def test_resolve_latest_version(self):
25+
def test_resolve_latest_version(self, registry_client):
2626
"""get_bundle_download returns a valid download URL and SHA256 for latest."""
27-
with MpakClient() as client:
28-
download = client.get_bundle_download(TEST_PACKAGE)
27+
download = registry_client.get_bundle_download(TEST_PACKAGE)
2928

3029
assert isinstance(download, BundleDownloadResponse)
3130
assert download.url.startswith("https://")
@@ -36,48 +35,43 @@ def test_resolve_latest_version(self):
3635
assert download.bundle.version # non-empty
3736
assert download.bundle.size > 0
3837

39-
def test_resolve_specific_version(self):
38+
def test_resolve_specific_version(self, registry_client):
4039
"""get_bundle_download works with a pinned version."""
41-
with MpakClient() as client:
42-
download = client.get_bundle_download(TEST_PACKAGE, version="0.1.5")
40+
download = registry_client.get_bundle_download(TEST_PACKAGE, version="0.1.5")
4341

4442
assert download.bundle.version == "0.1.5"
4543
assert download.bundle.sha256
4644
assert download.url.endswith(".mcpb")
4745

48-
def test_resolve_with_explicit_platform(self):
46+
def test_resolve_with_explicit_platform(self, registry_client):
4947
"""get_bundle_download accepts an explicit platform tuple."""
50-
with MpakClient() as client:
51-
download = client.get_bundle_download(
52-
TEST_PACKAGE,
53-
platform=("linux", "arm64"),
54-
)
48+
download = registry_client.get_bundle_download(
49+
TEST_PACKAGE,
50+
platform=("linux", "arm64"),
51+
)
5552

5653
assert "linux" in download.url
5754
assert "arm64" in download.url
5855

59-
def test_not_found_package(self):
56+
def test_not_found_package(self, registry_client):
6057
"""get_bundle_download raises MpakNotFoundError for non-existent packages."""
61-
with MpakClient() as client:
62-
with pytest.raises(MpakNotFoundError):
63-
client.get_bundle_download("@test/this-package-does-not-exist-xyz")
58+
with pytest.raises(MpakNotFoundError):
59+
registry_client.get_bundle_download("@test/this-package-does-not-exist-xyz")
6460

65-
def test_not_found_version(self):
61+
def test_not_found_version(self, registry_client):
6662
"""get_bundle_download raises MpakNotFoundError for non-existent versions."""
67-
with MpakClient() as client:
68-
with pytest.raises(MpakNotFoundError):
69-
client.get_bundle_download(TEST_PACKAGE, version="99.99.99")
63+
with pytest.raises(MpakNotFoundError):
64+
registry_client.get_bundle_download(TEST_PACKAGE, version="99.99.99")
7065

7166

7267
class TestLoadBundle:
7368
"""Tests for the full download + extract + verify pipeline."""
7469

75-
def test_load_bundle_end_to_end(self):
70+
def test_load_bundle_end_to_end(self, registry_client):
7671
"""load_bundle downloads, verifies SHA256, extracts, and returns manifest."""
7772
dest = Path(tempfile.mkdtemp(prefix="mpak-test-"))
7873
try:
79-
with MpakClient() as client:
80-
manifest = client.load_bundle(TEST_PACKAGE, dest)
74+
manifest = registry_client.load_bundle(TEST_PACKAGE, dest)
8175

8276
# Manifest has expected fields
8377
assert manifest["name"] == TEST_PACKAGE
@@ -91,12 +85,11 @@ def test_load_bundle_end_to_end(self):
9185
finally:
9286
shutil.rmtree(dest, ignore_errors=True)
9387

94-
def test_load_bundle_specific_version(self):
88+
def test_load_bundle_specific_version(self, registry_client):
9589
"""load_bundle works with a pinned version."""
9690
dest = Path(tempfile.mkdtemp(prefix="mpak-test-"))
9791
try:
98-
with MpakClient() as client:
99-
manifest = client.load_bundle(TEST_PACKAGE, dest, version="0.1.5")
92+
manifest = registry_client.load_bundle(TEST_PACKAGE, dest, version="0.1.5")
10093

10194
assert manifest["version"] == "0.1.5"
10295
assert (dest / "manifest.json").exists()
@@ -107,11 +100,10 @@ def test_load_bundle_specific_version(self):
107100
class TestPlatformDetection:
108101
"""Verify platform detection produces values the registry accepts."""
109102

110-
def test_detected_platform_resolves_a_bundle(self):
103+
def test_detected_platform_resolves_a_bundle(self, registry_client):
111104
"""The auto-detected platform should resolve a real bundle."""
112-
with MpakClient() as client:
113-
os_name, arch = client.detect_platform()
114-
download = client.get_bundle_download(TEST_PACKAGE, platform=(os_name, arch))
105+
os_name, arch = registry_client.detect_platform()
106+
download = registry_client.get_bundle_download(TEST_PACKAGE, platform=(os_name, arch))
115107

116108
assert os_name in download.url
117109
assert arch in download.url

packages/sdk-python/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sdk-typescript/tests/client.integration.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import { MpakNotFoundError } from '../src/errors.js';
1717
// Known bundle that exists in the registry
1818
const KNOWN_BUNDLE = '@nimblebraininc/echo';
1919

20+
const registryUrl = process.env.MPAK_REGISTRY_URL ?? 'https://registry.mpak.dev';
21+
2022
describe('MpakClient Integration Tests', () => {
21-
const client = new MpakClient();
23+
const client = new MpakClient({ registryUrl });
2224

2325
describe('Bundle API', () => {
2426
it('searches bundles', async () => {

0 commit comments

Comments
 (0)