Ejemplo n.º 1
0
    def test_not_anonymous_form(self):
        idea = create_idea()
        data = get_valid_form_data(idea)

        f = MPTTCommentForm(idea, data=data)
        c = f.get_comment_object()
        self.assertTrue(isinstance(c, MPTTComment))
        self.assertEqual(c.is_anonymous, False)
Ejemplo n.º 2
0
    def test_not_anonymous_form(self):
        idea = create_idea()
        data = get_valid_form_data(idea)

        f = MPTTCommentForm(idea, data=data)
        c = f.get_comment_object()
        self.assertTrue(isinstance(c, MPTTComment))
        self.assertEqual(c.is_anonymous, False)
Ejemplo n.º 3
0
    def test_anonymous_form(self):
        idea = create_idea()
        data = get_valid_form_data(idea)
        data['is_anonymous'] = True

        f = MPTTCommentForm(idea, data=data)
        c = f.get_comment_object()
        self.assertTrue(isinstance(c, MPTTComment))
        self.assertEqual(c.is_anonymous, True)
        # (It is up to the front end to hide the name)
        self.assertEqual(c.user_name, data['name'])
Ejemplo n.º 4
0
    def test_anonymous_form(self):
        idea = create_idea()
        data = get_valid_form_data(idea)
        data['is_anonymous'] = True

        f = MPTTCommentForm(idea, data=data)
        c = f.get_comment_object()
        self.assertTrue(isinstance(c, MPTTComment))
        self.assertEqual(c.is_anonymous, True)
        # (It is up to the front end to hide the name)
        self.assertEqual(c.user_name, data['name'])
Ejemplo n.º 5
0
def get_valid_form_data(obj):
    f = MPTTCommentForm(obj)
    data = {}
    data['comment'] = "sample comment"
    user = random_user()
    data['name'] = user.username
    data['email'] = user.email
    data.update(f.initial)
    return data
Ejemplo n.º 6
0
    def test_anonymous_comment_hidden_name(self):
        idea = create_idea()
        data = get_valid_form_data(idea)
        data['is_anonymous'] = True

        f = MPTTCommentForm(idea, data=data)
        c = f.get_comment_object()
        c.save()

        create_superuser()
        login(self)
        resp = self.client.get(reverse('idea:idea_detail', args=(idea.id,)))
        self.assertFalse(data['name'] in resp.content)

        # add a second comment where anonymous = False
        data['is_anonymous'] = False
        data['comment'] = "new comment"
        f = MPTTCommentForm(idea, data=data)
        c = f.get_comment_object()
        c.save()

        resp = self.client.get(reverse('idea:idea_detail', args=(idea.id,)))
        self.assertTrue(data['name'] in resp.content)
Ejemplo n.º 7
0
    def test_anonymous_comment_hidden_name(self):
        idea = create_idea()
        data = get_valid_form_data(idea)
        data['is_anonymous'] = True

        f = MPTTCommentForm(idea, data=data)
        c = f.get_comment_object()
        c.save()

        create_superuser()
        login(self)
        resp = self.client.get(reverse('idea:idea_detail', args=(idea.id, )))
        self.assertFalse(data['name'] in resp.content)

        # add a second comment where anonymous = False
        data['is_anonymous'] = False
        data['comment'] = "new comment"
        f = MPTTCommentForm(idea, data=data)
        c = f.get_comment_object()
        c.save()

        resp = self.client.get(reverse('idea:idea_detail', args=(idea.id, )))
        self.assertTrue(data['name'] in resp.content)