-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathbase_classes.py
More file actions
262 lines (226 loc) · 7.39 KB
/
base_classes.py
File metadata and controls
262 lines (226 loc) · 7.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
"""
Module providing base classes for the integration tests.
Both _definitions and lib refer to this module.
"""
import os
from abc import ABC
from enum import StrEnum
from pathlib import Path
from fastapi import APIRouter
class GitHubAccount(StrEnum):
CONDA_FORGE_ORG = (
os.environ.get("GITHUB_ACCOUNT_CONDA_FORGE_ORG") or "conda-forge-bot-staging"
)
BOT_USER = (
os.environ.get("GITHUB_ACCOUNT_BOT_USER") or "regro-cf-autotick-bot-staging"
)
REGRO_ORG = os.environ.get("GITHUB_ACCOUNT_REGRO_ORG") or "regro-staging"
class AbstractIntegrationTestHelper(ABC):
"""Abstract base class for the IntegrationTestHelper in tests_integration.lib.
Without this class, we cannot refer to IntegrationTestHelper in the definitions module
because it would create a circular import. So we refer to this class instead
and make sure that IntegrationTestHelper inherits from this class.
"""
def overwrite_feedstock_contents(
self, feedstock_name: str, source_dir: Path, branch: str = "main"
):
"""
Overwrite the contents of the feedstock with the contents of the source directory.
This prunes the entire git history.
Parameters
----------
feedstock_name
The name of the feedstock repository, without the "-feedstock" suffix.
source_dir
The directory containing the new contents of the feedstock.
branch
The branch to overwrite.
"""
pass
def overwrite_github_repository(
self,
owner_account: GitHubAccount,
repo_name: str,
source_dir: Path,
branch: str = "main",
):
"""
Overwrite the contents of the repository with the contents of the source directory.
This prunes the entire git history.
Parameters
----------
owner_account
The owner of the repository.
repo_name
The name of the repository.
source_dir
The directory containing the new contents of the repository.
branch
The branch to overwrite.
"""
pass
def assert_version_pr_present_v0(
self,
feedstock: str,
new_version: str,
new_hash: str,
old_version: str,
old_hash: str,
) -> None:
"""
Assert that the bot has opened a version update PR for a v0 recipe.
Parameters
----------
feedstock
The feedstock we expect the PR for, without the -feedstock suffix.
new_version
The new version that is expected.
new_hash
The new SHA-256 source artifact hash.
old_version
The old version of the feedstock, to check that it no longer appears in the recipe.
old_hash
The old SHA-256 source artifact hash, to check that it no longer appears in the recipe.
Raises
------
AssertionError
If the assertion fails.
"""
pass
def assert_version_pr_present_v1(
self,
feedstock: str,
new_version: str,
new_hash: str,
old_version: str,
old_hash: str,
):
"""
Assert that the bot has opened a version update PR for a v1 recipe.
Parameters
----------
feedstock
The feedstock we expect the PR for, without the -feedstock suffix.
new_version
The new version that is expected.
new_hash
The new SHA-256 source artifact hash.
old_version
The old version of the feedstock, to check that it no longer appears in the recipe.
old_hash
The old SHA-256 source artifact hash, to check that it no longer appears in the recipe.
Raises
------
AssertionError
If the assertion fails.
"""
pass
def assert_bot_pr_contents_v1(
self,
feedstock: str,
title_contains: str,
included: list[str],
not_included: list[str],
):
"""
Assert that the bot has opened a PR for a v1 recipe and some
defined strings are either included or not included in the new recipe.
Parameters
----------
feedstock
The feedstock we expect the PR for, without the -feedstock suffix.
title_contains
A string that must be included in the PR title.
included
A list of strings that must be included in the new recipe.
not_included
A list of strings that must not be present in the new recipe.
Raises
------
AssertionError
If the assertion fails.
"""
pass
def assert_new_run_requirements_equal_v1(
self,
feedstock: str,
new_version: str,
run_requirements: list[str],
):
"""
Assert that the new run requirements in the version update PR match our expectations.
Parameters
----------
feedstock
The feedstock we expect the PR for, without the -feedstock suffix.
new_version
The new version that is expected.
run_requirements
A list of requirements.
Raises
------
AssertionError
If the assertion fails.
"""
pass
def assert_pr_body_not_contains(
self,
feedstock: str,
new_version: str,
not_included: list[str],
):
"""
Assert that the version update PR body does NOT contain certain strings.
Parameters
----------
feedstock
The feedstock we expect the PR for, without the -feedstock suffix.
new_version
The new version that is expected.
not_included
A list of strings that must NOT be present in the PR body.
Raises
------
AssertionError
If any of the strings are found in the PR body.
"""
pass
def assert_pr_title_starts_with(
self,
feedstock: str,
pr_title_contains: str,
expected_prefix: str,
):
"""
Assert that a PR title starts with an expected prefix.
Parameters
----------
feedstock
The feedstock we expect the PR for, without the -feedstock suffix.
pr_title_contains
A string that must be included in the PR title to identify the PR.
expected_prefix
The expected prefix that the PR title should start with.
Raises
------
AssertionError
If the assertion fails.
"""
pass
class TestCase(ABC):
"""
Abstract base class for a single test case in a scenario.
Per test case, there is exactly one instance of this class statically created
in the definition of the ALL_TEST_CASES list of the feedstock module.
Note that a test case (i.e. an instance of this class) might be run multiple times,
so be careful with state you keep in the instance.
"""
def get_router(self) -> APIRouter:
"""Return the FastAPI router for the test case."""
pass
def prepare(self, helper: AbstractIntegrationTestHelper):
"""Prepare the test case using the given helper."""
pass
def validate(self, helper: AbstractIntegrationTestHelper):
"""Validate the test case using the given helper."""
pass