示例#1
0
    def test_no_absolute_url(self):
        self.client.login(username='******', password='******')

        get_absolute_url = User.get_absolute_url
        User.get_absolute_url = None

        follow_url = utils.follow_link(self.hendrix)

        response = self.client.post(follow_url)
        self.assertEqual(500, response.status_code)
示例#2
0
    def test_no_absolute_url(self):
        self.client.login(username='******', password='******')

        get_absolute_url = User.get_absolute_url
        User.get_absolute_url = None

        follow_url = utils.follow_link(self.hendrix)

        response = self.client.post(follow_url)
        self.assertEqual(500, response.status_code)
示例#3
0
    def test_template_tags(self):
        follow_url = reverse('follow', args=['auth', 'user', self.hendrix.id])
        unfollow_url = reverse('unfollow',
                               args=['auth', 'user', self.hendrix.id])

        request = type('Request', (object, ), {'user': self.lennon})()

        self.assertEqual(follow_url, utils.follow_link(self.hendrix))
        self.assertEqual(unfollow_url, utils.unfollow_link(self.hendrix))

        tpl = template.Template(
            """{% load follow_tags %}{% follow_url obj %}""")
        ctx = template.Context({'obj': self.hendrix, 'request': request})

        self.assertEqual(follow_url, tpl.render(ctx))

        utils.follow(self.lennon, self.hendrix)

        self.assertEqual(unfollow_url, tpl.render(ctx))

        utils.unfollow(self.lennon, self.hendrix)

        self.assertEqual(follow_url, tpl.render(ctx))

        tpl = template.Template(
            """{% load follow_tags %}{% follow_url obj user %}""")
        ctx2 = template.Context({
            'obj': self.lennon,
            'user': self.hendrix,
            'request': request
        })

        self.assertEqual(utils.follow_url(self.hendrix, self.lennon),
                         tpl.render(ctx2))

        tpl = template.Template(
            """{% load follow_tags %}{% if request.user|is_following:obj %}True{% else %}False{% endif %}"""
        )

        self.assertEqual("False", tpl.render(ctx))

        utils.follow(self.lennon, self.hendrix)

        self.assertEqual("True", tpl.render(ctx))

        tpl = template.Template(
            """{% load follow_tags %}{% follow_form obj %}""")
        self.assertEqual(True, isinstance(tpl.render(ctx), unicode))

        tpl = template.Template(
            """{% load follow_tags %}{% follow_form obj "follow/form.html" %}"""
        )
        self.assertEqual(True, isinstance(tpl.render(ctx), unicode))
示例#4
0
 def test_template_tags(self):
     follow_url = reverse('follow', args=['auth', 'user', self.hendrix.id])
     unfollow_url = reverse('unfollow', args=['auth', 'user', self.hendrix.id])
     
     request = type('Request', (object,), {'user': self.lennon})()
     
     self.assertEqual(follow_url, utils.follow_link(self.hendrix))
     self.assertEqual(unfollow_url, utils.unfollow_link(self.hendrix))
     
     tpl = template.Template("""{% load follow_tags %}{% follow_url obj %}""")
     ctx = template.Context({
         'obj':self.hendrix,
         'request': request
     })
     
     self.assertEqual(follow_url, tpl.render(ctx))
     
     utils.follow(self.lennon, self.hendrix)
     
     self.assertEqual(unfollow_url, tpl.render(ctx))
     
     utils.unfollow(self.lennon, self.hendrix)
     
     self.assertEqual(follow_url, tpl.render(ctx))
     
     tpl = template.Template("""{% load follow_tags %}{% follow_url obj user %}""")
     ctx2 = template.Context({
         'obj': self.lennon,
         'user': self.hendrix,
         'request': request
     })
     
     self.assertEqual(utils.follow_url(self.hendrix, self.lennon), tpl.render(ctx2))
     
     tpl = template.Template("""{% load follow_tags %}{% if request.user|is_following:obj %}True{% else %}False{% endif %}""")
     
     self.assertEqual("False", tpl.render(ctx))
     
     utils.follow(self.lennon, self.hendrix)
     
     self.assertEqual("True", tpl.render(ctx))
     
     tpl = template.Template("""{% load follow_tags %}{% follow_form obj %}""")
     self.assertEqual(True, isinstance(tpl.render(ctx), str))
     
     tpl = template.Template("""{% load follow_tags %}{% follow_form obj "follow/form.html" %}""")
     self.assertEqual(True, isinstance(tpl.render(ctx), str))
示例#5
0
    def test_template_tags(self):
        follow_url = reverse("follow", args=["auth", "user", self.hendrix.id])
        unfollow_url = reverse("unfollow", args=["auth", "user", self.hendrix.id])

        request = type("Request", (object,), {"user": self.lennon})()

        self.assertEqual(follow_url, utils.follow_link(self.hendrix))
        self.assertEqual(unfollow_url, utils.unfollow_link(self.hendrix))

        tpl = template.Template("""{% load follow_tags %}{% follow_url obj %}""")
        ctx = template.Context({"obj": self.hendrix, "request": request})

        self.assertEqual(follow_url, tpl.render(ctx))

        utils.follow(self.lennon, self.hendrix)

        self.assertEqual(unfollow_url, tpl.render(ctx))

        utils.unfollow(self.lennon, self.hendrix)

        self.assertEqual(follow_url, tpl.render(ctx))

        tpl = template.Template("""{% load follow_tags %}{% follow_url obj user %}""")
        ctx2 = template.Context({"obj": self.lennon, "user": self.hendrix, "request": request})

        self.assertEqual(utils.follow_url(self.hendrix, self.lennon), tpl.render(ctx2))

        tpl = template.Template(
            """{% load follow_tags %}{% if request.user|is_following:obj %}True{% else %}False{% endif %}"""
        )

        self.assertEqual("False", tpl.render(ctx))

        utils.follow(self.lennon, self.hendrix)

        self.assertEqual("True", tpl.render(ctx))

        tpl = template.Template("""{% load follow_tags %}{% follow_form obj %}""")
        self.assertEqual(True, isinstance(tpl.render(ctx), unicode))

        tpl = template.Template("""{% load follow_tags %}{% follow_form obj "follow/form.html" %}""")
        self.assertEqual(True, isinstance(tpl.render(ctx), unicode))