def test_validate_uuid_list(self): # check not a list uuids = [ None, 123, 'e5069610-744b-42a7-8bd8-ceac1a229cd4', '12345678123456781234567812345678', { 'uuid': 'e5069610-744b-42a7-8bd8-ceac1a229cd4' } ] for uuid in uuids: msg = attributes._validate_uuid_list(uuid) error = "'%s' is not a list" % uuid self.assertEqual(error, msg) # check invalid uuid in a list invalid_uuid_lists = [[None], [123], [123, 'e5069610-744b-42a7-8bd8-ceac1a229cd4'], ['123', '12345678123456781234567812345678'], ['t5069610-744b-42a7-8bd8-ceac1a229cd4'], ['e5069610-744b-42a7-8bd8-ceac1a229cd44'], ['e50696100-744b-42a7-8bd8-ceac1a229cd4'], ['e5069610-744bb-42a7-8bd8-ceac1a229cd4']] for uuid_list in invalid_uuid_lists: msg = attributes._validate_uuid_list(uuid_list) error = "'%s' is not a valid UUID" % uuid_list[0] self.assertEqual(error, msg) # check duplicate items in a list duplicate_uuids = [ 'e5069610-744b-42a7-8bd8-ceac1a229cd4', 'f3eeab00-8367-4524-b662-55e64d4cacb5', 'e5069610-744b-42a7-8bd8-ceac1a229cd4' ] msg = attributes._validate_uuid_list(duplicate_uuids) error = ("Duplicate items in the list: " "'%s'" % ', '.join(duplicate_uuids)) self.assertEqual(error, msg) # check valid uuid lists valid_uuid_lists = [['e5069610-744b-42a7-8bd8-ceac1a229cd4'], ['f3eeab00-8367-4524-b662-55e64d4cacb5'], [ 'e5069610-744b-42a7-8bd8-ceac1a229cd4', 'f3eeab00-8367-4524-b662-55e64d4cacb5' ]] for uuid_list in valid_uuid_lists: msg = attributes._validate_uuid_list(uuid_list) self.assertIsNone(msg)
def test_validate_uuid_list(self): # check not a list uuids = [None, 123, 'e5069610-744b-42a7-8bd8-ceac1a229cd4', '12345678123456781234567812345678', {'uuid': 'e5069610-744b-42a7-8bd8-ceac1a229cd4'}] for uuid in uuids: msg = attributes._validate_uuid_list(uuid) error = "'%s' is not a list" % uuid self.assertEqual(error, msg) # check invalid uuid in a list invalid_uuid_lists = [[None], [123], [123, 'e5069610-744b-42a7-8bd8-ceac1a229cd4'], ['123', '12345678123456781234567812345678'], ['t5069610-744b-42a7-8bd8-ceac1a229cd4'], ['e5069610-744b-42a7-8bd8-ceac1a229cd44'], ['e50696100-744b-42a7-8bd8-ceac1a229cd4'], ['e5069610-744bb-42a7-8bd8-ceac1a229cd4']] for uuid_list in invalid_uuid_lists: msg = attributes._validate_uuid_list(uuid_list) error = "'%s' is not a valid UUID" % uuid_list[0] self.assertEqual(error, msg) # check duplicate items in a list duplicate_uuids = ['e5069610-744b-42a7-8bd8-ceac1a229cd4', 'f3eeab00-8367-4524-b662-55e64d4cacb5', 'e5069610-744b-42a7-8bd8-ceac1a229cd4'] msg = attributes._validate_uuid_list(duplicate_uuids) error = ("Duplicate items in the list: " "'%s'" % ', '.join(duplicate_uuids)) self.assertEqual(error, msg) # check valid uuid lists valid_uuid_lists = [['e5069610-744b-42a7-8bd8-ceac1a229cd4'], ['f3eeab00-8367-4524-b662-55e64d4cacb5'], ['e5069610-744b-42a7-8bd8-ceac1a229cd4', 'f3eeab00-8367-4524-b662-55e64d4cacb5']] for uuid_list in valid_uuid_lists: msg = attributes._validate_uuid_list(uuid_list) self.assertIsNone(msg)