def test_tags(self): # Test valid tags. for tag in ('#t', '#tag', '#TAG', '#tag123'): expected = '%s <div class="tags">%s</div>' % (tag, TAG_TMPL.format('', tag[1:].lower(), tag[1:]),) eq_(format_update(tag), expected) # Test invalid tags. for tag in ('#1', '#.abc', '#?abc'): eq_(format_update(tag), tag)
def test_tags(): """Test that format update parses tags correctly""" # Test valid tags. for tag in ("#t", "#tag", "#TAG", "#tag123"): expected = '%s <div class="tags">%s</div>' % (tag, TAG_TMPL.format("", tag[1:].lower(), tag[1:])) eq_(format_update(tag), expected) # Test invalid tags. for tag in ("#1", "#.abc", "#?abc"): eq_(format_update(tag), tag)
def test_tags(): """Test that format update parses tags correctly""" # Test valid tags. for tag in ('#t', '#tag', '#TAG', '#tag123'): expected = '%s <div class="tags">%s</div>' % ( tag, TAG_TMPL.format('', tag[1:].lower(), tag[1:])) eq_(format_update(tag), expected) # Test invalid tags. for tag in ('#1', '#.abc', '#?abc'): eq_(format_update(tag), tag)
def test_tags(self): """Test that format update parses tags correctly""" with self.app.app_context(): # Test valid tags. for tag in ('#t', '#tag', '#TAG', '#tag123'): expected = '%s <div class="tags">%s</div>' % ( tag, TAG_TMPL.format('', tag[1:].lower(), tag[1:])) eq_(format_update(tag), expected) # Test invalid tags. for tag in ('#1', '#.abc', '#?abc'): eq_(format_update(tag), tag)
def dictify(self, trim_user=False, trim_project=False): """Returns an OrderedDict of model attributes""" if self.reply_to: reply_to_user_id = self.reply_to.user.id reply_to_username = self.reply_to.user.username else: reply_to_user_id = None reply_to_username = None data = OrderedDict() data['id'] = self.id data['created'] = self.created.isoformat() if self.user: if trim_user: data['user'] = self.user.id else: data['user'] = self.user.dictify() else: data['user'] = None if self.project: if trim_project: data['project'] = self.project.id else: data['project'] = self.project.dictify() else: data['project'] = None data['content'] = format_update(self.content_html) data['reply_to_id'] = self.reply_to_id data['reply_to_user_id'] = reply_to_user_id data['reply_to_username'] = reply_to_username data['reply_count'] = self.reply_count return data
def test_format_update(self): p = Project(name='mdndev', slug='mdndev', repo_url='https://github.com/mozilla/kuma') app.db.session.add(p) app.db.session.commit() content = "#merge pull #1 and pR 2 to fix bug #3 and BUg 4" formatted_update = format_update(content, project=p) ok_('tag-merge' in formatted_update) ok_('pull/1' in formatted_update) ok_('pull/2' in formatted_update) ok_('show_bug.cgi?id=3' in formatted_update) ok_('show_bug.cgi?id=4' in formatted_update)
def test_format_update(self): db = get_session(self.app) p = Project(name='mdndev', slug='mdndev', repo_url='https://github.com/mozilla/kuma') db.add(p) db.commit() content = "#merge pull #1 and pR 2 to fix bug #3 and BUg 4" formatted_update = format_update(content, project=p) ok_('tag-merge' in formatted_update) ok_('pull/1' in formatted_update) ok_('pull/2' in formatted_update) ok_('show_bug.cgi?id=3' in formatted_update) ok_('show_bug.cgi?id=4' in formatted_update)
def test_format_update(self): content = ("#merge pull #1 and pR 2 to fix bug #3 and BUg 4 by " "@jezdez for @r1cky but not [email protected]") with self.app.app_context(): user(username='******', slug='r1cky', save=True) user(username='******', slug='jezdez', email='*****@*****.**', github_handle='jezdez', save=True) p = project(name='mdndev', slug='mdndev', repo_url='https://github.com/mozilla/kuma') formatted_update = format_update(content, project=p) ok_('tag-merge' in formatted_update) ok_('pull/1' in formatted_update) ok_('pull/2' in formatted_update) ok_('show_bug.cgi?id=3' in formatted_update) ok_('show_bug.cgi?id=4' in formatted_update) ok_('/user/jezdez' in formatted_update) ok_('/user/r1cky' in formatted_update) ok_('/user/willkg' not in formatted_update) ok_('/user/mozilla.com' not in formatted_update)
def test_format_update(self): content = ("#merge pull #1 and pR 2 to fix bug #3 and BUg 4 by " "@jezdez for @r1cky but not [email protected]") with self.app.app_context(): user(username='******', slug='r1cky', save=True) user(username='******', slug='jezdez', email='*****@*****.**', github_handle='jezdez', save=True) p = project(name='mdndev', slug='mdndev', repo_url='https://github.com/mozilla/kuma') formatted_update = format_update(content, project=p) ok_('tag-merge' in formatted_update) ok_('pull/1' in formatted_update) ok_('pull/2' in formatted_update) ok_('show_bug.cgi?id=3' in formatted_update) ok_('show_bug.cgi?id=4' in formatted_update) ok_('/user/jezdez' in formatted_update) ok_('/user/r1cky' in formatted_update) ok_('/user/willkg' not in formatted_update) ok_('/user/mozilla.com' not in formatted_update)
def dictify(self, trim_user=False, trim_project=False, include_week=False): """Returns an OrderedDict of model attributes""" if self.reply_to: reply_to_user_id = self.reply_to.user.id reply_to_username = self.reply_to.user.username else: reply_to_user_id = None reply_to_username = None data = OrderedDict() data['id'] = self.id data['created'] = self.created.isoformat() if self.user: if trim_user: data['user'] = self.user.id else: data['user'] = self.user.dictify() else: data['user'] = None if self.project: if trim_project: data['project'] = self.project.id else: data['project'] = self.project.dictify() else: data['project'] = None data['content'] = format_update(self.content_html) data['reply_to_id'] = self.reply_to_id data['reply_to_user_id'] = reply_to_user_id data['reply_to_username'] = reply_to_username data['reply_count'] = self.reply_count if include_week: data['week_start'] = self.week_start.strftime("%Y-%m-%d") data['week_end'] = self.week_end.strftime("%Y-%m-%d") return data
def format_status(status): """Format a status update inside an Atom feed with HTML filters.""" return markdown(urlize(format_update(status.content_html, status.project)))
def format_status(status): """Format a status update inside an Atom feed with HTML filters.""" return markdown(urlize(format_update(status.content_html, status.project)))