brewtils.test package

Submodules

brewtils.test.comparable module

Module to simplify model comparisons.

Warning

This module was created to simplify testing. As such, it’s not recommended for production use.

Warning

This module subject to change outside of the normal deprecation cycle.

Seriously, this is a ‘use at your own risk’ kind of thing.

brewtils.test.comparable.assert_instance_equal(obj1, obj2, do_raise=False, **kwargs)

Wrapper that will translate AssertionError to a boolean.

This is a safety measure in case these functions are used outside of a testing context. This isn’t recommended, but naked asserts are still unacceptable in any packaged code. This method will translate the various comparison functions to a simple boolean return.

Note that in a testing context the AssertionError is re-raised. This is because it’s much more helpful to know the specific assertion that failed, as it could be something nested several levels deep.

Parameters:
  • obj1 – Passed through to _assert_equal
  • obj2 – Passed through to _assert_equal
  • expected_type – Both objects will be checked (using isinstance) against this type
  • do_raise – If True, re-raise any raised AssertionError. This helps with nested comparisons.
  • **kwargs – Passed through to _assert_equal
Returns:

True if the comparison was equal. False if
  • The comparison was not equal and
  • do_raise is False and
  • called from outside of a testing context

Return type:

bool

Raises:

AssertionError – The comparison was not equal. Assertion will be translated to a boolean False if do_raise is False and called from outside of a testing context.

brewtils.test.comparable.assert_choices_equal(obj1, obj2, do_raise=False, **kwargs)

Wrapper that will translate AssertionError to a boolean.

This is a safety measure in case these functions are used outside of a testing context. This isn’t recommended, but naked asserts are still unacceptable in any packaged code. This method will translate the various comparison functions to a simple boolean return.

Note that in a testing context the AssertionError is re-raised. This is because it’s much more helpful to know the specific assertion that failed, as it could be something nested several levels deep.

Parameters:
  • obj1 – Passed through to _assert_equal
  • obj2 – Passed through to _assert_equal
  • expected_type – Both objects will be checked (using isinstance) against this type
  • do_raise – If True, re-raise any raised AssertionError. This helps with nested comparisons.
  • **kwargs – Passed through to _assert_equal
Returns:

True if the comparison was equal. False if
  • The comparison was not equal and
  • do_raise is False and
  • called from outside of a testing context

Return type:

bool

Raises:

AssertionError – The comparison was not equal. Assertion will be translated to a boolean False if do_raise is False and called from outside of a testing context.

brewtils.test.comparable.assert_patch_equal(obj1, obj2, do_raise=False, **kwargs)

Wrapper that will translate AssertionError to a boolean.

This is a safety measure in case these functions are used outside of a testing context. This isn’t recommended, but naked asserts are still unacceptable in any packaged code. This method will translate the various comparison functions to a simple boolean return.

Note that in a testing context the AssertionError is re-raised. This is because it’s much more helpful to know the specific assertion that failed, as it could be something nested several levels deep.

Parameters:
  • obj1 – Passed through to _assert_equal
  • obj2 – Passed through to _assert_equal
  • expected_type – Both objects will be checked (using isinstance) against this type
  • do_raise – If True, re-raise any raised AssertionError. This helps with nested comparisons.
  • **kwargs – Passed through to _assert_equal
Returns:

True if the comparison was equal. False if
  • The comparison was not equal and
  • do_raise is False and
  • called from outside of a testing context

Return type:

bool

Raises:

AssertionError – The comparison was not equal. Assertion will be translated to a boolean False if do_raise is False and called from outside of a testing context.

brewtils.test.comparable.assert_logging_config_equal(obj1, obj2, do_raise=False, **kwargs)

Wrapper that will translate AssertionError to a boolean.

This is a safety measure in case these functions are used outside of a testing context. This isn’t recommended, but naked asserts are still unacceptable in any packaged code. This method will translate the various comparison functions to a simple boolean return.

Note that in a testing context the AssertionError is re-raised. This is because it’s much more helpful to know the specific assertion that failed, as it could be something nested several levels deep.

Parameters:
  • obj1 – Passed through to _assert_equal
  • obj2 – Passed through to _assert_equal
  • expected_type – Both objects will be checked (using isinstance) against this type
  • do_raise – If True, re-raise any raised AssertionError. This helps with nested comparisons.
  • **kwargs – Passed through to _assert_equal
Returns:

True if the comparison was equal. False if
  • The comparison was not equal and
  • do_raise is False and
  • called from outside of a testing context

Return type:

bool

Raises:

AssertionError – The comparison was not equal. Assertion will be translated to a boolean False if do_raise is False and called from outside of a testing context.

brewtils.test.comparable.assert_event_equal(obj1, obj2, do_raise=False)[source]
brewtils.test.comparable.assert_queue_equal(obj1, obj2, do_raise=False, **kwargs)

Wrapper that will translate AssertionError to a boolean.

This is a safety measure in case these functions are used outside of a testing context. This isn’t recommended, but naked asserts are still unacceptable in any packaged code. This method will translate the various comparison functions to a simple boolean return.

Note that in a testing context the AssertionError is re-raised. This is because it’s much more helpful to know the specific assertion that failed, as it could be something nested several levels deep.

Parameters:
  • obj1 – Passed through to _assert_equal
  • obj2 – Passed through to _assert_equal
  • expected_type – Both objects will be checked (using isinstance) against this type
  • do_raise – If True, re-raise any raised AssertionError. This helps with nested comparisons.
  • **kwargs – Passed through to _assert_equal
Returns:

True if the comparison was equal. False if
  • The comparison was not equal and
  • do_raise is False and
  • called from outside of a testing context

Return type:

bool

Raises:

AssertionError – The comparison was not equal. Assertion will be translated to a boolean False if do_raise is False and called from outside of a testing context.

brewtils.test.comparable.assert_request_template_equal(obj1, obj2, do_raise=False, **kwargs)

Wrapper that will translate AssertionError to a boolean.

This is a safety measure in case these functions are used outside of a testing context. This isn’t recommended, but naked asserts are still unacceptable in any packaged code. This method will translate the various comparison functions to a simple boolean return.

Note that in a testing context the AssertionError is re-raised. This is because it’s much more helpful to know the specific assertion that failed, as it could be something nested several levels deep.

Parameters:
  • obj1 – Passed through to _assert_equal
  • obj2 – Passed through to _assert_equal
  • expected_type – Both objects will be checked (using isinstance) against this type
  • do_raise – If True, re-raise any raised AssertionError. This helps with nested comparisons.
  • **kwargs – Passed through to _assert_equal
Returns:

True if the comparison was equal. False if
  • The comparison was not equal and
  • do_raise is False and
  • called from outside of a testing context

Return type:

bool

Raises:

AssertionError – The comparison was not equal. Assertion will be translated to a boolean False if do_raise is False and called from outside of a testing context.

brewtils.test.comparable.assert_trigger_equal(obj1, obj2, do_raise=False, **kwargs)

Wrapper that will translate AssertionError to a boolean.

This is a safety measure in case these functions are used outside of a testing context. This isn’t recommended, but naked asserts are still unacceptable in any packaged code. This method will translate the various comparison functions to a simple boolean return.

Note that in a testing context the AssertionError is re-raised. This is because it’s much more helpful to know the specific assertion that failed, as it could be something nested several levels deep.

Parameters:
  • obj1 – Passed through to _assert_equal
  • obj2 – Passed through to _assert_equal
  • expected_type – Both objects will be checked (using isinstance) against this type
  • do_raise – If True, re-raise any raised AssertionError. This helps with nested comparisons.
  • **kwargs – Passed through to _assert_equal
Returns:

True if the comparison was equal. False if
  • The comparison was not equal and
  • do_raise is False and
  • called from outside of a testing context

Return type:

bool

Raises:

AssertionError – The comparison was not equal. Assertion will be translated to a boolean False if do_raise is False and called from outside of a testing context.

brewtils.test.comparable.assert_command_equal(obj1, obj2, do_raise=False)[source]
brewtils.test.comparable.assert_parameter_equal(obj1, obj2, do_raise=False)[source]
brewtils.test.comparable.assert_principal_equal(obj1, obj2, do_raise=False)[source]
brewtils.test.comparable.assert_request_equal(obj1, obj2, do_raise=False)[source]

Assert that two requests are ‘equal’.

This is the most complicated due to how we serialize parent and children requests to avoid reference loops.

Parent fields will not serialize their children. That’s why compare_parent asserts that the children field is None.

The requests in the children field will not serialize their parents or children. That’s why compare_child asserts that both the parent and children fields are None.

brewtils.test.comparable.assert_role_equal(obj1, obj2, do_raise=False)[source]
brewtils.test.comparable.assert_system_equal(obj1, obj2, do_raise=False)[source]
brewtils.test.comparable.assert_job_equal(obj1, obj2, do_raise=False)[source]
brewtils.test.comparable.assert_request_file_equal(obj1, obj2, do_raise=False, **kwargs)

Wrapper that will translate AssertionError to a boolean.

This is a safety measure in case these functions are used outside of a testing context. This isn’t recommended, but naked asserts are still unacceptable in any packaged code. This method will translate the various comparison functions to a simple boolean return.

Note that in a testing context the AssertionError is re-raised. This is because it’s much more helpful to know the specific assertion that failed, as it could be something nested several levels deep.

Parameters:
  • obj1 – Passed through to _assert_equal
  • obj2 – Passed through to _assert_equal
  • expected_type – Both objects will be checked (using isinstance) against this type
  • do_raise – If True, re-raise any raised AssertionError. This helps with nested comparisons.
  • **kwargs – Passed through to _assert_equal
Returns:

True if the comparison was equal. False if
  • The comparison was not equal and
  • do_raise is False and
  • called from outside of a testing context

Return type:

bool

Raises:

AssertionError – The comparison was not equal. Assertion will be translated to a boolean False if do_raise is False and called from outside of a testing context.

brewtils.test.comparable.assert_operation_equal(obj1, obj2, do_raise=False)[source]
brewtils.test.comparable.assert_runner_equal(obj1, obj2, do_raise=False, **kwargs)

Wrapper that will translate AssertionError to a boolean.

This is a safety measure in case these functions are used outside of a testing context. This isn’t recommended, but naked asserts are still unacceptable in any packaged code. This method will translate the various comparison functions to a simple boolean return.

Note that in a testing context the AssertionError is re-raised. This is because it’s much more helpful to know the specific assertion that failed, as it could be something nested several levels deep.

Parameters:
  • obj1 – Passed through to _assert_equal
  • obj2 – Passed through to _assert_equal
  • expected_type – Both objects will be checked (using isinstance) against this type
  • do_raise – If True, re-raise any raised AssertionError. This helps with nested comparisons.
  • **kwargs – Passed through to _assert_equal
Returns:

True if the comparison was equal. False if
  • The comparison was not equal and
  • do_raise is False and
  • called from outside of a testing context

Return type:

bool

Raises:

AssertionError – The comparison was not equal. Assertion will be translated to a boolean False if do_raise is False and called from outside of a testing context.

brewtils.test.fixtures module

brewtils.test.fixtures.bg_choices(*args, **kwargs)[source]
brewtils.test.fixtures.bg_command(*args, **kwargs)[source]

Use the bg_command fixture instead.

brewtils.test.fixtures.bg_command_2(*args, **kwargs)[source]

Use the bg_command fixture instead.

brewtils.test.fixtures.bg_cron_job(*args, **kwargs)[source]

A beer garden cron job

brewtils.test.fixtures.bg_cron_trigger(*args, **kwargs)[source]

A cron trigger as a model.

brewtils.test.fixtures.bg_date_trigger(*args, **kwargs)[source]

A date trigger as a model.

brewtils.test.fixtures.bg_event(*args, **kwargs)[source]

An event as a model.

brewtils.test.fixtures.bg_garden(*args, **kwargs)[source]

An operation as a model.

brewtils.test.fixtures.bg_instance(*args, **kwargs)[source]

An instance as a model.

brewtils.test.fixtures.bg_interval_job(*args, **kwargs)[source]

A beer garden interval job

brewtils.test.fixtures.bg_interval_trigger(*args, **kwargs)[source]

An interval trigger as a model.

brewtils.test.fixtures.bg_job(*args, **kwargs)[source]

A job as a model.

brewtils.test.fixtures.bg_job_defns_list(*args, **kwargs)[source]

A list of job definitions

brewtils.test.fixtures.bg_job_ids(*args, **kwargs)[source]

A list of job IDs

brewtils.test.fixtures.bg_logging_config(*args, **kwargs)[source]

A logging config as a model.

brewtils.test.fixtures.bg_operation(*args, **kwargs)[source]

An operation as a model.

brewtils.test.fixtures.bg_parameter(*args, **kwargs)[source]

Parameter based on the parameter_dict

brewtils.test.fixtures.bg_patch(*args, **kwargs)[source]

A patch as a model.

brewtils.test.fixtures.bg_patch2(*args, **kwargs)[source]

A patch as a model.

brewtils.test.fixtures.bg_principal(*args, **kwargs)[source]
brewtils.test.fixtures.bg_queue(*args, **kwargs)[source]

A queue as a model.

brewtils.test.fixtures.bg_request(*args, **kwargs)[source]

A request as a model.

brewtils.test.fixtures.bg_request_file(*args, **kwargs)[source]

A request file as a model

brewtils.test.fixtures.bg_request_template(*args, **kwargs)[source]

Request template as a bg model.

brewtils.test.fixtures.bg_resolvable(*args, **kwargs)[source]
brewtils.test.fixtures.bg_resolvable_chunk(*args, **kwargs)[source]
brewtils.test.fixtures.bg_role(*args, **kwargs)[source]
brewtils.test.fixtures.bg_runner(*args, **kwargs)[source]

A runner as a model.

brewtils.test.fixtures.bg_system(*args, **kwargs)[source]

A system as a model.

brewtils.test.fixtures.bg_system_2(*args, **kwargs)[source]

A system with a different version.

brewtils.test.fixtures.child_request(*args, **kwargs)[source]

A child request as a model.

brewtils.test.fixtures.child_request_dict(*args, **kwargs)[source]

A child request represented as a dictionary.

brewtils.test.fixtures.choices_dict(*args, **kwargs)[source]

Choices as a dictionary.

brewtils.test.fixtures.command_dict(*args, **kwargs)[source]

A command represented as a dictionary.

brewtils.test.fixtures.command_dict_2(*args, **kwargs)[source]

A second command represented as a dictionary.

brewtils.test.fixtures.cron_job_dict(*args, **kwargs)[source]

A cron job represented as a dictionary.

brewtils.test.fixtures.cron_trigger_dict(*args, **kwargs)[source]

A cron trigger as a dictionary.

brewtils.test.fixtures.date_trigger_dict(*args, **kwargs)[source]

A cron trigger as a dictionary.

brewtils.test.fixtures.event_dict(*args, **kwargs)[source]

An event represented as a dictionary.

brewtils.test.fixtures.garden_dict(*args, **kwargs)[source]

A garden as a dictionary.

brewtils.test.fixtures.instance_dict(*args, **kwargs)[source]

An instance represented as a dictionary.

brewtils.test.fixtures.interval_job_dict(*args, **kwargs)[source]

An interval job represented as a dictionary.

brewtils.test.fixtures.interval_trigger_dict(*args, **kwargs)[source]

An interval trigger as a dictionary.

brewtils.test.fixtures.job_dfn_list_dict(*args, **kwargs)[source]

A job definition list represented as a dictionary.

brewtils.test.fixtures.job_dict(*args, **kwargs)[source]

A date job represented as a dictionary.

brewtils.test.fixtures.job_dict_for_import(*args, **kwargs)[source]

A job dict but some keys and values are missing.

brewtils.test.fixtures.job_id_list_dict(*args, **kwargs)[source]

A job ID list represented as a dictionary.

brewtils.test.fixtures.job_ids_dict(*args, **kwargs)[source]

A list of job IDs represented as a dictionary.

brewtils.test.fixtures.legacy_role_dict(*args, **kwargs)[source]
brewtils.test.fixtures.logging_config_dict(*args, **kwargs)[source]

A logging config represented as a dictionary.

brewtils.test.fixtures.nested_parameter_dict(*args, **kwargs)[source]

Nested Parameter as a dictionary.

brewtils.test.fixtures.operation_dict(*args, **kwargs)[source]

An operation as a dictionary.

brewtils.test.fixtures.parameter_dict(*args, **kwargs)[source]

Non-nested parameter as a dictionary.

brewtils.test.fixtures.parent_request(*args, **kwargs)[source]

A parent request as a model.

brewtils.test.fixtures.parent_request_dict(*args, **kwargs)[source]

A parent request represented as a dictionary.

brewtils.test.fixtures.patch_dict(*args, **kwargs)[source]

A patch represented as a dictionary.

brewtils.test.fixtures.patch_dict_no_envelop(*args, **kwargs)[source]

A patch without an envelope represented as a dictionary.

brewtils.test.fixtures.patch_dict_no_envelop2(*args, **kwargs)[source]

A patch without an envelope represented as a dictionary.

brewtils.test.fixtures.patch_many_dict(*args, **kwargs)[source]

Multiple patches represented as a dictionary.

brewtils.test.fixtures.principal_dict(*args, **kwargs)[source]
brewtils.test.fixtures.queue_dict(*args, **kwargs)[source]

A queue represented as a dictionary.

brewtils.test.fixtures.request_dict(*args, **kwargs)[source]

A request represented as a dictionary.

brewtils.test.fixtures.request_file_dict(*args, **kwargs)[source]

A request file represented as a dictionary.

brewtils.test.fixtures.request_template_dict(*args, **kwargs)[source]

Request template as a dictionary.

brewtils.test.fixtures.resolvable_chunk_dict(*args, **kwargs)[source]

A resolvable as a dictionary.

brewtils.test.fixtures.resolvable_dict(*args, **kwargs)[source]

A resolvable as a dictionary.

brewtils.test.fixtures.runner_dict(*args, **kwargs)[source]

A runner as a dictionary.

brewtils.test.fixtures.system_dict(*args, **kwargs)[source]

A system represented as a dictionary.

brewtils.test.fixtures.system_id(*args, **kwargs)[source]
brewtils.test.fixtures.ts_2_dt(*args, **kwargs)[source]

Feb 2, 2017 as a naive datetime.

brewtils.test.fixtures.ts_2_dt_utc(*args, **kwargs)[source]

Feb 2, 2017 UTC as timezone-aware datetime.

brewtils.test.fixtures.ts_2_epoch(*args, **kwargs)[source]

Feb 2, 2017 UTC as epoch milliseconds.

brewtils.test.fixtures.ts_dt(*args, **kwargs)[source]

Jan 1, 2016 as a naive datetime.

brewtils.test.fixtures.ts_dt_eastern(*args, **kwargs)[source]

Jan 1, 2016 US/Eastern as timezone-aware datetime.

brewtils.test.fixtures.ts_dt_utc(*args, **kwargs)[source]

Jan 1, 2016 UTC as timezone-aware datetime.

brewtils.test.fixtures.ts_epoch(*args, **kwargs)[source]

Jan 1, 2016 UTC as epoch milliseconds.

brewtils.test.fixtures.ts_epoch_eastern(*args, **kwargs)[source]

Jan 1, 2016 US/Eastern as epoch milliseconds.

Module contents