Skip to content

Commit 3386c4f

Browse files
committed
fix: adjust for new settings module
ir
1 parent 32d0eae commit 3386c4f

File tree

5 files changed

+33
-26
lines changed

5 files changed

+33
-26
lines changed

tests_integration/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ overwrite the feedstock repository in the test environment. The `IntegrationTest
5959
with the test environment.
6060

6161
2. A `router` object to define mock responses for specific HTTP requests. All web requests are intercepted by an HTTP proxy.
62-
Consult `tests_integration.lib.shared.TRANSPARENT_URLS` to define URLs that should not be intercepted.
62+
Consult `tests_integration.lib.shared.get_transparent_urls` to define URLs that should not be intercepted.
6363

6464
3. A function `validate(helper: IntegrationTestHelper)` for validating the state after the bot has run.
6565
The `IntegrationTestHelper` provides convenience methods such as `assert_version_pr_present` to check for the presence

tests_integration/lib/shared.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from fastapi import APIRouter
77

8-
from conda_forge_tick.settings import GITHUB_RUNNER_DEBUG, GRAPH_REPO_DEFAULT_BRANCH
8+
from conda_forge_tick.settings import settings
99

1010

1111
class GitHubAccount(StrEnum):
@@ -44,32 +44,14 @@ class GitHubAccount(StrEnum):
4444

4545
FEEDSTOCK_SUFFIX = "-feedstock"
4646

47-
TRANSPARENT_URLS = {
48-
f"https://raw.githubusercontent.com/regro/cf-graph-countyfair/{GRAPH_REPO_DEFAULT_BRANCH}/mappings/pypi/name_mapping.yaml",
49-
f"https://raw.githubusercontent.com/regro/cf-graph-countyfair/{GRAPH_REPO_DEFAULT_BRANCH}/mappings/pypi/grayskull_pypi_mapping.json",
50-
"https://api.github.com/*",
51-
"https://pypi.io/packages/source/*",
52-
"https://pypi.org/packages/source/*",
53-
"https://files.pythonhosted.org/packages/*",
54-
"https://api.anaconda.org/package/conda-forge/conda-forge-pinning",
55-
"https://api.anaconda.org/download/conda-forge/conda-forge-pinning/*",
56-
"https://binstar-cio-packages-prod.s3.amazonaws.com/*",
57-
}
58-
"""
59-
Requests to those are forwarded to the actual upstream URLs in the tests.
60-
Use Unix filename patterns (provided by fnmatch) to specify wildcards:
61-
62-
https://docs.python.org/3/library/fnmatch.html
63-
"""
64-
6547

6648
def setup_logging(default_level: int):
6749
"""
6850
Set up the Python logging module.
6951
Uses the passed log level as the default level.
7052
If running within GitHub Actions and the workflow runs in debug mode, the log level is never set above DEBUG.
7153
"""
72-
if GITHUB_RUNNER_DEBUG and default_level > logging.DEBUG:
54+
if settings().github_runner_debug and default_level > logging.DEBUG:
7355
level = logging.DEBUG
7456
else:
7557
level = default_level
@@ -84,6 +66,28 @@ def is_user_account(account: GitHubAccount) -> bool:
8466
return IS_USER_ACCOUNT[account]
8567

8668

69+
def get_transparent_urls() -> set[str]:
70+
"""
71+
Returns URLs which should be forwarded to the actual upstream URLs in the tests.
72+
Unix filename patterns (provided by fnmatch) are used to specify wildcards:
73+
https://docs.python.org/3/library/fnmatch.html
74+
"""
75+
76+
# this is not a constant because the graph_repo_default_branch setting is dynamic
77+
graph_repo_default_branch = settings().graph_repo_default_branch
78+
return {
79+
f"https://raw.githubusercontent.com/regro/cf-graph-countyfair/{graph_repo_default_branch}/mappings/pypi/name_mapping.yaml",
80+
f"https://raw.githubusercontent.com/regro/cf-graph-countyfair/{graph_repo_default_branch}/mappings/pypi/grayskull_pypi_mapping.json",
81+
"https://api.github.com/*",
82+
"https://pypi.io/packages/source/*",
83+
"https://pypi.org/packages/source/*",
84+
"https://files.pythonhosted.org/packages/*",
85+
"https://api.anaconda.org/package/conda-forge/conda-forge-pinning",
86+
"https://api.anaconda.org/download/conda-forge/conda-forge-pinning/*",
87+
"https://binstar-cio-packages-prod.s3.amazonaws.com/*",
88+
}
89+
90+
8791
def get_global_router():
8892
"""
8993
Returns the global FastAPI router to be included in all test scenarios.

tests_integration/mock_server_addon.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@
1919
from tests_integration.collect_test_scenarios import get_test_scenario
2020
from tests_integration.lib.shared import (
2121
ENV_TEST_SCENARIO_ID,
22-
TRANSPARENT_URLS,
2322
VIRTUAL_PROXY_HOSTNAME,
2423
VIRTUAL_PROXY_PORT,
2524
get_global_router,
25+
get_transparent_urls,
2626
)
2727

2828
LOGGER = logging.getLogger(__name__)
2929

3030

3131
def request(flow: HTTPFlow):
32-
if any(fnmatch.fnmatch(flow.request.url, pattern) for pattern in TRANSPARENT_URLS):
32+
if any(
33+
fnmatch.fnmatch(flow.request.url, pattern) for pattern in get_transparent_urls()
34+
):
3335
return
3436
flow.request.path = f"/{flow.request.host}{flow.request.path}"
3537
flow.request.host = VIRTUAL_PROXY_HOSTNAME

tests_integration/step_prepare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from github import Github
1212

13-
from conda_forge_tick.settings import GRAPH_REPO_DEFAULT_BRANCH
13+
from conda_forge_tick.settings import settings
1414
from tests_integration.lib.integration_test_helper import IntegrationTestHelper
1515
from tests_integration.lib.shared import (
1616
FEEDSTOCK_SUFFIX,
@@ -41,7 +41,7 @@ def reset_cf_graph():
4141
GitHubAccount.REGRO_ORG,
4242
"cf-graph-countyfair",
4343
Path(__file__).parent / "resources" / "empty-graph",
44-
branch=GRAPH_REPO_DEFAULT_BRANCH,
44+
branch=settings().graph_repo_default_branch,
4545
)
4646

4747

tests_integration/test_integration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pytest
99
from xprocess import ProcessStarter, XProcess
1010

11+
from conda_forge_tick.settings import settings
1112
from tests_integration import setup_repositories
1213
from tests_integration.collect_test_scenarios import get_test_scenario
1314
from tests_integration.lib.shared import setup_logging
@@ -107,7 +108,7 @@ def in_fresh_cf_graph():
107108
with tempfile.TemporaryDirectory() as tmpdir_s:
108109
tmpdir = Path(tmpdir_s)
109110

110-
cf_graph_repo = os.environ["CF_TICK_GRAPH_GITHUB_BACKEND_REPO"]
111+
cf_graph_repo = settings().graph_github_backend_repo
111112
subprocess.run(
112113
[
113114
"git",

0 commit comments

Comments
 (0)