def test_can_understand_wheel_dependecies( current_platform: TargetPlatform, requirement_parser: RequirementParser): runtime_dependencies = RequirementSet(current_platform) runtime_dependency = requirement_parser.parse("runtime_dependency") runtime_dependencies.add(runtime_dependency) build_dependencies = RequirementSet(current_platform) build_dependency = requirement_parser.parse("build_dependency") build_dependencies.add(build_dependency) wheel = Wheel( name="testpackage", version="", deps=runtime_dependencies, target_platform=current_platform, license="", homepage="", description="", build_dependencies=build_dependencies, ) requirement = requirement_parser.parse("testpackage") dependency_graph = DependencyGraph() dependency_graph.import_wheel(wheel, requirement_parser) assert dependency_graph.is_buildtime_dependency(requirement, build_dependency) assert dependency_graph.is_runtime_dependency(requirement, runtime_dependency)
def test_can_set_runtime_dependencies(package_a: Requirement, package_b: Requirement, dependency_graph: DependencyGraph): dependency_graph.set_runtime_dependency(dependent=package_a, dependency=package_b) assert dependency_graph.is_runtime_dependency(dependent=package_a, dependency=package_b)
def check_dependency_graph(self, dependency_graph: DependencyGraph, requirement_parser: RequirementParser): self.assertTrue( dependency_graph.is_runtime_dependency( requirement_parser.parse("django"), requirement_parser.parse("pytz"), ))
def test_build_time_dependencies_dont_show_up_as_runtime_dependencies( package_a: Requirement, package_b: Requirement, package_c: Requirement, dependency_graph: DependencyGraph, ): dependency_graph.set_runtime_dependency(dependent=package_a, dependency=package_b) dependency_graph.set_buildtime_dependency(dependent=package_b, dependency=package_c) assert not dependency_graph.is_runtime_dependency(dependent=package_a, dependency=package_c)
def test_can_detect_indirect_runtime_dependencies( package_a: Requirement, package_b: Requirement, package_c: Requirement, dependency_graph: DependencyGraph, ) -> None: dependency_graph.set_runtime_dependency(dependent=package_a, dependency=package_b) dependency_graph.set_runtime_dependency(dependent=package_b, dependency=package_c) assert dependency_graph.is_runtime_dependency(dependent=package_a, dependency=package_c)
def test_can_add_two_dependencies_graphs_and_runtime_dependencies_are_also_added( package_a: Requirement, package_b: Requirement, package_c: Requirement, dependency_graph: DependencyGraph, ): other_dependency_graph = copy(dependency_graph) dependency_graph.set_runtime_dependency(dependent=package_a, dependency=package_b) other_dependency_graph.set_runtime_dependency(dependent=package_b, dependency=package_c) sum_graph = dependency_graph + other_dependency_graph assert not dependency_graph.is_runtime_dependency(dependent=package_a, dependency=package_c) assert not other_dependency_graph.is_runtime_dependency( dependent=package_a, dependency=package_c) assert sum_graph.is_runtime_dependency(dependent=package_a, dependency=package_c)