tests.test_entity_mixins

Tests for nailgun.entity_mixins.

class tests.test_entity_mixins.EntityCreateMixinTestCase(methodName='runTest')

Tests for nailgun.entity_mixins.EntityCreateMixin.

setUp()

Set self.entity = EntityWithCreate(…).

test_create()

Test nailgun.entity_mixins.EntityCreateMixin.create().

test_create_json()

Test nailgun.entity_mixins.EntityCreateMixin.create_json().

test_create_missing()

Call method create_missing.

test_create_raw_v1()

What happens if the create_missing arg is not specified?

nailgun.entity_mixins.EntityCreateMixin.create_raw() should default to nailgun.entity_mixins.CREATE_MISSING. We do not set CREATE_MISSING in this test. It is a process-wide variable, and setting it may prevent tests from being run in parallel.

test_create_raw_v2()

What happens if the create_missing arg is True?

test_create_raw_v3()

What happens if the create_missing arg is False?

class tests.test_entity_mixins.EntityDeleteMixinTestCase(methodName='runTest')

Tests for nailgun.entity_mixins.EntityDeleteMixin.

setUp()

Set self.entity = EntityWithDelete(…).

test_delete_raw()

Call nailgun.entity_mixins.EntityDeleteMixin.delete_raw().

test_delete_v1()

What happens if the server returns an error HTTP status code?

test_delete_v2()

What happens if the server returns an HTTP ACCEPTED status code?

test_delete_v3()

What happens if the server returns an HTTP NO_CONTENT status?

test_delete_v4()

What happens if the server returns some other stuccess status?

test_delete_v5()

What happens if the server returns an HTTP OK status and empty content?

test_delete_v6()

What happens if the server returns an HTTP OK status and blank only content?

class tests.test_entity_mixins.EntityReadMixinTestCase(methodName='runTest')

Tests for nailgun.entity_mixins.EntityReadMixin.

setUp()

Set self.entity = EntityWithRead(…).

classmethod setUpClass()

Set cls.test_entity.

test_entity is a class having one to one and one to many fields.

test_missing_value_error()

Raise a nailgun.entity_mixins.MissingValueError.

test_read_json()

Call nailgun.entity_mixins.EntityReadMixin.read_json().

test_read_raw()

Call nailgun.entity_mixins.EntityReadMixin.read_raw().

test_read_v1()

Make read_json return hashes.

test_read_v2()

Make read_json return hashes, but with different field names.

test_read_v3()

Make read_json return IDs.

test_read_v4()

Do not ignore any fields.

class tests.test_entity_mixins.EntitySearchMixinTestCase(methodName='runTest')

Tests for nailgun.entity_mixins.EntitySearchMixin.

setUp()

Set self.cfg and self.entity.

test_search_filter_v1()

Test nailgun.entity_mixins.EntitySearchMixin.search_filter().

Pass a zero-length list of entities.

test_search_filter_v2()

Test nailgun.entity_mixins.EntitySearchMixin.search_filter().

Try to filter on a foreign key field.

test_search_filter_v3()

Test nailgun.entity_mixins.EntitySearchMixin.search_filter().

Pass an invalid filter.

test_search_filter_v4()

Test nailgun.entity_mixins.EntitySearchMixin.search_filter().

Pass in valid entities and filters.

test_search_json()

Call nailgun.entity_mixins.EntitySearchMixin.search_json().

test_search_normalize_v1()

Call search_normalize.

Pretend the server returns values for all fields, and an extra value.

test_search_normalize_v2()

Call search_normalize.

Pretend the server returns no values for any fields.

test_search_payload_v1()

Call search_payload. Generate an empty query.

test_search_payload_v2()

Call search_payload. Pass in a query.

test_search_payload_v3()

Call search_payload. Include a variety of fields in a search.

test_search_raw()

Call nailgun.entity_mixins.EntitySearchMixin.search_raw().

test_search_v1()

Test nailgun.entity_mixins.EntitySearchMixin.search().

Pass no arguments.

test_search_v2()

Test nailgun.entity_mixins.EntitySearchMixin.search().

Provide each possible argument.

class tests.test_entity_mixins.EntityTestCase(methodName='runTest')

Tests for nailgun.entity_mixins.Entity.

setUp()

Set self.cfg.

test_bad_value_error()

Try to raise a nailgun.entity_mixins.BadValueError.

test_compare()

Assert compare take only not unique fields into account

test_compare_to_null()

Assert entity comparison to None

test_compare_with_filter()

Assert compare can filter fields based on callable

test_entity_get_fields()

Test nailgun.entity_mixins.Entity.get_fields().

test_entity_get_values()

Test nailgun.entity_mixins.Entity.get_values().

test_entity_get_values_v2()

Test nailgun.entity_mixins.Entity.get_values(), ensure _path_fields are never returned.

test_eq()

Test method nailgun.entity_mixins.Entity.__eq__.

Assert that __eq__ works comparing all attributes, even from nested structures.

test_eq_none()

Test method nailgun.entity_mixins.Entity.__eq__ against None

Assert that __eq__ returns False when compared to None.

test_init_v1()

Provide no value for the server_config argument.

test_init_v2()

Provide a server config object via DEFAULT_SERVER_CONFIG.

test_no_such_field_error()

Try to raise a nailgun.entity_mixins.NoSuchFieldError.

test_path()

Test nailgun.entity_mixins.Entity.path().

test_repr_v1()

Test method nailgun.entity_mixins.Entity.__repr__.

Assert that __repr__ works correctly when no arguments are passed to an entity.

test_repr_v2()

Test method nailgun.entity_mixins.Entity.__repr__.

Assert that __repr__ works correctly when an ID is passed to an entity.

test_repr_v3()

Test method nailgun.entity_mixins.Entity.__repr__.

Assert that __repr__ works correctly when one entity has a foreign key relationship to a second entity.

class tests.test_entity_mixins.EntityUpdateMixinTestCase(methodName='runTest')

Tests for nailgun.entity_mixins.EntityUpdateMixin.

setUp()

Set self.entity = EntityWithUpdate(…).

test_update()

Test nailgun.entity_mixins.EntityUpdateMixin.update().

test_update_json()

Call nailgun.entity_mixins.EntityUpdateMixin.update_json().

test_update_payload_v1()

Call nailgun.entity_mixins.EntityUpdateMixin.update_payload().

Assert that the method behaves correctly given various values for the field argument.

test_update_payload_v2()

Call nailgun.entity_mixins.EntityUpdateMixin.update_payload().

Assign None to a OneToOneField and call update_payload.

test_update_raw()

Call nailgun.entity_mixins.EntityUpdateMixin.update_raw().

class tests.test_entity_mixins.EntityWithCreate(server_config=None, **kwargs)

Inherits from nailgun.entity_mixins.EntityCreateMixin.

class tests.test_entity_mixins.EntityWithDelete(server_config=None, **kwargs)

Inherits from nailgun.entity_mixins.EntityDeleteMixin.

class tests.test_entity_mixins.EntityWithRead(server_config=None, **kwargs)

Inherits from nailgun.entity_mixins.EntityReadMixin.

class tests.test_entity_mixins.EntityWithSearch(server_config=None, **kwargs)

Inherits from nailgun.entity_mixins.EntitySearchMixin.

class tests.test_entity_mixins.EntityWithSearch2(server_config=None, **kwargs)

An entity with integer, one to one and one to many fields.

class tests.test_entity_mixins.EntityWithUpdate(server_config=None, **kwargs)

Inherits from nailgun.entity_mixins.EntityUpdateMixin.

class tests.test_entity_mixins.MakeEntitiesFromIdsTestCase(methodName='runTest')

Tests for nailgun.entity_mixins._make_entities_from_ids().

setUp()

Set self.cfg.

test_pass_in_both()

Let entity_objs_and_ids be an iterable of integers and IDs.

test_pass_in_emtpy_iterable()

Let the entity_objs_and_ids argument be an empty iterable.

test_pass_in_entity_ids()

Let the entity_objs_and_ids arg be an iterable of integers.

test_pass_in_entity_obj()

Let the entity_objs_and_ids arg be an iterable of entities.

class tests.test_entity_mixins.MakeEntityFromIdTestCase(methodName='runTest')

Tests for nailgun.entity_mixins._make_entity_from_id().

setUp()

Set self.cfg.

test_pass_in_entity_id()

Let the entity_obj_or_id argument be an integer.

test_pass_in_entity_obj()

Let the entity_obj_or_id argument be an entity object.

class tests.test_entity_mixins.PollTaskTestCase(methodName='runTest')

Tests for nailgun.entity_mixins._poll_task().

setUp()

Create a bogus server configuration object.

test__poll_task_failure()

What happens when a foreman task completes but does not succeed?

Assert that a nailgun.entity_mixins.TaskFailedError exception is raised.

test__poll_task_success()

What happens when a foreman task completes and does succeed?

Assert that the server’s response is returned.

test__poll_task_timeout()

What happens when a foreman task timesout? Assert that the task is still running.

class tests.test_entity_mixins.SampleEntity(server_config=None, **kwargs)

Sample entity to be used in the tests

class tests.test_entity_mixins.SampleEntityThree(server_config=None, **kwargs)

An entity with foreign key fields as One to One and ListField.

This class has a nailgun.entity_fields.OneToOneField called “one_to_one” pointing to tests.test_entity_mixins.SampleEntityTwo.

This class has a nailgun.entity_fields.ListField called “list” containing instances of tests.test_entity_mixins.SampleEntity.

class tests.test_entity_mixins.SampleEntityTwo(server_config=None, **kwargs)

An entity with foreign key fields.

This class has a nailgun.entity_fields.OneToManyField called “one_to_many” pointing to tests.test_entity_mixins.SampleEntity.