コード例 #1
0
ファイル: test_wrap.py プロジェクト: goern/thoth-adviser
    def test_no_should_include(self) -> None:
        """Test not including this pipeline unit."""
        prescription_str = """
name: WrapUnit
type: wrap
should_include:
  times: 1
  adviser_pipeline: true
match:
  state:
    resolved_dependencies:
      - name: flask
        version: "<=1.0.0,>=0.12"
        index_url: "https://pypi.org/simple"
run:
  justification:
    - type: ERROR
      message: This message will not be shown
      link: https://pypi.org/project/connexion
"""
        flexmock(WrapPrescription).should_receive(
            "_should_include_base").replace_with(lambda _: False).once()
        prescription = yaml.safe_load(prescription_str)
        PRESCRIPTION_WRAP_SCHEMA(prescription)
        WrapPrescription.set_prescription(prescription)

        builder_context = flexmock()
        assert list(WrapPrescription.should_include(builder_context)) == []
コード例 #2
0
ファイル: test_wrap.py プロジェクト: tlegen-k/adviser
    def test_should_include_no_package_name(self) -> None:
        """Test including this pipeline unit without any specific resolved package."""
        prescription_str = """
name: WrapUnit
type: wrap
should_include:
  times: 1
  adviser_pipeline: true
run:
  justification:
    - type: ERROR
      message: This message will not be shown
      link: https://pypi.org/project/connexion
"""
        flexmock(WrapPrescription).should_receive("_should_include_base").replace_with(lambda _: True).once()
        prescription = yaml.safe_load(prescription_str)
        PRESCRIPTION_WRAP_SCHEMA(prescription)
        WrapPrescription.set_prescription(prescription)

        builder_context = flexmock()
        assert list(WrapPrescription.should_include(builder_context)) == [
            {
                "package_name": None,
                "match": {},
                "run": {
                    "justification": [
                        {
                            "type": "ERROR",
                            "message": "This message will not be shown",
                            "link": "https://pypi.org/project/connexion",
                        }
                    ]
                },
            },
        ]
コード例 #3
0
ファイル: test_wrap.py プロジェクト: goern/thoth-adviser
    def test_should_include_multi(self) -> None:
        """Test including this pipeline unit multiple times."""
        prescription_str = """
name: WrapUnit
type: wrap
should_include:
  times: 1
  adviser_pipeline: true
match:
  - state:
      resolved_dependencies:
        - name: tensorflow-cpu
  - state:
      resolved_dependencies:
        - name: tensorflow
  - state:
      resolved_dependencies:
        - name: intel-tensorflow
run:
  justification:
    - type: ERROR
      message: This message will be shown
      link: https://pypi.org/project/tensorflow
"""
        flexmock(WrapPrescription).should_receive(
            "_should_include_base").replace_with(lambda _: True).once()
        prescription = yaml.safe_load(prescription_str)
        PRESCRIPTION_WRAP_SCHEMA(prescription)
        WrapPrescription.set_prescription(prescription)

        builder_context = flexmock()
        assert list(WrapPrescription.should_include(builder_context)) == [
            {
                "package_name": "tensorflow-cpu",
                "match": {
                    "state": {
                        "resolved_dependencies": [{
                            "name": "tensorflow-cpu",
                        }],
                    },
                },
                "prescription": {
                    "run": False
                },
                "run": {
                    "justification": [{
                        "type":
                        "ERROR",
                        "message":
                        "This message will be shown",
                        "link":
                        "https://pypi.org/project/tensorflow",
                    }]
                },
            },
            {
                "package_name": "tensorflow",
                "match": {
                    "state": {
                        "resolved_dependencies": [{
                            "name": "tensorflow",
                        }],
                    },
                },
                "prescription": {
                    "run": False
                },
                "run": {
                    "justification": [{
                        "type":
                        "ERROR",
                        "message":
                        "This message will be shown",
                        "link":
                        "https://pypi.org/project/tensorflow",
                    }]
                },
            },
            {
                "package_name": "intel-tensorflow",
                "match": {
                    "state": {
                        "resolved_dependencies": [{
                            "name": "intel-tensorflow",
                        }],
                    },
                },
                "prescription": {
                    "run": False
                },
                "run": {
                    "justification": [{
                        "type":
                        "ERROR",
                        "message":
                        "This message will be shown",
                        "link":
                        "https://pypi.org/project/tensorflow",
                    }]
                },
            },
        ]