def deserialize_canonical_facts(raw_data):
    try:
        validated_data = CanonicalFactsSchema().load(raw_data)
    except ValidationError as e:
        raise ValidationException(str(e.messages)) from None
    return _deserialize_canonical_facts(validated_data)
Esempio n. 2
0
def test_invalid_ip_addresses(ip_addresses):
    with pytest.raises(MarshmallowValidationError):
        CanonicalFactsSchema().load({"ip_addresses": ip_addresses})
Esempio n. 3
0
def test_invalid_providers(canonical_facts):
    with pytest.raises(MarshmallowValidationError):
        CanonicalFactsSchema().load(canonical_facts)
Esempio n. 4
0
def test_valid_ip_addresses(ip_addresses):
    CanonicalFactsSchema().load({"ip_addresses": ip_addresses})
Esempio n. 5
0
def test_valid_providers(provider):
    canonical_facts = {"provider_id": provider.get("id"), "provider_type": provider.get("type")}
    validated_host = CanonicalFactsSchema().load(canonical_facts)

    assert validated_host["provider_id"] == provider.get("id")
    assert validated_host["provider_type"] == provider.get("type")