def get_from_dict(cls, raw_dict: dict) -> "JobConfig": # required to avoid cyclical imports from packit.schema import JobConfigSchema, MM3 if MM3: config = JobConfigSchema().load(raw_dict) else: # v2 config = JobConfigSchema(strict=True).load(raw_dict).data logger.debug(config) return config
def test_deserialize_and_serialize_job_config(config_in, config_out, validation_error): schema = JobConfigSchema() if validation_error: with pytest.raises(ValidationError): schema.dump(schema.load(config_in)) else: serialized_from_in = schema.dump(schema.load(config_in)) serialized_from_out = schema.dump(schema.load(config_out)) assert serialized_from_in == serialized_from_out