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)
def test_invalid_ip_addresses(ip_addresses): with pytest.raises(MarshmallowValidationError): CanonicalFactsSchema().load({"ip_addresses": ip_addresses})
def test_invalid_providers(canonical_facts): with pytest.raises(MarshmallowValidationError): CanonicalFactsSchema().load(canonical_facts)
def test_valid_ip_addresses(ip_addresses): CanonicalFactsSchema().load({"ip_addresses": ip_addresses})
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")