1010
1111import pytest
1212
13- from mpak import MpakClient , MpakNotFoundError
13+ from mpak import MpakNotFoundError
1414from mpak .types import BundleDownloadResponse
1515
1616# Well-known bundle that exists on the registry
2222class 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
7267class 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):
107100class 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
0 commit comments