Exemplo n.º 1
0
 def test_get_alike_torrents(self):
     anime = Anime(cn_name=u'JOJO', name=u'JOJO的奇妙冒险')
     Torrent(title=u'JOJO的奇妙冒险[1]', link='http://t.tt/link/1', enclosure='http://dsf.io/1').create()
     Torrent(title=u'JOJO的奇妙冒险[2]', link='http://t.tt/link/2', enclosure='http://dsf.io/2').create()
     length = 0
     for t in anime.get_alike_torrents(5):
         length += 1
     assert length == 2
Exemplo n.º 2
0
 def test_get_alike_animes(self):
     Anime(cn_name=u'物语系列', name=u'物语系列').create()
     Anime(cn_name=u'物语系列2', name=u'物语系列2').create()
     Anime(cn_name=u'化物语', name=u'化物语').create()
     length = 0
     for anime in Anime.get_alike_animes(u'物语'):
         length += 1
     assert length == 3
Exemplo n.º 3
0
 def test_delete(self):
     Anime(cn_name=u'虫师',
           tags='',
           finished=0,
           first_time=datetime.date(2014, 4, 4),
           name='').create()
     Anime(cn_name=u'JOJO', name=u'JOJO的奇妙冒险').create()
     assert Anime.query.count() == 2
     ts = Anime.query.all()
     for t in ts:
         t.delete()
     assert Anime.query.count() == 0
Exemplo n.º 4
0
 def test_get_newest_added(self):
     Anime(cn_name=u'虫师',
           tags='',
           finished=0,
           first_time=datetime.date(2014, 4, 4),
           name='').create()
     Anime(cn_name=u'JOJO', name=u'JOJO的奇妙冒险').create()
     animes = Anime.get_newest_added(5)
     assert animes[0].id == 2
     assert animes[0].cn_name == u'JOJO'
     assert animes[1].id == 1
     assert animes[1].cn_name == u'虫师'
Exemplo n.º 5
0
 def test_get_alike_torrents(self):
     anime = Anime(cn_name=u'JOJO', name=u'JOJO的奇妙冒险')
     Torrent(title=u'JOJO的奇妙冒险[1]',
             link='http://t.tt/link/1',
             enclosure='http://dsf.io/1').create()
     Torrent(title=u'JOJO的奇妙冒险[2]',
             link='http://t.tt/link/2',
             enclosure='http://dsf.io/2').create()
     length = 0
     for t in anime.get_alike_torrents(5):
         length += 1
     assert length == 2
Exemplo n.º 6
0
 def test_create(self):
     assert Anime.query.count() == 0
     Anime(cn_name=u'龙珠',
           tags='',
           finished=0,
           first_time=datetime.date.today(),
           name='').create()
     Anime(cn_name=u'虫师',
           tags='',
           finished=0,
           first_time=datetime.date(2014, 4, 4),
           name='').create()
     Anime(cn_name=u'JOJO', name=u'JOJO的奇妙冒险').create()
     assert Anime.query.count() == 3
Exemplo n.º 7
0
 def test_create(self):
     Anime(cn_name=u'乒乓', name=u'乒乓').create()
     assert AnimeReview.query.count() == 0
     AnimeReview(anime_id=1,
                 title='test1',
                 link='http://test.com/1',
                 summary='').create()
     assert AnimeReview.query.count() == 1
Exemplo n.º 8
0
 def test_update(self):
     Anime(cn_name=u'龙珠改', name=u'龙珠').create()
     ActorQuote(anime_id=1, actor_line='', actor_pic='', actor='').create()
     t = ActorQuote.query.all()[0]
     t.actor_line = 'test'
     t.update()
     ts = ActorQuote.query.all()[0]
     assert ts.actor_line == 'test'
Exemplo n.º 9
0
 def test_get_newest_added(self):
     Anime(cn_name=u'虫师', tags='', finished=0, first_time=datetime.date(2014, 4, 4), name='').create()
     Anime(cn_name=u'JOJO', name=u'JOJO的奇妙冒险').create()
     animes = Anime.get_newest_added(5)
     assert animes[0].id == 2
     assert animes[0].cn_name == u'JOJO'
     assert animes[1].id == 1
     assert animes[1].cn_name == u'虫师'
Exemplo n.º 10
0
 def test_get_alike_animes(self):
     Anime(cn_name=u'物语系列', name=u'物语系列').create()
     Anime(cn_name=u'物语系列2', name=u'物语系列2').create()
     Anime(cn_name=u'化物语', name=u'化物语').create()
     length = 0
     for anime in Anime.get_alike_animes(u'物语'):
         length += 1
     assert length == 3
Exemplo n.º 11
0
 def test_delete(self):
     Anime(cn_name=u'龙珠改', name=u'龙珠').create()
     ActorQuote(anime_id=1, actor_line='', actor_pic='', actor='').create()
     ActorQuote(anime_id=1, actor_line='', actor_pic='', actor='').create()
     assert ActorQuote.query.count() == 2
     ts = ActorQuote.query.all()
     for t in ts:
         t.delete()
     assert ActorQuote.query.count() == 0
Exemplo n.º 12
0
 def test_update(self):
     Anime(cn_name=u'龙珠',
           tags='',
           finished=0,
           first_time=datetime.date.today(),
           name='').create()
     t = Anime.query.all()[0]
     t.title = 'test'
     assert t.title == 'test'
Exemplo n.º 13
0
 def test_update(self):
     Anime(cn_name=u'乒乓', name=u'乒乓').create()
     AnimeReview(anime_id=1,
                 title='test1',
                 link='http://test.com/1',
                 summary='').create()
     t = AnimeReview.query.all()[0]
     t.summary = 'test'
     t.update()
     ts = AnimeReview.query.all()[0]
     assert ts.summary == 'test'
Exemplo n.º 14
0
 def test_like(self):
     User(nickname='kxxoling',
          openid='',
          google_account='*****@*****.**').register()
     Anime(cn_name=u'JOJO', name=u'JOJO的奇妙冒险').create()
     anime = Anime.query.all()[0]
     anime.add_recommend(
         ActorQuote(anime_id=1, actor_line='', actor_pic='', actor=''))
     user = User.query.all()[0]
     quote = ActorQuote.query.all()[0]
     user.like(quote)
     assert ActorQuote.query.all()[0].likes == 1
Exemplo n.º 15
0
def search():
    if request.args.get("q"):
        info = request.args["q"]
        try:
            anime_id = int(info)
            return redirect(url_for(".show_anime", anime_id=anime_id))
        except ValueError:
            animes = Anime.get_alike_animes(info)
            return render_template("search.html", animes=animes)
    else:
        flash("You need to type something to search!")
        return redirect(url_for("index.index"))
Exemplo n.º 16
0
def search():
    if request.args.get('q'):
        info = request.args['q']
        try:
            anime_id = int(info)
            return redirect(url_for('.show_anime', anime_id=anime_id))
        except ValueError:
            animes = Anime.get_alike_animes(info)
            return render_template('search.html', animes=animes)
    else:
        flash('You need to type something to search!')
        return redirect(url_for('index.index'))
Exemplo n.º 17
0
 def test_delete(self):
     Anime(cn_name=u'乒乓', name=u'乒乓').create()
     AnimeReview(anime_id=1,
                 title='test1',
                 link='http://test.com/1',
                 summary='').create()
     AnimeReview(anime_id=1, title='test2',
                 link='http://test.org/2').create()
     assert AnimeReview.query.count() == 2
     ts = AnimeReview.query.all()
     for t in ts:
         t.delete()
     assert AnimeReview.query.count() == 0
Exemplo n.º 18
0
 def test_add_recommend(self):
     Anime(cn_name=u'JOJO', name=u'JOJO的奇妙冒险').create()
     anime = Anime.query.all()[0]
     actor_line = u'人被杀就会死'
     actor = u'卫宫士郎'
     anime.add_recommend(
         ActorQuote(actor_line=actor_line, actor_pic='', actor=actor))
     anime.add_recommend(
         AnimeReview(title='test1',
                     link='http://test.com/1',
                     summary='summarytest'))
     quote = ActorQuote.query.all()[0]
     review = AnimeReview.query.all()[0]
     assert quote.actor_line == actor_line
     assert quote.actor == actor
     assert review.title == 'test1'
     assert review.summary == 'summarytest'
     assert review.link == 'http://test.com/1'
Exemplo n.º 19
0
 def set_anime(self):
     [year, month, day] = self.date.data.split(' ')[0].split('-')
     dt = datetime.date(int(year), int(month), int(day))
     user = Anime(cn_name=self.cn_name.data, name=self.name.data, first_time=dt, tags=self.tags.data,
                  finished=self.finished.data)
     return user
Exemplo n.º 20
0
 def wrapper(*args, **kwargs):
     anime = Anime(cn_name=u'物语系列')
     anime.id = 2
     g.newest_added_animes = [anime]
     g.newest_updated_animes = []
     return func(*args, **kwargs)
Exemplo n.º 21
0
 def test_create(self):
     Anime(cn_name=u'龙珠改', name=u'龙珠').create()
     assert ActorQuote.query.count() == 0
     ActorQuote(anime_id=1, actor_line='', actor_pic='', actor='').create()
     assert ActorQuote.query.count() == 1
Exemplo n.º 22
0
#! -*- coding: utf8 -*-
from website import app
from website.models.models import Anime, ActorQuote, AnimeReview, Torrent, User

if __name__ == '__main__':
    User(
        'kxxoling',
        'https://www.google.com/accounts/o8/id?id=AItOawnbfJtiF3G0UihMZZ06LyoJjKM2L3bp4LQ',
        '*****@*****.**').create()
    Anime(u'化物语', u'化物语', finished=1, name=u'化物语').create()
    Anime(u'囮物语', u'物语系列', finished=1, name=u'物语系列').create()
    Anime(u'物语系列(二)', u'物语系列(二)', finished=1, name=u'物语系列(二)').create()
    Anime(u'虫师 续章', u'虫师 续章', finished=1, name=u'虫师 续章').create()
    assert Anime.query.count >= 4
    ActorQuote(u'好奇心就像蟑螂——随意的打听不想被人触及的秘密。让人郁闷到不行。伤脑筋的恶心虫子。', 1,
               actor=u'战场原黑仪').create()
    ActorQuote(
        u'不过,心神荡漾的荡字,是个很不错的词。你知道吗?草字头下一个汤。我觉得,这要比草字头下一个明的萌字更上一层楼。'
        u'作为次世代的敏感单词,它很受期待哟。比如、女仆荡漾、猫耳荡漾之类。',
        1,
        actor=u'战场原黑仪').create()
    ActorQuote(
        u'喜欢的东西变得厌倦了,喜欢的东西变得讨厌了——这很难受吧,这很无趣吧?一般来说,十份现在的讨厌,加上过去十份的喜欢,'
        u'就会变成二十份的讨厌了吧?这种事——会让人屈服呢',
        1,
        actor=u'战场原黑仪').create()
    ActorQuote(u'好、好厉害。没想到竟然是这么变态的……果然不愧为历哥哥……真不是盖的……不、不对,可是。这个也……',
               2,
               actor=u'千石抚子').create()
    ActorQuote(u'如、如果抚子不可爱的话……月火你在那时候就不跟抚子做朋友……了吗?', 2, actor=u'千石抚子').create()
    ActorQuote(u'呀啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊!',
Exemplo n.º 23
0
 def wrapper(*args, **kwargs):
     anime = Anime(cn_name=u'物语系列')
     anime.id = 2
     g.newest_added_animes = [anime]
     g.newest_updated_animes = []
     return func(*args, **kwargs)