Пример #1
0
 def test_re(self):
     w = Wklejka()
     w.save()
     url = reverse("reply", kwargs={"id": w.id})
     response = self.client.get(url)
     self.assertEquals(response.status_code, 200)
     self.assertTemplateUsed(response, "homepage.dhtml")
Пример #2
0
 def test_re(self):
     w = Wklejka()
     w.save()
     url = reverse("reply", kwargs={"id": w.id})
     response = self.client.get(url)
     self.assertEquals(response.status_code, 200)
     self.assertTemplateUsed(response, "homepage.dhtml")
Пример #3
0
 def test_public_url(self):
     w = Wklejka(is_private=False, user=self.user)
     w.save()
     self.get(w)
     self.get_txt(w)
     self.get_dl(w)
     self.get_del(w)
     self.post_del(w)
Пример #4
0
    def test_children_count(self):
        parent = Wklejka()
        parent.save()
        self.assertEquals(parent.children_count(), 0)

        child = Wklejka(parent=parent)
        child.save()
        self.assertEquals(parent.children_count(), 1)
Пример #5
0
    def test_is_parent(self):
        parent = Wklejka()
        parent.save()
        self.assertFalse(parent.is_parent())

        child = Wklejka(parent=parent)
        child.save()
        self.assertTrue(parent.is_parent())
Пример #6
0
 def test_public_url(self):
     w = Wklejka(is_private=False, user=self.user)
     w.save()
     self.get(w)
     self.get_txt(w)
     self.get_dl(w)
     self.get_del(w)
     self.post_del(w)
Пример #7
0
 def test_private_url(self):
     w = Wklejka(is_private=True, hash="foobar", user=self.user)
     w.save()
     self.get(w)
     self.get_txt(w)
     self.get_dl(w)
     self.get_del(w)
     self.post_del(w)
Пример #8
0
 def test_private_url(self):
     w = Wklejka(is_private=True, hash="foobar", user=self.user)
     w.save()
     self.get(w)
     self.get_txt(w)
     self.get_dl(w)
     self.get_del(w)
     self.post_del(w)
Пример #9
0
def dodaj_wpis(tresc, syntax, autor="Anonim"):
    """
    Pozwala zdalnie dodawac wpisy do wkleja.
    """

    w = Wklejka(nickname=autor, body=tresc, syntax=syntax)
    w.save()

    return w.get_absolute_url()
Пример #10
0
def auth_dodaj_wpis(tresc, syntax, salt):
    """
    Pozwala zdalnei dodawac wpisy do konta
    """
    try:
        p = UserProfile.objects.get(current_salt=salt)
    except:
        return dodaj_wpis(tresc, syntax)
    w = Wklejka(nickname=p.username(), body=tresc, syntax=syntax,  user=p.user)
    w.save()

    return w.get_absolute_url()
Пример #11
0
    def test_is_child(self):
        parent = Wklejka()
        parent.save()

        child = Wklejka()
        child.save()
        self.assertFalse(child.is_child())

        child.parent = parent
        self.assertTrue(child.is_child())
Пример #12
0
    def test_author(self):
        user = User(username="******")
        self.wklejka = Wklejka(
            user=user,
            nickname="Anonymous",
            body="Foobar",
        )
        self.assertEqual(self.wklejka.author, user)

        self.wklejka = Wklejka(
            nickname="Anonymous",
            body="Foobar",
        )
        self.assertEqual(self.wklejka.author, "Anonymous")
Пример #13
0
    def test_children_count(self):
        parent = Wklejka()
        parent.save()
        self.assertEquals(parent.children_count(), 0)

        child = Wklejka(parent=parent)
        child.save()
        self.assertEquals(parent.children_count(), 1)
Пример #14
0
    def test_is_parent(self):
        parent = Wklejka()
        parent.save()
        self.assertFalse(parent.is_parent())

        child = Wklejka(parent=parent)
        child.save()
        self.assertTrue(parent.is_parent())
Пример #15
0
    def test_get_del_url(self):
        w = Wklejka(hash="foobar", is_private=True)
        w.save()
        self.assertEqual(w.get_del_url(), "/hash/{}/delete/".format(w.hash))

        w.is_private = False
        self.assertEqual(w.get_del_url(), "/id/{}/delete/".format(w.id))
Пример #16
0
def dodaj_prywatny_wpis(tresc, syntax, autor="Anonim"):
    """
    Pozwala zdalnie dodawać prywatne wpisy do wkleja
    """

    w = Wklejka(nickname=autor, body=tresc, syntax=syntax, is_private=True)
    w.save()
    salt = sha.new(str(random.random())).hexdigest()[:10]
    hash = sha.new(salt).hexdigest()[:10]
    w.hash = hash
    w.save()

    return w.get_absolute_url()
Пример #17
0
    def test_get_del_url(self):
        w = Wklejka(hash="foobar", is_private=True)
        w.save()
        self.assertEqual(w.get_del_url(), "/hash/{}/delete/".format(w.hash))

        w.is_private = False
        self.assertEqual(w.get_del_url(), "/id/{}/delete/".format(w.id))
Пример #18
0
def auth_dodaj_prywatny_wpis(tresc, syntax, salt):
    """
    Pozwala zdalnei dodawac wpisy do konta
    """

    try:
        p = UserProfile.objects.get(current_salt=salt)
    except:
        return dodaj_prywatny_wpis(tresc, syntax)

    w = Wklejka(nickname=p.username(), body=tresc, syntax=syntax,
                user=p.user, is_private=True)
    w.save()
    salt = sha.new(str(random.random())).hexdigest()[:10]
    hash = sha.new(salt).hexdigest()[:10]
    w.hash = hash
    w.save()

    return w.get_absolute_url()
Пример #19
0
 def test_get_10_lines(self):
     w = Wklejka(body="\n".join("abcdefghijklmn"))
     self.assertEqual(w.get_10_lines().splitlines()[-1], "j")
Пример #20
0
    def test_hl(self):
        w = Wklejka(syntax="python")
        self.assertEqual(w.hl, "python")

        w = Wklejka(syntax="", guessed_syntax="perl")
        self.assertEqual(w.hl, "perl")
Пример #21
0
 def test_banned_lexer(self):
     w = Wklejka(syntax="raw")
     w.save()
     self.get(w)
Пример #22
0
 def test_get_id_url(self):
     w = Wklejka()
     w.save()
     self.assertEqual(w.get_id_url(), "/id/{}/".format(w.id))
Пример #23
0
    def test_is_child(self):
        parent = Wklejka()
        parent.save()

        child = Wklejka()
        child.save()
        self.assertFalse(child.is_child())

        child.parent = parent
        self.assertTrue(child.is_child())
Пример #24
0
 def handle(self, how_many=100, **options):
     for i in range(int(how_many)):
         w = Wklejka(**wklejka())
         w.save()
         print "WKLEJKA", w.id
Пример #25
0
 def test_get_id_url(self):
     w = Wklejka()
     w.save()
     self.assertEqual(w.get_id_url(), "/id/{}/".format(w.id))
Пример #26
0
 def test_get_hash_url(self):
     w = Wklejka(hash="foobar")
     w.save()
     self.assertEqual(w.get_hash_url(), "/hash/foobar/")
Пример #27
0
 def test_get_hash_url(self):
     w = Wklejka(hash="foobar")
     w.save()
     self.assertEqual(w.get_hash_url(), "/hash/foobar/")
Пример #28
0
 def test_banned_lexer(self):
     w = Wklejka(syntax="raw")
     w.save()
     self.get(w)
Пример #29
0
 def test_get_10_lines(self):
     w = Wklejka(body="\n".join("abcdefghijklmn"))
     self.assertEqual(w.get_10_lines().splitlines()[-1], "j")