Tests Reference

Models

tests.models

SQLAlchemy models for the Chinook database.

class tests.models.Album(**kwargs)[source]

SQLAlchemy model for the Album table in our database.

album_id
title
artist_id
artist
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.Artist(**kwargs)[source]

SQLAlchemy model for the Artist table in our database.

artist_id
name
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.Customer(**kwargs)[source]

SQLAlchemy model for the Customer table in our database.

customer_id
first_name
last_name
company
address
city
state

Two Character Abbreviation

country
postal_code
phone
fax
email
support_rep_id
employee
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.Employee(**kwargs)[source]

SQLAlchemy model for the Employee table in our database.

employee_id
last_name
first_name
title
reports_to
birth_date
hire_date
address
city
state
country
postal_code
phone
fax
email
manager
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.Genre(**kwargs)[source]

SQLAlchemy model for the Genre table in our database.

genre_id
name
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.Invoice(**kwargs)[source]

SQLAlchemy model for the Invoice table in our database.

invoice_id
customer_id
invoice_date
billing_address
billing_city
billing_state
billing_country
billing_postal_code
total
customer
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.InvoiceLine(**kwargs)[source]

SQLAlchemy model for the InvoiceLine table in our database.

invoice_line_id
invoice_id
track_id
unit_price
quantity
invoice
track
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.MediaType(**kwargs)[source]

SQLAlchemy model for the MediaType table in our database.

media_type_id
name
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.Playlist(**kwargs)[source]

SQLAlchemy model for the Playlist table in our database.

playlist_id
name
tracks
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.Track(**kwargs)[source]

SQLAlchemy model for the Track table in our database.

track_id
name
album_id
media_type_id
genre_id
composer
milliseconds
bytes
unit_price
album
genre
media_type
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.TrackStats(**kwargs)[source]

SQLAlchemy model for the Track table in our database.

track_id
downloads
track
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.Node(**kwargs)[source]

SQLAlchemy model for the Node table in our database.

node_id
children
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.CompositeNode(**kwargs)[source]

SQLAlchemy model for the CompositeNode table in our database.

node_id
composite_id
children
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.CompositeOne(**kwargs)[source]

Dummy model for one side of one to many composite key testing.

one_id
composite_one_id
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.CompositeMany(**kwargs)[source]

Model for many side of one to many composite key testing.

many_id
one_id
composite_one_id
one
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.PrimaryPkExample(**kwargs)[source]

Parent model for testing FK that’s part of a PK.

parent_id
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class tests.models.ForeignPkExample(**kwargs)[source]

Child model for testing FK that’s part of a PK.

child_id
parent_id
parent
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

Schemas

tests.schemas

Schemas used for test purposes.

class tests.schemas.InvoiceLineSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of InvoiceLine

include_relationships = True
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.InvoiceSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Invoice

include_relationships = True
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.EmployeeSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Employee

include_relationships = True
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.CustomerSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Customer

include_relationships = True
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.PlaylistSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Playlist

include_relationships = True
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.MediaTypeSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of MediaType

include_relationships = True
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.GenreSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Genre

include_relationships = True
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.TrackSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Track

include_relationships = True
check_permission(data, instance, action)[source]

Checks if this action is permissible to attempt.

Parameters:
  • data (dict) – The user supplied data to be deserialized.

  • instance – A pre-existing instance the data is to be deserialized into. Should be None if not updating an existing object.

  • action (str) – Either "create", "update", or "delete".

Returns:

None

Raises:

PermissionValidationError – If the action being taken is not allowed.

opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.TrackPermissionsSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Track

include_relationships = True
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.TrackStatsSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of TrackStats

include_relationships = True
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.AlbumSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Album

include_relationships = True
id_keys = ['album_id']
error_messages = {'permission_denied': 'Overrides original error.'}
check_permission(data, instance, action)[source]

Checks if this action is permissible to attempt.

Parameters:
  • data (dict) – The user supplied data to be deserialized.

  • instance – A pre-existing instance the data is to be deserialized into. Should be None if not updating an existing object.

  • action (str) – Either "create", "update", or "delete".

Returns:

None

Raises:

PermissionValidationError – If the action being taken is not allowed.

opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.ArtistSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Artist

include_relationships = True
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.NodeSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Node

include_relationships = True
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.CompositeNodeSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of CompositeNode

include_relationships = True
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.CompositeOneSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of CompositeOne

include_relationships = True
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.CompositeManySchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of CompositeMany

include_relationships = True
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.TestCamelModelResourceConverter(schema_cls: type[Schema] | None = None)[source]

Convert a model’s fields for use in a ModelResourceSchema.

class tests.schemas.InvoiceLineCamelSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of InvoiceLine

include_relationships = True
model_converter

alias of TestCamelModelResourceConverter

opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.InvoiceCamelSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Invoice

include_relationships = True
model_converter

alias of TestCamelModelResourceConverter

opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.EmployeeCamelSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Employee

include_relationships = True
model_converter

alias of TestCamelModelResourceConverter

opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.CustomerCamelSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Customer

include_relationships = True
model_converter

alias of TestCamelModelResourceConverter

opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.PlaylistCamelSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Playlist

include_relationships = True
model_converter

alias of TestCamelModelResourceConverter

opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.MediaTypeCamelSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of MediaType

include_relationships = True
model_converter

alias of TestCamelModelResourceConverter

opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.GenreCamelSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Genre

include_relationships = True
model_converter

alias of TestCamelModelResourceConverter

opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.TrackCamelSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Track

include_relationships = True
model_converter

alias of TestCamelModelResourceConverter

opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.AlbumCamelSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Album

include_relationships = True
model_converter

alias of TestCamelModelResourceConverter

id_keys = ['album_id']
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.ArtistCamelSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Artist

include_relationships = True
model_converter

alias of TestCamelModelResourceConverter

opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.NodeCamelSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Node

include_relationships = True
model_converter

alias of TestCamelModelResourceConverter

opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.CompositeNodeCamelSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of CompositeNode

include_relationships = True
model_converter

alias of TestCamelModelResourceConverter

opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.CompositeOneCamelSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of CompositeOne

include_relationships = True
model_converter

alias of TestCamelModelResourceConverter

opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.CompositeManyCamelSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of CompositeMany

include_relationships = True
model_converter

alias of TestCamelModelResourceConverter

opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None
class tests.schemas.MsAlbumSchema(*args, **kwargs)[source]
class Meta[source]
model

alias of Album

include_relationships = True
load_instance = True
opts: LoadInstanceMixin.Opts = <marshmallow_sqlalchemy.schema.SQLAlchemyAutoSchemaOpts object>
instance: _ModelType | None
class tests.schemas.AlbumBadIdKeysSchema(only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None, instance=None, parent_resource=None, session=None)[source]
class Meta[source]
model

alias of Album

include_relationships = True
id_keys = ['test']
opts: Any = <drowsy.schema.ModelResourceSchemaOpts object>
exclude: set[Any] | MutableSet[Any]
unknown: types.UnknownOption
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

load_fields: dict[str, Field]
dump_fields: dict[str, Field]
instance: _ModelType | None

Resources

tests.resources

Resources used for test purposes.

tests.resources.page_max_100(resource)[source]

Always returns 100 as the page max size.

class tests.resources.AlbumResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of AlbumSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.InvoiceLineResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of InvoiceLineSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.InvoiceResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of InvoiceSchema

page_max_size()

Always returns 100 as the page max size.

options = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']
opts = <drowsy.resource.ResourceOpts object>
class tests.resources.EmployeeResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of EmployeeSchema

error_messages = {'invalid_field': 'Test invalid_field message.'}
opts = <drowsy.resource.ResourceOpts object>
class tests.resources.CustomerResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of CustomerSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.PlaylistResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of PlaylistSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.MediaTypeResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of MediaTypeSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.GenreResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of GenreSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.TrackResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of TrackSchema

get_required_filters(alias=None)[source]

Build any required filters for this resource.

Does nothing by default, but can be usefully overridden if you want to enforce certain filters on this resource. A simple example would be a notifications resource where a filter matching the currently logged in user is applied.

e.g.:

model = alias or self.model
return model.user_id == self.context.get("user_id")
Parameters:

alias – Can optionally be supplied if this resource is being used as a subresource and an alias has been applied.

Returns:

Any valid SQL expression(s), to be passed directly into filter(). If multiple expressions, they may be returned in a list or tuple. Defaults to None.

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.TrackStatsResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of TrackStatsSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.ArtistResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of ArtistSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.NodeResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of NodeSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.CompositeNodeResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of CompositeNodeSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.CompositeOneResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of CompositeOneSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.CompositeManyResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of CompositeManySchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.AlbumCamelResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of AlbumCamelSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.InvoiceLineCamelResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of InvoiceLineCamelSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.InvoiceCamelResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of InvoiceCamelSchema

page_max_size()

Always returns 100 as the page max size.

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.EmployeeCamelResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of EmployeeCamelSchema

error_messages = {'invalid_field': 'Test invalid_field message.'}
opts = <drowsy.resource.ResourceOpts object>
class tests.resources.CustomerCamelResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of CustomerCamelSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.PlaylistCamelResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of PlaylistCamelSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.MediaTypeCamelResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of MediaTypeCamelSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.GenreCamelResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of GenreCamelSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.TrackCamelResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of TrackCamelSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.ArtistCamelResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of ArtistCamelSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.NodeCamelResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of NodeCamelSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.CompositeNodeCamelResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of CompositeNodeCamelSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.CompositeOneCamelResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of CompositeOneCamelSchema

opts = <drowsy.resource.ResourceOpts object>
class tests.resources.CompositeManyCamelResource(session, context=None, page_max_size=None, error_messages=None, parent_field=None)[source]
class Meta[source]
schema_cls

alias of CompositeManyCamelSchema

opts = <drowsy.resource.ResourceOpts object>

Base

tests.base

Commonly used classes and definitions for Drowsy tests.

class tests.base.DrowsyTests[source]

Base class used for set up and tear down of drowsy tests.

class tests.base.DrowsyDatabaseTests[source]

Base class used for set up and tear down of drowsy tests.

backends = ['sqlite', 'mssql', 'postgres']

PyTest Config

Database Tests

tests.test_database

Test database checking for Drowsy.

class tests.test_database.TestDrowsyDatabaseConnection[source]

Database tests to ensure our connection is valid.

static test_db(db_session)[source]

Make sure our test db is functional.

Field Tests

Integration Tests

tests.test_integration

Integration tests for Drowsy.

class tests.test_integration.TestDrowsyIntegration[source]

General purpose drowsy integration tests.

static test_offset(db_session)[source]

Make sure providing an offset query_param works.

static test_limit(db_session)[source]

Make sure providing a limit query_param works.

static test_get_resources_ordered(db_session)[source]

Test simple get_resources sort functionality.

static test_get_first_page(db_session)[source]

Test that we can get the first page of a set of objects.

static test_get_second_page(db_session)[source]

Test that we can get the second page of a set of objects.

static test_subresource_nested_query(db_session)[source]

Ensure a simple subresource query works.

static test_subresource_simple_query(db_session)[source]

Ensure a simple subresource query works.

Parser Tests

Query Builer Tests

Resource Tests

Router Tests

Schema Tests

Utility Tests

tests.test_utils

Utility function tests for Drowsy.

tests.test_utils.test_get_field_by_data_key()[source]

Test get_field_by_data_key works with old style Schema.

tests.test_utils.test_get_error_message()[source]

Test simple get_error_message functionality.

tests.test_utils.test_get_error_message_no_string()[source]

Test get_error_message can return a non string.