@@ -27,7 +27,7 @@ def _mock_mctx(*modules, environ = {}, read = None):
2727 name = "unittest" ,
2828 arch = "exotic" ,
2929 ),
30- read = read or (lambda _ : "" ),
30+ read = read or (lambda _ : "simple==0.0.1 --hash=sha256:deadbeef " ),
3131 modules = [
3232 struct (
3333 name = modules [0 ].name ,
@@ -75,18 +75,18 @@ def _parse(
7575 experimental_requirement_cycles = {},
7676 experimental_target_platforms = [],
7777 extra_pip_args = [],
78- isolated = False ,
78+ isolated = True ,
7979 netrc = None ,
8080 pip_data_exclude = None ,
8181 python_interpreter = None ,
8282 python_interpreter_target = None ,
83- quiet = False ,
83+ quiet = True ,
8484 requirements_by_platform = {},
8585 requirements_darwin = None ,
8686 requirements_linux = None ,
8787 requirements_lock = None ,
8888 requirements_windows = None ,
89- timeout = 42 ,
89+ timeout = 600 ,
9090 whl_modifications = {},
9191 ** kwargs ):
9292 return struct (
@@ -115,6 +115,10 @@ def _parse(
115115 requirements_windows = requirements_windows ,
116116 timeout = timeout ,
117117 whl_modifications = whl_modifications ,
118+ # The following are covered by other unit tests
119+ experimental_extra_index_urls = [],
120+ parallel_download = False ,
121+ experimental_index_url_overrides = {},
118122 ** kwargs
119123 )
120124
@@ -147,6 +151,87 @@ def _test_simple(env):
147151
148152_tests .append (_test_simple )
149153
154+ def _test_simple_get_index (env ):
155+ got_simpleapi_download_args = []
156+ got_simpleapi_download_kwargs = {}
157+
158+ def mocksimpleapi_download (* args , ** kwargs ):
159+ got_simpleapi_download_args .extend (args )
160+ got_simpleapi_download_kwargs .update (kwargs )
161+ return {
162+ "simple" : struct (
163+ whls = {},
164+ sdists = {
165+ "deadbeef" : struct (
166+ yanked = False ,
167+ filename = "simple-0.0.1.tar.gz" ,
168+ sha256 = "deadbeef" ,
169+ url = "example.org" ,
170+ ),
171+ },
172+ ),
173+ }
174+
175+ pypi = _parse_modules (
176+ env ,
177+ module_ctx = _mock_mctx (
178+ _mod (
179+ name = "rules_python" ,
180+ parse = [
181+ _parse (
182+ hub_name = "pypi" ,
183+ python_version = "3.15" ,
184+ requirements_lock = "requirements.txt" ,
185+ experimental_index_url = "pypi.org" ,
186+ ),
187+ ],
188+ ),
189+ ),
190+ available_interpreters = {
191+ "python_3_15_host" : "unit_test_interpreter_target" ,
192+ },
193+ simpleapi_download = mocksimpleapi_download ,
194+ )
195+
196+ pypi .is_reproducible ().equals (False )
197+ pypi .exposed_packages ().contains_exactly ({"pypi" : ["simple" ]})
198+ pypi .hub_group_map ().contains_exactly ({})
199+ pypi .hub_whl_map ().contains_exactly ({"pypi" : {
200+ "simple" : [
201+ struct (
202+ config_setting = "//_config:is_python_3.15" ,
203+ filename = "simple-0.0.1.tar.gz" ,
204+ repo = "pypi_315_simple_sdist_deadbeef" ,
205+ target_platforms = None ,
206+ version = "3.15" ,
207+ ),
208+ ],
209+ }})
210+ pypi .whl_libraries ().contains_exactly ({
211+ "pypi_315_simple_sdist_deadbeef" : {
212+ "dep_template" : "@pypi//{name}:{target}" ,
213+ "experimental_target_platforms" : [
214+ "cp315_linux_aarch64" ,
215+ "cp315_linux_arm" ,
216+ "cp315_linux_ppc" ,
217+ "cp315_linux_s390x" ,
218+ "cp315_linux_x86_64" ,
219+ "cp315_osx_aarch64" ,
220+ "cp315_osx_x86_64" ,
221+ "cp315_windows_x86_64" ,
222+ ],
223+ "filename" : "simple-0.0.1.tar.gz" ,
224+ "python_interpreter_target" : "unit_test_interpreter_target" ,
225+ "repo" : "pypi_315" ,
226+ "requirement" : "simple==0.0.1" ,
227+ "sha256" : "deadbeef" ,
228+ "urls" : ["example.org" ],
229+ },
230+ })
231+ pypi .whl_mods ().contains_exactly ({})
232+
233+ _tests .append (_test_simple_get_index )
234+
150235def extension_test_suite (name ):
151236 """Create the test suite.
152237
0 commit comments