unioslo / harborapi

Python async client for the Harbor REST API v2.0.
https://unioslo.github.io/harborapi/
MIT License
27 stars 5 forks source link

Ensure `T` and `None` are tested for fields with type `Optional[T]` #13

Open pederhan opened 1 year ago

pederhan commented 1 year ago

As of now, Hypothesis does not seem to guarantee that it actually tests the type for Pydantic model fields with type Optional[T] with default value None. It seems to test with None only.

Using the solution outlined in this issue, we can use hypothesis-jsonschema to generate the required values.

This will require a somewhat large change to both the existing unit tests and the testing regime in general. Any new tests following this change will be required to use hypothesis-jsonschema. We could potentially also make use of st.register_type_strategy() to register the type strategy after inferring the strategy from the schema, so that other tests can simply use st.from_type()