Example #1
0
    def test_from_dict_duplicate_name_error(self) -> None:
        """Test raising duplicate error if unit names clash."""
        unit = {
            "name": "BootUnit",
            "type": "boot",
            "should_include": {
                "adviser_pipeline": True
            },
            "run": {
                "log": {
                    "message": "Some text printed",
                    "type": "INFO"
                }
            },
        }

        prescription = {
            "apiVersion": "thoth-station.ninja/v1",
            "kind": "prescription",
            "spec": {
                "name": "thoth",
                "release": "2021.03.30",
                "units": {
                    "boots": [unit, dict(unit)],
                },
            },
        }

        with pytest.raises(PrescriptionDuplicateUnitNameError):
            Prescription.from_dict(prescription)
Example #2
0
    def test_from_dict_duplicate_name_error(self) -> None:
        """Test raising duplicate error if unit names clash."""
        unit = {
            "name": "BootUnit",
            "type": "boot",
            "should_include": {
                "adviser_pipeline": True
            },
            "run": {
                "log": {
                    "message": "Some text printed",
                    "type": "INFO"
                }
            },
        }

        prescription = {
            "units": {
                "boots": [unit, dict(unit)],
            },
        }

        with pytest.raises(PrescriptionDuplicateUnitNameError):
            Prescription.from_dict(prescription,
                                   prescription_name="thoth",
                                   prescription_release="2021.06.15")
Example #3
0
 def test_from_dict_validate_error(self) -> None:
     """Test raising an error if schema validation fails."""
     with pytest.raises(PrescriptionSchemaError):
         Prescription.from_dict({"foo": "bar"})
Example #4
0
 def test_from_dict_validate_error(self) -> None:
     """Test raising an error if schema validation fails."""
     with pytest.raises(PrescriptionSchemaError):
         Prescription.from_dict({"foo": "bar"},
                                prescription_name="thoth",
                                prescription_release="2021.06.15")