tests.test_entity_fields

Unit tests for nailgun.entity_fields.

class tests.test_entity_fields.GenValueTestCase(methodName='runTest')

Tests for the gen_value method on various *Field classes.

Classes with complex gen_value implementations are broken out into separate test cases.

test_boolean_field()

Test nailgun.entity_fields.BooleanField.gen_value().

test_date_field()

Test nailgun.entity_fields.DateField.gen_value().

test_datetime_field()

Test nailgun.entity_fields.DateTimeField.gen_value().

test_dict_field()

Test nailgun.entity_fields.DictField.gen_value().

Assert that an empty dict is returned by default. There are very few occurrences of dict fields in the entity classes, so it is hard to intelligently produce a randomized value that will be of use in a wide variety of entities. Instead, those few entities override or extend this method.

test_email_field()

Test nailgun.entity_fields.EmailField.gen_value().

Ensure nailgun.entity_fields.EmailField.gen_value() returns a unicode string containing the character ‘@’.

test_float_field()

Test nailgun.entity_fields.FloatField.gen_value().

test_gen_netmask()

Test nailgun.entity_fields.NetmaskField.gen_value().

Assert that the result is in fauxfactory.constants.VALID_NETMASKS.

test_ip_address_field()

Test nailgun.entity_fields.IPAddressField.gen_value().

Ensure the value returned is acceptable to socket.inet_aton.

test_mac_address_field()

Test nailgun.entity_fields.MACAddressField.gen_value().

Ensure the value returned is a string containing 12 hex digits (either upper or lower case), grouped into pairs of digits and separated by colon characters. For example: '01:23:45:FE:dc:BA'

The regex used in this test is inspired by this Q&A: http://stackoverflow.com/questions/7629643/how-do-i-validate-the-format-of-a-mac-address

test_one_to_many_field()

Test nailgun.entity_fields.OneToManyField.gen_value().

test_one_to_one_field()

Test nailgun.entity_fields.OneToOneField.gen_value().

test_url_field()

Test nailgun.entity_fields.URLField.gen_value().

Check that the result can be parsed by the urlparse/urllib.parse module and that the resultant object has a netloc attribute.

class tests.test_entity_fields.IntegerFieldTestCase(methodName='runTest')

Tests for nailgun.entity_fields.IntegerField.

test_int_is_returned()

Enture the value returned is an int.

test_max_val_arg()

Ensure that the max_val argument is respected.

test_min_val_arg()

Ensure that the min_val argument is respected.

test_min_val_max_val_args()

Ensure that the min_val and max_val args are respected.

class tests.test_entity_fields.StringFieldTestCase(methodName='runTest')

Tests for nailgun.entity_fields.StringField.

test_length_arg()

Ensure that the length argument is respected.

test_str_is_returned()

Ensure a unicode string at least 1 char long is returned.

test_str_type_arg()

Ensure that the str_type argument is respected.

class tests.test_entity_fields.TestClass

A class that is used when testing the OneTo{One,Many}Field classes.