def test_submit(self): i = interpretation.submit(title=u"untitled", author="Anonymous", type=interpretation.T_TEXT, content="fnord") self.assertEquals(comment.count(i), 0) c = comment.submit(author="Anonymous", content="yadda", interpretation_key_string=str(i.key())) self.assertEquals(comment.count(i), 1) l = comment.list_comments(str(i.key())) self.assertEquals(len(l), 1) self.assertEquals(l[0].is_active, True) self.assertEquals(l[0].author, "Anonymous") self.assertEquals(l[0].content, "yadda")
def get_public_info(self): """compute & return API-visible data""" ## the basics info = { 'title': self.title, 'author': self.author, 'created_at': self.created_at.strftime('%a, %d %b %Y %H:%M:%S GMT'), 'type': self.type, 'content_location': "/i/%s" % self.key(), 'short_url': self.short_url, 'is_active': self.is_active, 'comments': comment.count(self), 'key_string': str(self.key()), 'author_location': "/list_interpretations/a/%s/" % urllib.quote(self.author), 'decorated_location': "/interpretation/%s.html" % self.title_link } ## and type-specific properties for property_name in self.properties().iterkeys(): if (property_name.startswith(self.type + '_')): if (self.__dict__['_' + property_name] != None): info[property_name] = self.__dict__['_' + property_name] return info