swaggerconformance.valuetemplates package

Module contents

This package provides access to two main classes of objects:

  • ValueFactory for generating ValueTemplate instances matching the parameter values defines by a parameter entry in a swagger schema. This can be inherited from to generate new ValueTemplate instances matching custom parameters in a user’s schema.
  • The ValueTemplate itself and child classes used to generate hypothesis strategies for generating parameter values with certain constraints. Again, users may create new ValueTemplate subclasses to define their own new value types.
class swaggerconformance.valuetemplates.ValueFactory[source]

Bases: object

Factory for building ValueTemplate from swagger definitions.

create_value(swagger_definition)[source]

Create a template for the value specified by the definition.

Return type:ValueTemplate
class swaggerconformance.valuetemplates.ArrayTemplate(max_items=None, min_items=None, unique_items=None)[source]

Bases: object

Template for an array collection.

hypothesize(elements)[source]

Return a hypothesis strategy defining this collection.

Parameters:elements – The hypothesis strategy for a single element.
class swaggerconformance.valuetemplates.ObjectTemplate(max_properties=None, min_properties=None, additional_properties=False)[source]

Bases: object

Template for a JSON object collection.

MAX_ADDITIONAL_PROPERTIES is a limit on the number of additional properties to add to objects. Setting this too high might cause data generation to time out.

MAX_ADDITIONAL_PROPERTIES = 5
hypothesize(required_properties, optional_properties)[source]

Return a hypothesis strategy defining this collection, including random additional properties if the object supports them.

Will add only up to MAX_ADDITIONAL_PROPERTIES extra values to prevent data generation taking too long and timing out.

Parameters:
  • required_properties (dict) – The required fields in the generated dict.
  • optional_properties (dict) – The optional fields in the generated dict.
class swaggerconformance.valuetemplates.ValueTemplate[source]

Bases: object

Template for a single value of any specified type.

hypothesize()[source]

Return a hypothesis strategy defining this value.

class swaggerconformance.valuetemplates.BooleanTemplate[source]

Bases: swaggerconformance.valuetemplates._valuetemplates.ValueTemplate

Template for a Boolean value.

hypothesize()[source]
class swaggerconformance.valuetemplates.NumericTemplate(maximum=None, exclusive_maximum=None, minimum=None, exclusive_minimum=None, multiple_of=None)[source]

Bases: swaggerconformance.valuetemplates._valuetemplates.ValueTemplate

Abstract template for a numeric value.

hypothesize()[source]
class swaggerconformance.valuetemplates.IntegerTemplate(maximum=None, exclusive_maximum=None, minimum=None, exclusive_minimum=None, multiple_of=None)[source]

Bases: swaggerconformance.valuetemplates._valuetemplates.NumericTemplate

Template for an integer value.

hypothesize()[source]
class swaggerconformance.valuetemplates.FloatTemplate(maximum=None, exclusive_maximum=None, minimum=None, exclusive_minimum=None, multiple_of=None)[source]

Bases: swaggerconformance.valuetemplates._valuetemplates.NumericTemplate

Template for a floating point value.

hypothesize()[source]
class swaggerconformance.valuetemplates.StringTemplate(max_length=None, min_length=None, pattern=None, enum=None, blacklist_chars=None)[source]

Bases: swaggerconformance.valuetemplates._valuetemplates.ValueTemplate

Template for a string value.

hypothesize()[source]
class swaggerconformance.valuetemplates.URLPathStringTemplate(max_length=None, min_length=None, pattern=None, enum=None)[source]

Bases: swaggerconformance.valuetemplates._valuetemplates.StringTemplate

Template for a string value which must be valid in a URL path.

class swaggerconformance.valuetemplates.HTTPHeaderStringTemplate(max_length=None, min_length=None, pattern=None, enum=None)[source]

Bases: swaggerconformance.valuetemplates._valuetemplates.StringTemplate

Template for a string value which must be valid in a HTTP header.

hypothesize()[source]
class swaggerconformance.valuetemplates.DateTemplate[source]

Bases: swaggerconformance.valuetemplates._valuetemplates.ValueTemplate

Template for a Date value.

hypothesize()[source]
class swaggerconformance.valuetemplates.DateTimeTemplate[source]

Bases: swaggerconformance.valuetemplates._valuetemplates.ValueTemplate

Template for a Date-Time value.

hypothesize()[source]
class swaggerconformance.valuetemplates.UUIDTemplate[source]

Bases: swaggerconformance.valuetemplates._valuetemplates.ValueTemplate

Template for a UUID value.

hypothesize()[source]
class swaggerconformance.valuetemplates.FileTemplate[source]

Bases: swaggerconformance.valuetemplates._valuetemplates.ValueTemplate

Template for a File value.

hypothesize()[source]