Skip to content

Commit 6f50f42

Browse files
committed
add test for parse_requirements_tests
1 parent 2128d54 commit 6f50f42

File tree

1 file changed

+87
-1
lines changed

1 file changed

+87
-1
lines changed

tests/pypi/parse_requirements/parse_requirements_tests.bzl

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ foo==0.0.1 \
2626
--hash=sha256:deadb00f
2727
""",
2828
"requirements_direct": """\
29-
foo[extra] @ https://some-url
29+
foo[extra] @ https://some-url/package.whl
30+
bar @ https://example.org/bar-1.0.whl --hash=sha256:deadbeef
31+
baz @ https://test.com/baz-2.0.whl; python_version < "3.8" --hash=sha256:deadb00f
3032
""",
3133
"requirements_extra_args": """\
3234
--index-url=example.org
@@ -124,6 +126,90 @@ def _test_simple(env):
124126

125127
_tests.append(_test_simple)
126128

129+
def _test_direct_urls(env):
130+
got = parse_requirements(
131+
ctx = _mock_ctx(),
132+
requirements_by_platform = {
133+
"requirements_direct": ["linux_x86_64"],
134+
},
135+
)
136+
env.expect.that_dict(got).contains_exactly({
137+
"foo": [
138+
struct(
139+
distribution = "foo",
140+
extra_pip_args = [],
141+
sdist = None,
142+
is_exposed = True,
143+
srcs = struct(
144+
marker = "",
145+
requirement = "foo[extra] @ https://some-url/package.whl",
146+
requirement_line = "foo[extra] @ https://some-url/package.whl",
147+
shas = [],
148+
version = "",
149+
url = "https://some-url/package.whl",
150+
filename = "package.whl",
151+
),
152+
target_platforms = ["linux_x86_64"],
153+
whls = [struct(
154+
url = "https://some-url/package.whl",
155+
filename = "package.whl",
156+
sha256 = "",
157+
yanked = False,
158+
)],
159+
),
160+
],
161+
"bar": [
162+
struct(
163+
distribution = "bar",
164+
extra_pip_args = [],
165+
sdist = None,
166+
is_exposed = True,
167+
srcs = struct(
168+
marker = "",
169+
requirement = "bar @ https://example.org/bar-1.0.whl --hash=sha256:deadbeef",
170+
requirement_line = "bar @ https://example.org/bar-1.0.whl --hash=sha256:deadbeef",
171+
shas = ["deadbeef"],
172+
version = "",
173+
url = "https://example.org/bar-1.0.whl",
174+
filename = "bar-1.0.whl",
175+
),
176+
target_platforms = ["linux_x86_64"],
177+
whls = [struct(
178+
url = "https://example.org/bar-1.0.whl",
179+
filename = "bar-1.0.whl",
180+
sha256 = "deadbeef",
181+
yanked = False,
182+
)],
183+
),
184+
],
185+
"baz": [
186+
struct(
187+
distribution = "baz",
188+
extra_pip_args = [],
189+
sdist = None,
190+
is_exposed = True,
191+
srcs = struct(
192+
marker = "python_version < \"3.8\"",
193+
requirement = "baz @ https://test.com/baz-2.0.whl --hash=sha256:deadb00f",
194+
requirement_line = "baz @ https://test.com/baz-2.0.whl --hash=sha256:deadb00f",
195+
shas = ["deadb00f"],
196+
version = "",
197+
url = "https://test.com/baz-2.0.whl",
198+
filename = "baz-2.0.whl",
199+
),
200+
target_platforms = ["linux_x86_64"],
201+
whls = [struct(
202+
url = "https://test.com/baz-2.0.whl",
203+
filename = "baz-2.0.whl",
204+
sha256 = "deadb00f",
205+
yanked = False,
206+
)],
207+
),
208+
],
209+
})
210+
211+
_tests.append(_test_direct_urls)
212+
127213
def _test_extra_pip_args(env):
128214
got = parse_requirements(
129215
ctx = _mock_ctx(),

0 commit comments

Comments
 (0)