tests.test_entity_fields¶
Unit tests for nailgun.entity_fields.
-
class
tests.test_entity_fields.GenValueTestCase(methodName='runTest')¶ Tests for the
gen_valuemethod on various*Fieldclasses.Classes with complex
gen_valueimplementations are broken out into separate test cases.-
test_boolean_field()¶
-
test_date_field()¶
-
test_datetime_field()¶
-
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_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_one_to_one_field()¶
-
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
netlocattribute.
-
-
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_valargument is respected.
-
test_min_val_arg()¶ Ensure that the
min_valargument is respected.
-
test_min_val_max_val_args()¶ Ensure that the
min_valandmax_valargs are respected.
-
-
class
tests.test_entity_fields.StringFieldTestCase(methodName='runTest')¶ Tests for
nailgun.entity_fields.StringField.-
test_length_arg()¶ Ensure that the
lengthargument 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_typeargument is respected.
-
-
class
tests.test_entity_fields.TestClass¶ A class that is used when testing the OneTo{One,Many}Field classes.