Skip to content

Commit 094b273

Browse files
committed
Fix 180: Add envvar to click options and add tests
Signed-off-by: Cesar Lizarraga <[email protected]>
1 parent 10a014a commit 094b273

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

tests/test_cli.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,23 +162,27 @@ def test_cli_with_multiple_index_url_and_tilde_req():
162162
)
163163

164164
@pytest.mark.online
165-
def test_cli_with_single_env_var_index_url():
166-
expected_file = test_env.get_test_loc("single-url-env-var-expected.json", must_exist=False)
165+
def test_cli_with_single_env_var_index_url_flag_override():
166+
# Click default is to override env vars via flag as shown here
167+
expected_file = test_env.get_test_loc("single-url-env-var-expected.json", must_exist=True)
167168
specifier = "zipp==3.8.0"
168-
os.environ["PYINSP_INDEX_URL"] = "https://pypi.org/simple"
169+
os.environ["PYINSP_INDEX_URL"] = "https://thirdparty.aboutcode.org/pypi/simple/"
170+
extra_options = [
171+
"--index-url",
172+
"https://pypi.org/simple",
173+
]
169174
check_specs_resolution(
170175
specifier=specifier,
171176
expected_file=expected_file,
172-
extra_options=[],
177+
extra_options=extra_options,
173178
regen=REGEN_TEST_FIXTURES
174179
)
175180
os.unsetenv("PYINSP_INDEX_URL")
176181

177182
@pytest.mark.online
178183
def test_cli_with_single_env_var_index_url_except_pypi_simple():
179184
expected_file = test_env.get_test_loc(
180-
"single-url-env-var-except-simple-expected.json", must_exist=False
181-
)
185+
"single-url-env-var-except-simple-expected.json", must_exist=True)
182186
# using flask since it's not present in thirdparty
183187
specifier = "flask"
184188
os.environ["PYINSP_INDEX_URL"] = "https://thirdparty.aboutcode.org/pypi/simple/"
@@ -190,6 +194,31 @@ def test_cli_with_single_env_var_index_url_except_pypi_simple():
190194
)
191195
os.unsetenv("PYINSP_INDEX_URL")
192196

197+
@pytest.mark.online
198+
def test_cli_with_multiple_env_var_index_url_and_tilde_req():
199+
expected_file = test_env.get_test_loc("tilde_req-expected.json", must_exist=True)
200+
specifier = "zipp~=3.8.0"
201+
os.environ["PYINSP_INDEX_URL"] = "https://pypi.org/simple https://thirdparty.aboutcode.org/pypi/simple/"
202+
check_specs_resolution(
203+
specifier=specifier,
204+
expected_file=expected_file,
205+
extra_options=[],
206+
regen=REGEN_TEST_FIXTURES,
207+
)
208+
os.unsetenv("PYINSP_INDEX_URL")
209+
210+
@pytest.mark.online
211+
def test_cli_with_single_env_var_index_url():
212+
expected_file = test_env.get_test_loc("single-url-env-var-expected.json", must_exist=True)
213+
specifier = "zipp==3.8.0"
214+
os.environ["PYINSP_INDEX_URL"] = "https://pypi.org/simple"
215+
check_specs_resolution(
216+
specifier=specifier,
217+
expected_file=expected_file,
218+
extra_options=[],
219+
regen=REGEN_TEST_FIXTURES
220+
)
221+
os.unsetenv("PYINSP_INDEX_URL")
193222

194223
@pytest.mark.online
195224
def test_cli_with_environment_marker_and_complex_ranges():

0 commit comments

Comments
 (0)