def test_comment_reply_api_key(self): comment = PageComment() comment.page_object = self.page comment.scope_object = self.project comment.author = self.user comment.content = "blah blah" comment.save() data = { u"api-key": "notthecorrectkey", u"from": u"*****@*****.**", u"text": u"Some stealthy reply that won't make it in!\n", } response = self.client.post("/{0}/comments/{1}/email_reply/".format(self.locale, comment.id), data) self.assertEqual(response.status_code, 403)
def test_comment_reply_api_key(self): comment = PageComment() comment.page_object = self.page comment.scope_object = self.project comment.author = self.user comment.content = "blah blah" comment.save() data = { u'api-key': 'notthecorrectkey', u'from': self.test_username, u'text': u'Some stealthy reply that won\'t make it in!\n', } response = self.client.post('/{0}/comments/{1}/email_reply/'.format(self.locale, comment.id), data) self.assertEqual(response.status_code, 403)
def test_repy(self): comment = PageComment() comment.page_object = self.page comment.scope_object = self.project comment.author = self.user comment.content = "blah blah" comment.save() self.client.login(username=self.test_username, password=self.test_password) # post reply data = { 'content': 'This is a reply' } reply_url = '/{0}/comments/{1}/reply/'.format(self.locale, comment.id) response = self.client.post(reply_url, data) comments = PageComment.objects.all() self.assertEquals(comments.count(), 2)
def test_reply_by_email(self): # post a comment comment = PageComment() comment.page_object = self.page comment.scope_object = self.project comment.author = self.user comment.content = "blah blah" comment.save() data = {u"api-key": settings.INTERNAL_API_KEY, u"from": u"*****@*****.**", u"text": u"Maybe this time\n"} comment_count = PageComment.objects.filter(sent_by_email=True).count() response = self.client.post("/{0}/comments/{1}/email_reply/".format(self.locale, comment.id), data) self.assertEqual(response.status_code, 200) comments = PageComment.objects.filter(sent_by_email=True) self.assertEquals(comments.count(), comment_count + 1)
def test_repy(self): comment = PageComment() comment.page_object = self.page comment.scope_object = self.project comment.author = self.user comment.content = "blah blah" comment.save() self.client.login(username=self.test_username, password=self.test_password) # post reply data = {'content': 'This is a reply'} reply_url = '/{0}/comments/{1}/reply/'.format(self.locale, comment.id) response = self.client.post(reply_url, data) comments = PageComment.objects.all() self.assertEquals(comments.count(), 2)
def test_comment_reply_api_key(self): comment = PageComment() comment.page_object = self.page comment.scope_object = self.project comment.author = self.user comment.content = "blah blah" comment.save() data = { u'api-key': 'notthecorrectkey', u'from': self.test_username, u'text': u'Some stealthy reply that won\'t make it in!\n', } response = self.client.post( '/{0}/comments/{1}/email_reply/'.format(self.locale, comment.id), data) self.assertEqual(response.status_code, 403)
def test_reply_by_email(self): # post a comment comment = PageComment() comment.page_object = self.page comment.scope_object = self.project comment.author = self.user comment.content = "blah blah" comment.save() data = { u'api-key': settings.INTERNAL_API_KEY, u'from': self.test_username, u'text': u'Maybe this time\n', } comment_count = PageComment.objects.filter(sent_by_email=True).count() response = self.client.post('/{0}/comments/{1}/email_reply/'.format(self.locale, comment.id), data) self.assertEqual(response.status_code, 200) comments = PageComment.objects.filter(sent_by_email=True) self.assertEquals(comments.count(), comment_count+1)
def test_reply_by_email(self): # post a comment comment = PageComment() comment.page_object = self.page comment.scope_object = self.project comment.author = self.user comment.content = "blah blah" comment.save() data = { u'api-key': settings.INTERNAL_API_KEY, u'from': self.test_username, u'text': u'Maybe this time\n', } comment_count = PageComment.objects.filter(sent_by_email=True).count() response = self.client.post( '/{0}/comments/{1}/email_reply/'.format(self.locale, comment.id), data) self.assertEqual(response.status_code, 200) comments = PageComment.objects.filter(sent_by_email=True) self.assertEquals(comments.count(), comment_count + 1)