#!/usr/bin/env python3 from lock_mods import * class TestDependency: def test_from_str_dependency_type(self): assert Dependency.from_str("a") == Dependency( dependency_type=DependencyType.HARD, dependent_on="a", version_constraint_type=VersionConstraintType.NONE, version_constraint=None, ) assert Dependency.from_str("! a") == Dependency( dependency_type=DependencyType.INCOMPATIBLE_WITH, dependent_on="a", version_constraint_type=VersionConstraintType.NONE, version_constraint=None, ) assert Dependency.from_str("? a") == Dependency( dependency_type=DependencyType.OPTIONAL, dependent_on="a", version_constraint_type=VersionConstraintType.NONE, version_constraint=None, ) assert Dependency.from_str("(?) a") == Dependency( dependency_type=DependencyType.HIDDEN_OPTIONAL, dependent_on="a", version_constraint_type=VersionConstraintType.NONE, version_constraint=None, ) assert Dependency.from_str("~ a") == Dependency( dependency_type=DependencyType.LOAD_ORDER_IGNORED, dependent_on="a", version_constraint_type=VersionConstraintType.NONE, version_constraint=None, ) def test_from_str_version_constraint(self): assert Dependency.from_str("hactorio") == Dependency( dependency_type=DependencyType.HARD, dependent_on="hactorio", version_constraint_type=VersionConstraintType.NONE, version_constraint=None, ) assert Dependency.from_str("hactorio > 0.1") == Dependency( dependency_type=DependencyType.HARD, dependent_on="hactorio", version_constraint_type=VersionConstraintType.GREATER, version_constraint="0.1", ) assert Dependency.from_str("hactorio >= 0.1") == Dependency( dependency_type=DependencyType.HARD, dependent_on="hactorio", version_constraint_type=VersionConstraintType.GREATER_EQUAL, version_constraint="0.1", ) assert Dependency.from_str("hactorio < 0.1") == Dependency( dependency_type=DependencyType.HARD, dependent_on="hactorio", version_constraint_type=VersionConstraintType.LESS, version_constraint="0.1", ) assert Dependency.from_str("hactorio <= 0.1") == Dependency( dependency_type=DependencyType.HARD, dependent_on="hactorio", version_constraint_type=VersionConstraintType.LESS_EQUAL, version_constraint="0.1", ) def test_from_str_complex(self): assert Dependency.from_str("(?) hactorio <= 0.1") == Dependency( dependency_type=DependencyType.HIDDEN_OPTIONAL, dependent_on="hactorio", version_constraint_type=VersionConstraintType.LESS_EQUAL, version_constraint="0.1", )