def test_no_should_include(self) -> None: """Test not including this pipeline unit.""" prescription_str = """ name: StrideUnit type: stride 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: stack_info: - type: ERROR message: This message will not be shown link: https://pypi.org/project/connexion """ flexmock(StridePrescription).should_receive("_should_include_base").replace_with(lambda _: False).once() prescription = yaml.safe_load(prescription_str) PRESCRIPTION_STRIDE_SCHEMA(prescription) StridePrescription.set_prescription(prescription) builder_context = flexmock() assert list(StridePrescription.should_include(builder_context)) == []
def test_should_include_multi(self) -> None: """Test including this pipeline unit multiple times.""" prescription_str = """ name: StrideUnit type: stride should_include: times: 1 adviser_pipeline: true match: - state: resolved_dependencies: - name: flask - state: resolved_dependencies: - name: werkzeug run: stack_info: - type: INFO message: This message will be shown probably multiple times link: https://pypi.org/project/flask """ flexmock(StridePrescription).should_receive("_should_include_base").replace_with(lambda _: True).once() prescription = yaml.safe_load(prescription_str) PRESCRIPTION_STRIDE_SCHEMA(prescription) StridePrescription.set_prescription(prescription) builder_context = flexmock() assert list(StridePrescription.should_include(builder_context)) == [ { "package_name": "flask", "match": { "state": { "resolved_dependencies": [ { "name": "flask", } ] }, }, "prescription": {"run": False}, "run": { "stack_info": [ { "type": "INFO", "message": "This message will be shown probably multiple times", "link": "https://pypi.org/project/flask", } ] }, }, { "package_name": "werkzeug", "match": { "state": { "resolved_dependencies": [ { "name": "werkzeug", } ] }, }, "prescription": {"run": False}, "run": { "stack_info": [ { "type": "INFO", "message": "This message will be shown probably multiple times", "link": "https://pypi.org/project/flask", } ] }, }, ]