def test_should_include_no_package_name(self) -> None: """Test including this pipeline unit.""" prescription_str = """ name: SieveUnit type: sieve should_include: times: 1 adviser_pipeline: true match: package_version: index_url: https://pypi.org/simple """ flexmock(SievePrescription).should_receive("_should_include_base").replace_with(lambda _: True).once() prescription = yaml.safe_load(prescription_str) PRESCRIPTION_SIEVE_SCHEMA(prescription) SievePrescription.set_prescription(prescription) builder_context = flexmock() assert list(SievePrescription.should_include(builder_context)) == [ { "package_name": None, "match": { "package_version": { "index_url": "https://pypi.org/simple", } }, "prescription": {"run": False}, "run": {}, } ]
def test_should_include_package_name(self) -> None: """Test including this pipeline unit.""" prescription_str = """ name: SieveUnit type: sieve should_include: times: 1 adviser_pipeline: true match: package_version: name: flask version: '<=1.1.0' """ flexmock(SievePrescription).should_receive( "_should_include_base").replace_with(lambda _: True).once() prescription = yaml.safe_load(prescription_str) PRESCRIPTION_SIEVE_SCHEMA(prescription) SievePrescription.set_prescription(prescription) builder_context = flexmock() assert list(SievePrescription.should_include(builder_context)) == [ { "package_name": "flask", "match": { "package_version": { "name": "flask", "version": "<=1.1.0", }, }, "run": {}, }, ]