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:])) assert format_update(tag) == expected # Test invalid tags. for tag in ('#1', '#.abc', '#?abc'): assert format_update(tag) == tag
def dictify(self): """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: data['user'] = self.user.dictify() else: data['user'] = None if self.project: 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 # FIXME: What do we need these for? # data['week_start'] = self.week_start.strftime("%Y-%m-%d") # data['week_end'] = self.week_end.strftime("%Y-%m-%d") return data