def test_get_data_type_for_attributes_two_types(self): ne = NetworkEdge() # try various combos of <type> and None for a in [(None, 'string'), ('string', None), (None, 'list_of_string'), ('list_of_string', None), ('boolean', None), (None, 'boolean'), ('list_of_integer', None), (None, 'list_of_double')]: attrs = [Attribute(data_type=a[0]), Attribute(data_type=a[1])] self.assertEqual('list_of_string', ne._get_data_type_for_attributes(attrs)) # try the other types for a in [('string', 'list_of_string'), ('list_of_string', 'string'), ('boolean', 'list_of_boolean'), ('list_of_boolean', 'boolean'), ('double', 'list_of_double'), ('list_of_double', 'double'), ('integer', 'list_of_integer'), ('list_of_integer', 'integer'), ('long', 'list_of_long'), ('list_of_long', 'long')]: attrs = [Attribute(data_type=a[0]), Attribute(data_type=a[1])] if a[0].startswith('list_of'): checkval = a[0] else: checkval = 'list_of_' + a[0] self.assertEqual(checkval, ne._get_data_type_for_attributes(attrs))
def test_get_data_type_for_attributes_single_type(self): ne = NetworkEdge() # single None attrs = [Attribute(data_type=None)] self.assertEqual('list_of_string', ne._get_data_type_for_attributes(attrs)) # multiple None attrs = [Attribute(data_type=None), Attribute(data_type=None)] self.assertEqual('list_of_string', ne._get_data_type_for_attributes(attrs)) # single other types for a in ['string', 'boolean', 'double', 'integer', 'long']: attrs = [Attribute(data_type=a)] self.assertEqual('list_of_' + a, ne._get_data_type_for_attributes(attrs)) # multiple of matching types for a in [ 'string', 'boolean', 'double', 'integer', 'long', 'list_of_boolean', 'list_of_double', 'list_of_integer', 'list_of_long', 'list_of_string' ]: attrs = [ Attribute(data_type=a), Attribute(data_type=a), Attribute(data_type=a) ] if a.startswith('list_of'): checkval = a else: checkval = 'list_of_' + a self.assertEqual(checkval, ne._get_data_type_for_attributes(attrs))