from datetime import datetime
from django.core.urlresolvers import reverse
from django.test import TestCase, Client
from django.contrib.auth.models import User
from molo.core.tests.base import MoloTestCaseMixin
from molo.commenting.models import MoloComment
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site


class ViewsTestCase(TestCase, MoloTestCaseMixin):

    def setUp(self):
        self.mk_main()
        self.user = User.objects.create_user(
            'test', 'test@example.org', 'test')
        self.content_type = ContentType.objects.get_for_model(self.user)
        self.client = Client()

    def mk_comment(self, comment):
        return MoloComment.objects.create(
            content_type=self.content_type,
            object_pk=self.user.pk,
            content_object=self.user,
            site=Site.objects.get_current(),
            user=self.user,
            comment=comment,
            submit_date=datetime.now())

    def test_reporting_comment(self):
        comment = self.mk_comment('the comment')

        response = self.client.get(
            reverse('molo.commenting:molo-comments-report',
                    args=(comment.pk,)))

        self.assertEqual(response.status_code, 302)

        self.client.login(username='test', password='test')

        response = self.client.get(
            reverse('molo.commenting:molo-comments-report',
                    args=(comment.pk,)))
        self.assertEqual(response.status_code, 302)

@@ -1105,32 +1105,40 @@
 self.client.get(
+reverse(
 %0A            rev
@@ -1130,32 +1130,24 @@
             
-reverse(
 'molo.commen
@@ -1173,36 +1173,16 @@
 report',
-%0A                   
  args=(c
@@ -1225,33 +1225,105 @@
 ual(
-response.status_code, 302
+%0A            response%5B'location'%5D,%0A            '/profiles/login/?next=/commenting/molo/report/1/'
 )%0A%0A 
@@ -1417,16 +1417,24 @@
 ent.get(
+reverse(
 %0A       
@@ -1438,24 +1438,16 @@
         
-reverse(
 'molo.co
@@ -1481,28 +1481,8 @@
 rt',
-%0A                   
  arg
@@ -1536,23 +1536,33 @@
 onse
-.status_code, 302
+%5B'location'%5D, '/cr/4/1/#c1'
 )%0A

update test with saeed