Skip to content

Commit

Permalink
test: remove old tests
Browse files Browse the repository at this point in the history
  • Loading branch information
beckermr committed Sep 16, 2024
1 parent 4ef9456 commit c87f832
Showing 1 changed file with 0 additions and 175 deletions.
175 changes: 0 additions & 175 deletions tests/test_lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
import tempfile
import textwrap
import unittest
import warnings
from collections import OrderedDict
from contextlib import contextmanager
from pathlib import Path

import github
import pytest

import conda_smithy.lint_recipe as linter
Expand All @@ -20,10 +18,6 @@
_thisdir = os.path.abspath(os.path.dirname(__file__))


def is_gh_token_set():
return "GH_TOKEN" in os.environ


@contextmanager
def get_recipe_in_dir(recipe_name: str) -> Path:
base_dir = Path(__file__).parent
Expand Down Expand Up @@ -1819,7 +1813,6 @@ def test_cb3_jinja2_functions(self):
)
assert not lints

@unittest.skipUnless(is_gh_token_set(), "GH_TOKEN not set")
def test_maintainer_exists(self):
lints, _ = linter.lintify_meta_yaml(
{"extra": {"recipe-maintainers": ["support"]}}, conda_forge=True
Expand All @@ -1833,168 +1826,6 @@ def test_maintainer_exists(self):
expected_message = 'Recipe maintainer "isuruf" does not exist'
self.assertNotIn(expected_message, lints)

expected_message = (
"Feedstock with the same name exists in conda-forge."
)
# Check that feedstock exists if staged_recipes
lints, _ = linter.lintify_meta_yaml(
{"package": {"name": "python"}},
recipe_dir="python",
conda_forge=True,
)
self.assertIn(expected_message, lints)
lints, _ = linter.lintify_meta_yaml(
{"package": {"name": "python"}},
recipe_dir="python",
conda_forge=False,
)
self.assertNotIn(expected_message, lints)
# No lint if in a feedstock
lints, _ = linter.lintify_meta_yaml(
{"package": {"name": "python"}},
recipe_dir="recipe",
conda_forge=True,
)
self.assertNotIn(expected_message, lints)
lints, _ = linter.lintify_meta_yaml(
{"package": {"name": "python"}},
recipe_dir="recipe",
conda_forge=False,
)
self.assertNotIn(expected_message, lints)

# Make sure there's no feedstock named python1 before proceeding
gh = github.Github(os.environ["GH_TOKEN"])
cf = gh.get_user("conda-forge")
try:
cf.get_repo("python1-feedstock")
feedstock_exists = True
except github.UnknownObjectException:
feedstock_exists = False

if feedstock_exists:
warnings.warn(
"There's a feedstock named python1, but tests assume that there isn't"
)
else:
lints, _ = linter.lintify_meta_yaml(
{"package": {"name": "python1"}},
recipe_dir="python",
conda_forge=True,
)
self.assertNotIn(expected_message, lints)

# Test bioconda recipe checking
expected_message = (
"Recipe with the same name exists in bioconda: "
"please discuss with @conda-forge/bioconda-recipes."
)
bio = gh.get_user("bioconda").get_repo("bioconda-recipes")
r = "samtools"
try:
bio.get_dir_contents(f"recipe/{r}")
except github.UnknownObjectException:
warnings.warn(
f"There's no bioconda recipe named {r}, but tests assume that there is"
)
else:
# Check that feedstock exists if staged_recipes
lints, _ = linter.lintify_meta_yaml(
{"package": {"name": r}}, recipe_dir=r, conda_forge=True
)
self.assertIn(expected_message, lints)
lints, _ = linter.lintify_meta_yaml(
{"package": {"name": r}}, recipe_dir=r, conda_forge=False
)
self.assertNotIn(expected_message, lints)
# No lint if in a feedstock
lints, _ = linter.lintify_meta_yaml(
{"package": {"name": r}}, recipe_dir="recipe", conda_forge=True
)
self.assertNotIn(expected_message, lints)
lints, _ = linter.lintify_meta_yaml(
{"package": {"name": r}},
recipe_dir="recipe",
conda_forge=False,
)
self.assertNotIn(expected_message, lints)
# No lint if the name isn't specified
lints, _ = linter.lintify_meta_yaml(
{}, recipe_dir=r, conda_forge=True
)
self.assertNotIn(expected_message, lints)

r = "this-will-never-exist"
try:
bio.get_dir_contents(f"recipes/{r}")
except github.UnknownObjectException:
lints, _ = linter.lintify_meta_yaml(
{"package": {"name": r}}, recipe_dir=r, conda_forge=True
)
self.assertNotIn(expected_message, lints)
else:
warnings.warn(
f"There's a bioconda recipe named {r}, but tests assume that there isn't"
)

expected_message = (
"A conda package with same name (numpy) already exists."
)
lints, hints = linter.lintify_meta_yaml(
{
"package": {"name": "this-will-never-exist"},
"source": {
"url": "https://pypi.io/packages/source/n/numpy/numpy-1.26.4.tar.gz"
},
},
recipe_dir="recipes/foo",
conda_forge=True,
)
self.assertIn(expected_message, hints)

# check that this doesn't choke
lints, hints = linter.lintify_meta_yaml(
{
"package": {"name": "this-will-never-exist"},
"source": {
"url": [
"https://pypi.io/packages/source/n/numpy/numpy-1.26.4.tar.gz"
]
},
},
recipe_dir="recipes/foo",
conda_forge=True,
)

@unittest.skipUnless(is_gh_token_set(), "GH_TOKEN not set")
def test_maintainer_participation(self):
# Mocking PR and maintainer data
os.environ["STAGED_RECIPES_PR_NUMBER"] = "1" # Example PR number
maintainers = ["pelson", "isuruf"]

try:
# Running the linter function
lints, _ = linter.lintify_meta_yaml(
{"extra": {"recipe-maintainers": maintainers}},
recipe_dir="python",
conda_forge=True,
)

# Expected message if a maintainer has not participated
expected_message = (
"The following maintainers have not yet confirmed that they are willing to be listed here: "
"isuruf. Please ask them to comment on this PR if they are."
)
self.assertIn(expected_message, lints)

expected_message = (
"The following maintainers have not yet confirmed that they are willing to be listed here: "
"pelson, isuruf. Please ask them to comment on this PR if they are."
)
self.assertNotIn(expected_message, lints)
finally:
del os.environ["STAGED_RECIPES_PR_NUMBER"]

def test_bad_subheader(self):
expected_message = (
"The {} section contained an unexpected "
Expand Down Expand Up @@ -2086,7 +1917,6 @@ def test_recipe_v1_version_with_context(self):
lints, hints = linter.lintify_meta_yaml(meta, recipe_version=1)
assert any(lint.startswith(expected_message) for lint in lints)

@unittest.skipUnless(is_gh_token_set(), "GH_TOKEN not set")
def test_examples(self):
msg = (
"Please move the recipe out of the example dir and into its "
Expand Down Expand Up @@ -2268,7 +2098,6 @@ def test_build_sh_with_shellcheck_findings(self):
)
assert len(hints) < 100

@unittest.skipUnless(is_gh_token_set(), "GH_TOKEN not set")
def test_mpl_base_hint(self):
meta = {
"requirements": {
Expand All @@ -2279,7 +2108,6 @@ def test_mpl_base_hint(self):
expected = "Recipes should usually depend on `matplotlib-base`"
self.assertTrue(any(hint.startswith(expected) for hint in hints))

@unittest.skipUnless(is_gh_token_set(), "GH_TOKEN not set")
def test_mpl_base_hint_outputs(self):
meta = {
"outputs": [
Expand Down Expand Up @@ -2513,7 +2341,6 @@ def assert_jinja(jinja_var, is_good=True):
assert_jinja('{% set version= "0.27.3"%}', is_good=False)


@unittest.skipUnless(is_gh_token_set(), "GH_TOKEN not set")
def test_lint_no_builds():
expected_message = "The feedstock has no `.ci_support` files and "

Expand Down Expand Up @@ -2542,7 +2369,6 @@ def test_lint_no_builds():
assert not any(lint.startswith(expected_message) for lint in lints)


@unittest.skipUnless(is_gh_token_set(), "GH_TOKEN not set")
def test_lint_duplicate_cfyml():
expected_message = (
"The ``conda-forge.yml`` file is not allowed to have duplicate keys."
Expand Down Expand Up @@ -2771,7 +2597,6 @@ def test_v1_package_name_version():
assert lint_2 in lints


@unittest.skipUnless(is_gh_token_set(), "GH_TOKEN not set")
@pytest.mark.parametrize("remove_top_level", [True, False])
@pytest.mark.parametrize(
"outputs_to_add, outputs_expected_hints",
Expand Down

0 comments on commit c87f832

Please sign in to comment.