def test_unicode(self): """ Test Comment.__unicode__() method. """ # Create Comment instance user = self._login() comment = Comment(EDID=self.edid, user=user, level=0, content='') comment.save() self.assertEqual(unicode(comment), "%s: %s" % (comment.pk, comment.content[:100]))
def test_unicode(self): """ Test Comment.__unicode__() method. """ # Create Comment instance user = self._login() comment = Comment(EDID=self.edid, user=user, level=0, content='') comment.save() self.assertEqual( unicode(comment), "%s: %s" % (comment.pk, comment.content[:100]) )
def test_str(self): """ Test Comment.__str__() method. """ # Create Comment instance user = self._login() comment = Comment(EDID=self.edid, user=user, level=0, content='') comment.save() # pylint: disable=unsubscriptable-object self.assertEqual( str(comment), "{}: {}".format(comment.pk, comment.content[:100]) )
def test_get_comments(self): # Create nested comments user = self._login() comment_1 = Comment(EDID=self.edid, user=user, level=0, content='') comment_1.save() comment_2 = Comment(EDID=self.edid, user=user, level=1, parent=comment_1, content='') comment_2.save() comment_3 = Comment(EDID=self.edid, user=user, level=0, content='') comment_3.save() comment_4 = Comment(EDID=self.edid, user=user, level=2, parent=comment_2, content='') comment_4.save() # Get all comments for EDID comments = self.edid.get_comments() # Check comments are ordered self.assertEqual( comments, [ {'comment': comment_1, 'subcomments': [ {'comment': comment_2, 'subcomments': [{'comment': comment_4}]} ]}, {'comment': comment_3} ] )
def test_get_comments(self): # Create nested comments user = self._login() comment_1 = Comment(EDID=self.edid, user=user, level=0, content='') comment_1.save() comment_2 = Comment(EDID=self.edid, user=user, level=1, parent=comment_1, content='') comment_2.save() comment_3 = Comment(EDID=self.edid, user=user, level=0, content='') comment_3.save() comment_4 = Comment(EDID=self.edid, user=user, level=2, parent=comment_2, content='') comment_4.save() # Get all comments for EDID comments = self.edid.get_comments() # Check comments are ordered self.assertEqual(comments, [{ 'comment': comment_1, 'subcomments': [{ 'comment': comment_2, 'subcomments': [{ 'comment': comment_4 }] }] }, { 'comment': comment_3 }])