Skip to content

Commit

Permalink
use pytest, add tests for AzureRunnerSettings and CondaBuildConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
ytausch committed May 13, 2024
1 parent 01aac59 commit 3e87b5d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
1 change: 0 additions & 1 deletion conda_smithy/lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,6 @@ def main_debug():
lints, hints = main(rel_path, False, True)
messages = []
if lints:
all_pass = False
messages.append(
"\nFor **{}**:\n\n{}".format(
rel_path, "\n".join("* {}".format(lint) for lint in lints)
Expand Down
43 changes: 34 additions & 9 deletions tests/test_lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ def assert_jinja(jinja_var, is_good=True):
assert_jinja('{% set version= "0.27.3"%}', is_good=False)


class TestLintifyForgeYamlHintExtraFields(unittest.TestCase):
class TestLintifyForgeYamlHintExtraFields:
def test_extra_build_platforms_platform(self):
forge_yml = {
"build_platform": {
Expand All @@ -1665,11 +1665,9 @@ def test_extra_build_platforms_platform(self):

hints = linter._forge_yaml_hint_extra_fields(forge_yml)

self.assertEquals(len(hints), 1)
assert len(hints) == 1

self.assertIn(
"Unexpected key build_platform.UNKNOWN_PLATFORM", hints[0]
)
assert "Unexpected key build_platform.UNKNOWN_PLATFORM" in hints[0]

def test_extra_os_version_platform(self):
forge_yml = {
Expand All @@ -1680,9 +1678,9 @@ def test_extra_os_version_platform(self):

hints = linter._forge_yaml_hint_extra_fields(forge_yml)

self.assertEquals(len(hints), 1)
assert len(hints) == 1

self.assertIn("Unexpected key os_version.UNKNOWN_PLATFORM_2", hints[0])
assert "Unexpected key os_version.UNKNOWN_PLATFORM_2" in hints[0]

def test_extra_provider_platform(self):
forge_yml = {
Expand All @@ -1694,9 +1692,36 @@ def test_extra_provider_platform(self):

hints = linter._forge_yaml_hint_extra_fields(forge_yml)

self.assertEquals(len(hints), 1)
assert len(hints) == 1

assert "Unexpected key provider.UNKNOWN_PLATFORM_3" in hints[0]

@pytest.mark.parametrize(
"top_field", ["settings_linux", "settings_osx", "settings_win"]
)
def test_extra_azure_runner_settings_no_hint(self, top_field: str):
forge_yml = {
"azure": {
top_field: {
"EXTRA_FIELD": "EXTRA_VALUE",
}
}
}

hints = linter._forge_yaml_hint_extra_fields(forge_yml)

assert len(hints) == 0

def test_extra_conda_build_config_no_hint(self):
forge_yml = {
"conda_build": {
"EXTRA_FIELD": "EXTRA_VALUE",
}
}

hints = linter._forge_yaml_hint_extra_fields(forge_yml)

self.assertIn("Unexpected key provider.UNKNOWN_PLATFORM_3", hints[0])
assert len(hints) == 0


if __name__ == "__main__":
Expand Down

0 comments on commit 3e87b5d

Please sign in to comment.