|
| 1 | +""" |
| 2 | +This file contains classes that both _definitions and lib are referring to. |
| 3 | +To avoid circular imports, it needs to be separate. |
| 4 | +""" |
| 5 | + |
| 6 | +from abc import ABC |
| 7 | +from enum import StrEnum |
| 8 | +from pathlib import Path |
| 9 | + |
| 10 | +from fastapi import APIRouter |
| 11 | + |
| 12 | + |
| 13 | +class GitHubAccount(StrEnum): |
| 14 | + CONDA_FORGE_ORG = "conda-forge-bot-staging" |
| 15 | + BOT_USER = "regro-cf-autotick-bot-staging" |
| 16 | + REGRO_ORG = "regro-staging" |
| 17 | + |
| 18 | + |
| 19 | +class AbstractIntegrationTestHelper(ABC): |
| 20 | + """ |
| 21 | + This is an abstract base class for the IntegrationTestHelper in tests_integration.lib. |
| 22 | + Without this class, we cannot refer to IntegrationTestHelper in the definitions module |
| 23 | + because it would create a circular import. So we refer to this class instead |
| 24 | + and make sure that IntegrationTestHelper inherits from this class. |
| 25 | + """ |
| 26 | + |
| 27 | + def overwrite_feedstock_contents( |
| 28 | + self, feedstock_name: str, source_dir: Path, branch: str = "main" |
| 29 | + ): |
| 30 | + """ |
| 31 | + Overwrite the contents of the feedstock with the contents of the source directory. |
| 32 | + This prunes the entire git history. |
| 33 | +
|
| 34 | + :param feedstock_name: The name of the feedstock repository, without the "-feedstock" suffix. |
| 35 | + :param source_dir: The directory containing the new contents of the feedstock. |
| 36 | + :param branch: The branch to overwrite. |
| 37 | + """ |
| 38 | + pass |
| 39 | + |
| 40 | + def overwrite_github_repository( |
| 41 | + self, |
| 42 | + owner_account: GitHubAccount, |
| 43 | + repo_name: str, |
| 44 | + source_dir: Path, |
| 45 | + branch: str = "main", |
| 46 | + ): |
| 47 | + """ |
| 48 | + Overwrite the contents of the repository with the contents of the source directory. |
| 49 | + This prunes the entire git history. |
| 50 | +
|
| 51 | + :param owner_account: The owner of the repository. |
| 52 | + :param repo_name: The name of the repository. |
| 53 | + :param source_dir: The directory containing the new contents of the repository. |
| 54 | + :param branch: The branch to overwrite. |
| 55 | + """ |
| 56 | + pass |
| 57 | + |
| 58 | + def assert_version_pr_present( |
| 59 | + self, |
| 60 | + feedstock: str, |
| 61 | + new_version: str, |
| 62 | + new_hash: str, |
| 63 | + old_version: str, |
| 64 | + old_hash: str, |
| 65 | + ): |
| 66 | + """ |
| 67 | + Asserts that the bot has opened a version update PR. |
| 68 | +
|
| 69 | + :param feedstock: The feedstock we expect the PR for, without the -feedstock suffix. |
| 70 | + :param new_version: The new version that is expected. |
| 71 | + :param new_hash: The new SHA-256 source artifact hash. |
| 72 | + :param old_version: The old version of the feedstock, to check that it no longer appears in the recipe. |
| 73 | + :param old_hash: The old SHA-256 source artifact hash, to check that it no longer appears in the recipe. |
| 74 | +
|
| 75 | + :raises AssertionError: if the assertion fails |
| 76 | + """ |
| 77 | + pass |
| 78 | + |
| 79 | + |
| 80 | +class TestCase(ABC): |
| 81 | + """ |
| 82 | + Abstract base class for a single test case in a scenario. |
| 83 | + Per test case, there is exactly one instance of this class statically created |
| 84 | + in the definition of the ALL_TEST_CASES list of the feedstock module. |
| 85 | + Note that a test case (i.e. an instance of this class) might be run multiple times, |
| 86 | + so be careful with state you keep in the instance. |
| 87 | + """ |
| 88 | + |
| 89 | + def get_router(self) -> APIRouter: |
| 90 | + """ |
| 91 | + Return the FastAPI router for the test case. |
| 92 | + """ |
| 93 | + pass |
| 94 | + |
| 95 | + def prepare(self, helper: AbstractIntegrationTestHelper): |
| 96 | + """ |
| 97 | + Prepare the test case using the given helper. |
| 98 | + """ |
| 99 | + pass |
| 100 | + |
| 101 | + def validate(self, helper: AbstractIntegrationTestHelper): |
| 102 | + """ |
| 103 | + Validate the test case using the given helper. |
| 104 | + """ |
| 105 | + pass |
0 commit comments