Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aignas committed Oct 23, 2024
1 parent cfcc8c5 commit cf76913
Showing 1 changed file with 63 additions and 4 deletions.
67 changes: 63 additions & 4 deletions tests/pypi/extension/extension_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _mock_mctx(*modules, environ = {}, read = None):
name = "unittest",
arch = "exotic",
),
read = read or (lambda _: "simple==0.0.1 --hash=sha256:deadbeef"),
read = read or (lambda _: "simple==0.0.1 --hash=sha256:deadbeef --hash=sha256:deadbaaf"),
modules = [
struct(
name = modules[0].name,
Expand Down Expand Up @@ -168,7 +168,7 @@ def _test_simple(env):
"dep_template": "@pypi//{name}:{target}",
"python_interpreter_target": "unit_test_interpreter_target",
"repo": "pypi_315",
"requirement": "simple==0.0.1 --hash=sha256:deadbeef",
"requirement": "simple==0.0.1 --hash=sha256:deadbeef --hash=sha256:deadbaaf",
},
})
pypi.whl_mods().contains_exactly({})
Expand Down Expand Up @@ -359,7 +359,14 @@ def _test_simple_get_index(env):
got_simpleapi_download_kwargs.update(kwargs)
return {
"simple": struct(
whls = {},
whls = {
"deadbaaf": struct(
yanked = False,
filename = "simple-0.0.1-py3-none-any.whl",
sha256 = "deadbaaf",
url = "example.org/whl",
),
},
sdists = {
"deadbeef": struct(
yanked = False,
Expand All @@ -385,6 +392,11 @@ def _test_simple_get_index(env):
),
],
),
read = lambda _: """\
# Keep sorted
simple==0.0.1 --hash=sha256:deadbeef --hash=sha256:deadbaaf
some_pkg==0.0.1
""",
),
available_interpreters = {
"python_3_15_host": "unit_test_interpreter_target",
Expand All @@ -393,10 +405,17 @@ def _test_simple_get_index(env):
)

pypi.is_reproducible().equals(False)
pypi.exposed_packages().contains_exactly({"pypi": ["simple"]})
pypi.exposed_packages().contains_exactly({"pypi": ["simple", "some_pkg"]})
pypi.hub_group_map().contains_exactly({"pypi": {}})
pypi.hub_whl_map().contains_exactly({"pypi": {
"simple": [
struct(
config_setting = "//_config:is_python_3.15",
filename = "simple-0.0.1-py3-none-any.whl",
repo = "pypi_315_simple_py3_none_any_deadbaaf",
target_platforms = None,
version = "3.15",
),
struct(
config_setting = "//_config:is_python_3.15",
filename = "simple-0.0.1.tar.gz",
Expand All @@ -405,8 +424,29 @@ def _test_simple_get_index(env):
version = "3.15",
),
],
"some_pkg": [
],
}})
pypi.whl_libraries().contains_exactly({
"pypi_315_simple_py3_none_any_deadbaaf": {
"dep_template": "@pypi//{name}:{target}",
"experimental_target_platforms": [
"cp315_linux_aarch64",
"cp315_linux_arm",
"cp315_linux_ppc",
"cp315_linux_s390x",
"cp315_linux_x86_64",
"cp315_osx_aarch64",
"cp315_osx_x86_64",
"cp315_windows_x86_64",
],
"filename": "simple-0.0.1-py3-none-any.whl",
"python_interpreter_target": "unit_test_interpreter_target",
"repo": "pypi_315",
"requirement": "simple==0.0.1",
"sha256": "deadbaaf",
"urls": ["example.org/whl"],
},
"pypi_315_simple_sdist_deadbeef": {
"dep_template": "@pypi//{name}:{target}",
"experimental_target_platforms": [
Expand All @@ -426,8 +466,27 @@ def _test_simple_get_index(env):
"sha256": "deadbeef",
"urls": ["example.org"],
},
"pypi_315_some_pkg": {
"dep_template": "@pypi//{name}:{target}",
"python_interpreter_target": "unit_test_interpreter_target",
"repo": "pypi_315",
"requirement": "some_pkg==0.0.1",
},
})
pypi.whl_mods().contains_exactly({})
env.expect.that_dict(got_simpleapi_download_kwargs).contains_exactly({
"attr": struct(
auth_patterns = {},
envsubst = {},
extra_index_urls = [],
index_url = "pypi.org",
index_url_overrides = {},
netrc = None,
sources = ["simple", "some_pkg"],
),
"cache": {},
"parallel_download": False,
})

_tests.append(_test_simple_get_index)

Expand Down

0 comments on commit cf76913

Please sign in to comment.