def test_run_noop(self, context: Context, state: State, tf_name: str, tf_version: str) -> None: """Test not removing scipy from a TensorFlow stack.""" scipy_package_version = PackageVersion( name="scipy", version="==1.2.2", develop=False, index=Source("https://pypi.org/simple"), ) tf_package_version = PackageVersion( name=tf_name, version=f"=={tf_version}", develop=False, index=Source("https://pypi.org/simple"), ) assert "tensorflow" not in state.resolved_dependencies state.resolved_dependencies[ "tensorflow"] = tf_package_version.to_tuple() context.register_package_version(tf_package_version) context.dependents["scipy"] = { scipy_package_version.to_tuple(): {(tf_package_version.to_tuple(), "rhel", "8", "3.6")} } unit = TensorFlowRemoveSciPyStep() with TensorFlowRemoveSciPyStep.assigned_context(context): assert unit.run(state, scipy_package_version) is None
def test_include(self, builder_context: PipelineBuilderContext, recommendation_type: RecommendationType) -> None: """Test including this pipeline unit.""" builder_context.decision_type = None builder_context.recommendation_type = recommendation_type assert "scipy" not in builder_context.project.pipfile.packages assert builder_context.is_adviser_pipeline() assert TensorFlowRemoveSciPyStep.should_include(builder_context) == {}
def test_run_deps(self, context: Context, state: State) -> None: """Test not removing scipy from a TensorFlow stack if introduced by another dependency.""" scipy_package_version = PackageVersion( name="scipy", version="==1.2.2", develop=False, index=Source("https://pypi.org/simple"), ) tf_package_version = PackageVersion( name="tensorflow", version="==2.2.0", develop=False, index=Source("https://pypi.org/simple"), ) another_package_version = PackageVersion( name="some-package", version="==1.0.0", develop=False, index=Source("https://pypi.org/simple"), ) assert "tensorflow" not in state.resolved_dependencies state.resolved_dependencies[ "tensorflow"] = tf_package_version.to_tuple() state.resolved_dependencies[ another_package_version.name] = another_package_version.to_tuple() context.register_package_version(tf_package_version) context.dependents["scipy"] = { scipy_package_version.to_tuple(): { (tf_package_version.to_tuple(), "rhel", "8", "3.6"), (another_package_version.to_tuple(), "rhel", "8", "3.6"), } } unit = TensorFlowRemoveSciPyStep() with TensorFlowRemoveSciPyStep.assigned_context(context): assert unit.run(state, scipy_package_version) is None
def test_no_include( self, builder_context: PipelineBuilderContext, recommendation_type: RecommendationType, decision_type: DecisionType, add_direct_scipy: bool, ) -> None: """Test not including this pipeline unit step.""" builder_context.decision_type = decision_type builder_context.recommendation_type = recommendation_type if add_direct_scipy: builder_context.project.add_package(package_name="scipy", package_version="==1.2.2", develop=False) assert "scipy" in builder_context.project.pipfile.packages.packages assert list( TensorFlowRemoveSciPyStep.should_include(builder_context)) == []