tests Package

tests Package

mqlalchemy.tests.__init__

Tests for our new query syntax.

class tests.MQLAlchemyTests(methodName='runTest')[source]

Bases: TestCase

A collection of MQLAlchemy tests.

setUp()[source]

Configure a db session for the chinook database.

tearDown()[source]

Clean up database connections.

test_db()[source]

Make sure our test db is functional.

test_simple_query()[source]

Test a very simple mqlalchemy query.

test_simple_prior_query()[source]

Test a simple mqlalchemy query using a preformed query.

test_no_match()[source]

Test that a query that should have no match works.

test_list_relation()[source]

Test that a list relation .any query works.

test_complex_list_relation()[source]

Test that a multi-level list relation query works.

test_more_complex_list_relation()[source]

Test that a complex list relation query works.

test_complex_convert_name()[source]

Test that converting from camelCase to underscore works.

test_explicit_elem_match()[source]

Test that an explicit elemMatch.

test_implicit_elem_match()[source]

Test that an implicit elemMatch works.

test_list_relation_eq_fail()[source]

Make sure we can’t check a relation for equality.

test_list_relation_neq_fail()[source]

Make sure we can’t check a relation for inequality.

test_non_list_relation()[source]

Test that a non-list relation .has query works.

test_attr_exists()[source]

Test $exists on a simple attr.

test_attr_not_exists()[source]

Test not $exists on a simple attr.

test_child_list_not_exists()[source]

Test a child list can be filtered for being missing.

test_child_list_exists()[source]

Test a child list can be checked for existence.

test_child_non_list_not_exists()[source]

Test a non list child can be filtered for being missing.

test_child_non_list_exists()[source]

Test a non list child can be checked for existence.

test_implicit_and()[source]

Test that an implicit and query works.

test_explicit_and()[source]

Test that the $and operator works.

test_or()[source]

Test that the $or operator works.

test_negation()[source]

Test that the $not operator works.

test_nor()[source]

Test that the $nor operator works.

test_neq()[source]

Test that the $ne operator works.

test_lt()[source]

Test that the $lt operator works.

test_lte()[source]

Test that the $lte operator works.

test_eq()[source]

Test that the new $eq operator works.

test_gte()[source]

Test that the $gte operator works.

test_gt()[source]

Test that the $gt operator works.

test_mod()[source]

Test that the $mod operator works.

test_mod_str_fail()[source]

Test passing string values to $mod op fails.

test_mod_decimal_divisor_fails()[source]

Test passing a decimal divisor to $mod op fails.

test_mod_decimal_remainder_fails()[source]

Test passing a decimal remainder to $mod op fails.

test_mod_non_list()[source]

Test passing a non list to $mod op rails.

test_mod_non_int_field()[source]

Test trying to $mod a non int field fails.

test_in()[source]

Test that the $in operator works.

test_in_nested()[source]

Test that the $in operator works on nested objects.

test_in_non_list_fails()[source]

Test that the $in op fails when not supplied with a list.

test_nin()[source]

Test that the $nin operator works.

test_nin_non_list_fails()[source]

Test that the $nin op fails when not supplied with a list.

test_like()[source]

Test that the new $like operator works.

test_elemmatch_fail()[source]

Test that the $elemMatch operator properly fails.

test_nested_attr_query_fail()[source]

Test that a nested attribute query fails.

test_bad_operator_fail()[source]

Test that a invalid operator fails.

test_empty_dict_fail()[source]

Test that a nested attribute query fails.

test_whitelist()[source]

Test that whitelisting works as expected.

test_custom_whitelist_func()[source]

Test that providing a whitelist function works.

test_convert_to_int()[source]

Test that we can convert a string to integer.

test_convert_to_float()[source]

Test that we can convert a string to a float.

test_convert_to_bool()[source]

Test that we can convert a value to a boolean.

test_convert_to_datetime()[source]

Test that we can convert a value to a datetime.

test_convert_to_date()[source]

Test that we can convert a value to a date.

test_convert_to_time()[source]

Test that we can convert a value to a time.

test_convert_to_string()[source]

Test that we can convert a string to integer.

test_convert_to_null()[source]

Test that convert_to_alchemy_type properly returns None.

test_convert_fail()[source]

Test that convert_to_alchemy_type properly fails.

test_get_attr_class_attributes()[source]

Test that _get_class_attributes works.

test_stack_size_limit()[source]

Make sure that limiting the stack size works as expected.

test_stack_size_limit_fail()[source]

Make sure that limiting the stack size fails as expected.

test_type_conversion_fail()[source]

Make sure we can’t check a relation for equality.

test_self_referential_relation()[source]

Test relationship chain leading to the same model.

test_required_filters()[source]

Test nested conditions are applied properly.

test_required_filters_tuple()[source]

Test nested conditions are applied properly as a tuple.

test_nested_conditions_dict()[source]

Test dict nested conditions are applied properly.

models Module

mqlalchemy.tests.models.py

SQLAlchemy models for the Chinook database.

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

Bases: Base

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.

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

Bases: Base

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.

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

Bases: Base

SQLAlchemy model for the Customer table in our database.

customer_id
first_name
last_name
company
address
city
state
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]

Bases: Base

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.

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

Bases: Base

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]

Bases: Base

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]

Bases: Base

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]

Bases: Base

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]

Bases: Base

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]

Bases: Base

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.

playlists