def get_message_attributes_md5(cls, req_data): req_data = clone(req_data) orig_types = {} for key, entry in dict(req_data).items(): # Fix an issue in moto where data types like 'Number.java.lang.Integer' are # not supported: Keep track of the original data type, and temporarily change # it to the short form (e.g., 'Number'), before changing it back again. if key.endswith("DataType"): parts = entry.split(".") if len(parts) > 2: short_type_name = parts[0] full_type_name = entry attr_num = key.split(".")[1] attr_name = req_data["MessageAttribute.%s.Name" % attr_num] orig_types[attr_name] = full_type_name req_data[key] = [short_type_name] if full_type_name not in TRANSPORT_TYPE_ENCODINGS: TRANSPORT_TYPE_ENCODINGS[ full_type_name] = TRANSPORT_TYPE_ENCODINGS[ short_type_name] # moto parse_message_attributes(..) expects params to be passed as dict of lists req_data_lists = {k: [v] for k, v in req_data.items()} moto_message = Message("dummy_msg_id", "dummy_body") moto_message.message_attributes = parse_message_attributes( req_data_lists) for key, data_type in orig_types.items(): moto_message.message_attributes[key]["data_type"] = data_type message_attr_hash = moto_message.attribute_md5 return message_attr_hash
def get_message_attributes_md5(self, req_data): req_data = clone(req_data) orig_types = {} for key, entry in dict(req_data).items(): # Fix an issue in moto where data types like 'Number.java.lang.Integer' are # not supported: Keep track of the original data type, and temporarily change # it to the short form (e.g., 'Number'), before changing it back again. if key.endswith('DataType'): parts = entry[0].split('.') if len(parts) > 2: short_type_name = parts[0] full_type_name = req_data[key][0] attr_num = key.split('.')[1] attr_name = req_data['MessageAttribute.%s.Name' % attr_num][0] orig_types[attr_name] = full_type_name req_data[key] = [short_type_name] if full_type_name not in TRANSPORT_TYPE_ENCODINGS: TRANSPORT_TYPE_ENCODINGS[ full_type_name] = TRANSPORT_TYPE_ENCODINGS[ short_type_name] moto_message = Message('dummy_msg_id', 'dummy_body') moto_message.message_attributes = parse_message_attributes(req_data) for key, data_type in orig_types.items(): moto_message.message_attributes[key]['data_type'] = data_type message_attr_hash = moto_message.attribute_md5 return message_attr_hash