test_wellformed.py 625 B

12345678910111213141516171819
  1. import pytest
  2. from axisregistry import AxisRegistry
  3. from axisregistry.axes_pb2 import AxisProto
  4. registry = AxisRegistry()
  5. OPTIONAL_FIELDS = ["illustration_url", "is_parametric"]
  6. @pytest.mark.parametrize("axis_tag", registry.keys())
  7. def test_proto_wellformed(axis_tag):
  8. axis = registry[axis_tag]
  9. raw_fields = dict([(k.name, v) for k, v in axis.ListFields()])
  10. for field in AxisProto.DESCRIPTOR.fields:
  11. field_name = field.name
  12. if field_name in OPTIONAL_FIELDS:
  13. continue
  14. assert field_name in raw_fields, field_name
  15. assert raw_fields[field_name] is not None, field_name