Skip to content

Commit

Permalink
Update unit tests to account for the year
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Dec 12, 2024
1 parent 9440ca8 commit 400d51c
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions tests/test_pyproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import typing

from robotpy_installer import pyproject, pypackages
from robotpy_installer.installer import _WPILIB_YEAR as YEAR

from packaging.requirements import Requirement

Expand All @@ -16,12 +17,12 @@ def null_resolver(req: Requirement, env: pypackages.Env) -> typing.List[Requirem

def test_ok():
project = load_project(
"""
f"""
[tool.robotpy]
robotpy_version = "2024.1.1.2"
robotpy_version = "{YEAR}.1.1.2"
"""
)
installed = pypackages.make_packages({"robotpy": "2024.1.1.2"})
installed = pypackages.make_packages({"robotpy": f"{YEAR}.1.1.2"})
assert project.are_requirements_met(
installed, pypackages.roborio_env(), null_resolver
) == (
Expand All @@ -32,49 +33,51 @@ def test_ok():

def test_older_fail():
project = load_project(
"""
f"""
[tool.robotpy]
robotpy_version = "2024.1.1.2"
robotpy_version = "{YEAR}.1.1.2"
"""
)
installed = pypackages.make_packages({"robotpy": "2024.1.1.0"})
installed = pypackages.make_packages({"robotpy": f"{YEAR}.1.1.0"})
assert project.are_requirements_met(
installed, pypackages.roborio_env(), null_resolver
) == (
False,
["robotpy==2024.1.1.2 (found 2024.1.1.0)"],
[f"robotpy=={YEAR}.1.1.2 (found {YEAR}.1.1.0)"],
)


def test_older_and_newer_fail():
project = load_project(
"""
f"""
[tool.robotpy]
robotpy_version = "2024.1.1.2"
robotpy_version = "{YEAR}.1.1.2"
"""
)
installed = pypackages.make_packages({"robotpy": ["2024.1.1.0", "2024.1.1.4"]})
installed = pypackages.make_packages(
{"robotpy": [f"{YEAR}.1.1.0", f"{YEAR}.1.1.4"]}
)
assert project.are_requirements_met(
installed, pypackages.roborio_env(), null_resolver
) == (
False,
["robotpy==2024.1.1.2 (found 2024.1.1.0, 2024.1.1.4)"],
[f"robotpy=={YEAR}.1.1.2 (found {YEAR}.1.1.0, {YEAR}.1.1.4)"],
)


def test_beta_empty_req():
project = load_project(
"""
f"""
[tool.robotpy]
robotpy_version = "2024.1.1.2"
robotpy_version = "{YEAR}.1.1.2"
requires = [
"robotpy-commands-v2"
]
"""
)

installed = pypackages.make_packages(
{"robotpy": "2024.1.1.2", "robotpy-commands-v2": "2024.0.0b4"}
{"robotpy": f"{YEAR}.1.1.2", "robotpy-commands-v2": f"{YEAR}.0.0b4"}
)

assert project.are_requirements_met(
Expand All @@ -87,9 +90,9 @@ def test_beta_empty_req():

def test_env_marker():
project = load_project(
"""
f"""
[tool.robotpy]
robotpy_version = "2024.1.1.2"
robotpy_version = "{YEAR}.1.1.2"
requires = [
"robotpy-opencv; platform_machine == 'roborio'",
"opencv-python; platform_machine != 'roborio'"
Expand All @@ -98,7 +101,7 @@ def test_env_marker():
)

installed = pypackages.make_packages(
{"robotpy": "2024.1.1.2", "robotpy-opencv": "2024.0.0"}
{"robotpy": f"{YEAR}.1.1.2", "robotpy-opencv": f"{YEAR}.0.0"}
)

assert project.are_requirements_met(
Expand Down

0 comments on commit 400d51c

Please sign in to comment.