Esempio n. 1
0
class ArticleAccessTestCase(TestCase):
    fixtures = ["pages"]

    def setUp(self):
        super().setUp()
        self.client = Client()

        self.article = CommonArticle(pk=1, name="xoxo")
        self.article.save()

    def test_article_present(self):
        res = self.client.get("/rubriky/clanky/1-xoxo/")
        self.assertEquals(200, res.status_code)

    def test_bad_slug_redirect(self):
        res = self.client.get("/rubriky/clanky/1-bad-slug/")
        self.assertEquals(301, res.status_code)

        res = self.client.get("/rubriky/clanky/1-bad-slug/", follow=True)
        self.assertEquals([("/rubriky/clanky/1-xoxo/", 301)],
                          res.redirect_chain)
        self.assertEquals(200, res.status_code)

    def test_redirect_for_empty_slug(self):
        article = CommonArticle(pk=2, name=" ")
        article.save()

        res = self.client.get("/rubriky/clanky/2-random-slug/", follow=True)
        self.assertEquals([("/rubriky/clanky/2-dilo/", 301)],
                          res.redirect_chain)
        self.assertEquals(200, res.status_code)
Esempio n. 2
0
    def test_redirect_for_empty_slug(self):
        article = CommonArticle(pk=2, jmeno=" ")
        article.save()

        res = self.client.get("/rubriky/clanky/2-random-slug/", follow=True)
        self.assertEquals([("/rubriky/clanky/2-dilo/", 301)], res.redirect_chain)
        self.assertEquals(200, res.status_code)
Esempio n. 3
0
def get_valid_article_chain():

    user = UserProfile(nick="Author", email="*****@*****.**")

    author = Author(id=1, user=user, author_type=Author.USER_TYPE)

    article = CommonArticle(
        author=author,
        name="Test Article",
        author_nick=user.nick,
        author_mail=user.email,
        is_published=CommonArticle.CREATION_APPROVED,
        creative_page_slug="clanky",
    )

    return {
        "user": user,
        "author": author,
        "article": article,
    }
Esempio n. 4
0
def get_valid_article_chain():

    user = UserProfile(nick_uzivatele="Author",
                       email_uzivatele="*****@*****.**")

    author = Author(id=1, user=user, author_type=Author.USER_TYPE)

    article = CommonArticle(
        author=author,
        jmeno="Test Article",
        autor=user.nick_uzivatele,
        autmail=user.email_uzivatele,
        schvaleno=CommonArticle.CREATION_APPROVED,
        rubrika="clanky",
    )

    return {
        "user": user,
        "author": author,
        "article": article,
    }
Esempio n. 5
0
 def test_simple(self):
     a = CommonArticle(name="ahoj a hola")
     self.assertEquals("ahoj-a-hola", a.get_slug())
Esempio n. 6
0
 def test_strip_noncombining(self):
     a = CommonArticle(name="ahoj a 你好")
     self.assertEquals("ahoj-a", a.get_slug())
Esempio n. 7
0
 def test_combining(self):
     a = CommonArticle(name="ahoj a ďíky")
     self.assertEquals("ahoj-a-diky", a.get_slug())
Esempio n. 8
0
 def test_upper(self):
     a = CommonArticle(name="ahoj a HOLA")
     self.assertEquals("ahoj-a-hola", a.get_slug())
Esempio n. 9
0
    def setUp(self):
        super().setUp()
        self.client = Client()

        self.article = CommonArticle(pk=1, name="xoxo")
        self.article.save()
Esempio n. 10
0
 def test_simple(self):
     a = CommonArticle(jmeno='ahoj a hola')
     self.assertEquals('ahoj-a-hola', a.get_slug())
Esempio n. 11
0
 def test_strip_noncombining(self):
     a = CommonArticle(jmeno='ahoj a 你好')
     self.assertEquals('ahoj-a', a.get_slug())
Esempio n. 12
0
 def test_combining(self):
     a = CommonArticle(jmeno='ahoj a ďíky')
     self.assertEquals('ahoj-a-diky', a.get_slug())
Esempio n. 13
0
 def test_upper(self):
     a = CommonArticle(jmeno='ahoj a HOLA')
     self.assertEquals('ahoj-a-hola', a.get_slug())
Esempio n. 14
0
    def setUp(self):
        super().setUp()
        self.client = Client()

        self.article = CommonArticle(pk=1, jmeno='xoxo')
        self.article.save()