def test_should_include_no_package_name(self) -> None: """Test including this pipeline unit.""" prescription_str = """ name: StepUnit type: step should_include: times: 1 adviser_pipeline: true match: package_version: index_url: 'https://thoth-station.ninja' run: score: 0.1 """ flexmock(StepPrescription).should_receive( "_should_include_base").replace_with(lambda _: True).once() prescription = yaml.safe_load(prescription_str) PRESCRIPTION_STEP_SCHEMA(prescription) StepPrescription.set_prescription(prescription) builder_context = flexmock() assert list(StepPrescription.should_include(builder_context)) == [{ "package_name": None, "match": { "package_version": { "index_url": "https://thoth-station.ninja", }, }, "multi_package_resolution": False, "run": { "score": 0.1, }, }]
def test_should_include_package_name(self) -> None: """Test including this pipeline unit.""" prescription_str = """ name: StepUnit type: step should_include: times: 1 adviser_pipeline: true match: - package_version: name: numpy version: '==1.19.1' index_url: 'https://pypi.org/simple' run: multi_package_resolution: true score: 0.1 """ flexmock(StepPrescription).should_receive( "_should_include_base").replace_with(lambda _: True).once() prescription = yaml.safe_load(prescription_str) PRESCRIPTION_STEP_SCHEMA(prescription) StepPrescription.set_prescription(prescription) builder_context = flexmock() result = list(StepPrescription.should_include(builder_context)) assert result == [{ "package_name": "numpy", "multi_package_resolution": True, "prescription": { "run": False, }, "match": { "package_version": { "name": "numpy", "version": "==1.19.1", "index_url": "https://pypi.org/simple", }, }, "run": { "score": 0.1, "multi_package_resolution": True, }, }]