Example #1
0
def check_csv(data, schema):
    try:
        if data.get("kind") != OPERATOR_CSV_KIND:
            raise NotOperatorCSV("Not a ClusterServiceVersion")
    except AttributeError as exc:
        raise NotOperatorCSV("File does not contain a YAML object") from exc
    validate_with_schema(data, schema)
Example #2
0
 def _validate_operator_csv_modifications_schema(self, modifications):
     """Validate if provided operator CSV modification are valid according schema"""
     schema = load_schema(
         'atomic_reactor',
         'schemas/operator_csv_modifications.json'
     )
     validate_with_schema(modifications, schema)
Example #3
0
def test_validate_with_schema_bad_schema(caplog):
    config = {'name': 'foo'}
    schema = {
        'type': 'bakagaki',  # Nonexistent type
        'properties': {
            'name': {
                'type': 'string'
            }
        }
    }
    with pytest.raises(jsonschema.SchemaError):
        validate_with_schema(config, schema)
    assert 'invalid schema, cannot validate' in caplog.text
Example #4
0
def test_validate_with_schema_validation(config, validation_pass, expected,
                                         caplog):
    schema = {
        'type': 'object',
        'required': ['name'],
        'properties': {
            'name': {
                'type': 'string'
            }
        },
        'additionalProperties': False
    }
    if not validation_pass:
        with pytest.raises(OsbsValidationException) as exc_info:
            validate_with_schema(config, schema)
        assert 'schema validation error' in caplog.text
        assert expected == str(exc_info.value)
    else:
        validate_with_schema(config, schema)
        assert expected == ''