def test_format_name_no_last_name(): data = { 'first_name': 'Julia', 'last_name': '' } assert MessageServiceBase.format_name(data) == 'Julia'
def extract_item_attachment_data(self, item): """ Extract item data from passed in item dict for use in an attachment """ item_attachment = { 'color': self.get_attachment_color(item), 'text': self.format_item_link(item), 'fields': [] } if item['assigned_to']: item_attachment['fields'].append({ 'title': 'Assigned to', 'value': '%s' % MessageServiceBase.format_name(item['assigned_to']), 'short': True }) if item['status']: item_attachment['fields'].append({ 'title': 'Status', 'value': ' '.join(item['status'].split('-')).capitalize(), 'short': True }) if item['score']: item_attachment['fields'].append({ 'title': 'Score', 'value': item['score'], 'short': True }) return item_attachment
def get_item_attachment(self, data): """ Return a dict with attachment data for Item activity """ item = data['attributes'] attachment = self.extract_item_attachment_data(item) attachment['pretext'] = '%s created the %s:' % (MessageServiceBase.format_name(item['created_by']), item['type']) return attachment
def get_item_attachment(self, data): """ Return a dict with attachment data for Item activity """ item = data['attributes'] attachment = self.extract_item_attachment_data(item) attachment['pretext'] = '%s created the %s:' % ( MessageServiceBase.format_name(item['created_by']), item['type']) return attachment
def get_favorite_attachment(self, data): """ Return a dict with attachment data for Favorite activity """ fave = data['attributes'] attachment = self.extract_item_attachment_data(fave['item']) attachment['pretext'] = '%s favorited the %s:' % ( MessageServiceBase.format_name(fave['user']), fave['item']['type']) return attachment
def get_favorite_attachment(self, data): """ Return a dict with attachment data for Favorite activity """ fave = data['attributes'] attachment = self.extract_item_attachment_data(fave['item']) attachment['pretext'] = '%s favorited the %s:' % ( MessageServiceBase.format_name(fave['user']), fave['item']['type']) return attachment
def get_block_attachment(self, data): """ Return a dict with attachment data for Block activity """ block = data['attributes'] attachment = self.extract_item_attachment_data(block['item']) attachment[ 'pretext'] = '%s indicated the %s %s is blocked by the %s:' % ( MessageServiceBase.format_name( block['user']), block['blocked']['type'], self.format_item_link(block['blocked']), block['item']['type']) return attachment
def get_block_attachment(self, data): """ Return a dict with attachment data for Block activity """ block = data['attributes'] attachment = self.extract_item_attachment_data(block['item']) attachment[ 'pretext'] = '%s indicated the %s %s is blocked by the %s:' % ( MessageServiceBase.format_name( block['user']), block['blocked']['type'], self.format_item_link(block['blocked']), block['item']['type']) return attachment
def get_comment_attachment(self, data): """ Return a dict with attachment data for Comment activity """ comment = data['attributes'] pretext = '%s commented on %s %s:' % ( MessageServiceBase.format_name(comment['created_by']), comment['item']['type'], self.format_item_link(comment['item'])) return { 'color': self.get_attachment_color(comment['item']), 'pretext': pretext, 'text': '"%s"' % MessageServiceBase.format_comment(comment['body']) }
def get_comment_attachment(self, data): """ Return a dict with attachment data for Comment activity """ comment = data['attributes'] pretext = '%s commented on %s %s:' % ( MessageServiceBase.format_name(comment['created_by']), comment['item']['type'], self.format_item_link(comment['item'])) return { 'color': self.get_attachment_color(comment['item']), 'pretext': pretext, 'text': '"%s"' % MessageServiceBase.format_comment(comment['body']) }
def get_deploy_attachment(self, data): """ Return a dict with attachment data for Deploy activity """ deploy = data['attributes'] items = deploy['items'] return { 'color': self.get_attachment_color(), 'text': '%s deployed %d item%s to %s' % (MessageServiceBase.format_name(deploy['user']), len(items), '' if len(items) == 1 else 's', deploy['environment']) }
def get_deploy_attachment(self, data): """ Return a dict with attachment data for Deploy activity """ deploy = data['attributes'] items = deploy['items'] return { 'color': self.get_attachment_color(), 'text': '%s deployed %d item%s to %s' % (MessageServiceBase.format_name( deploy['user']), len(items), '' if len(items) == 1 else 's', deploy['environment']) }
def extract_item_attachment_data(self, item): """ Extract item data from passed in item dict for use in an attachment """ item_attachment = { 'color': self.get_attachment_color(item), 'text': self.format_item_link(item), 'fields': [] } if item['assigned_to']: item_attachment['fields'].append({ 'title': 'Assigned to', 'value': '<https://sprint.ly/reports?assignee={1}|{0}>'.format(MessageServiceBase.format_name(item['assigned_to']), item['assigned_to']['id']), 'short': True }) if item['status']: item_attachment['fields'].append({ 'title': 'Status', 'value': '<https://sprint.ly/reports?status={1}|{0}>'.format(' '.join(item['status'].split('-')).capitalize(), item['status']), 'short': True }) if item['score']: item_attachment['fields'].append({ 'title': 'Score', 'value': item['score'], 'short': True }) if len(item['tags']): item_attachment['fields'].append({ 'title': 'Tags', 'value': ', '.join(['<https://sprint.ly/reports?tag={0}|{0}>'.format(tag) for tag in item['tags']]), 'short': True }) item_attachment['fields'].append({ 'title': 'Product', 'value': '<https://sprint.ly/reports?product={1}|{0}>'.format(item['product']['name'], item['product']['id']), 'short': True }) return item_attachment
def extract_item_attachment_data(self, item): """ Extract item data from passed in item dict for use in an attachment """ item_attachment = { 'color': self.get_attachment_color(item), 'text': self.format_item_link(item), 'fields': [] } if item['assigned_to']: item_attachment['fields'].append({ 'title': 'Assigned to', 'value': '<https://sprint.ly/reports?assignee={1}|{0}>'.format( MessageServiceBase.format_name(item['assigned_to']), item['assigned_to']['id']), 'short': True }) if item['status']: item_attachment['fields'].append({ 'title': 'Status', 'value': '<https://sprint.ly/reports?status={1}|{0}>'.format( ' '.join(item['status'].split('-')).capitalize(), item['status']), 'short': True }) if item['score']: item_attachment['fields'].append({ 'title': 'Score', 'value': item['score'], 'short': True }) if len(item['tags']): item_attachment['fields'].append({ 'title': 'Tags', 'value': ', '.join([ '<https://sprint.ly/reports?tag={0}|{0}>'.format(tag) for tag in item['tags'] ]), 'short': True }) item_attachment['fields'].append({ 'title': 'Product', 'value': '<https://sprint.ly/reports?product={1}|{0}>'.format( item['product']['name'], item['product']['id']), 'short': True }) return item_attachment