Exemplo n.º 1
0
    def test_adventurer(self):
        u = MyUser(email="*****@*****.**")
        u.put()
        c = u.add_adventurer("testadventurer")
        # to_json
        #     c_json = c.to_json()
        #     self.assertEquals(c_json,
        #                       json.dumps({
        #                         'name': 'testadventurer',
        #                         'lv': 1,
        #                         'exp': 0,
        #                         'attack': 1,
        #                         'hp':10,
        #                         'speed':1,
        #                         'guard':1,
        #                         'job' :None,
        #                         'user': u.email}))

        # explore
        e = Entry(
            title=u"exploreタイトル", count=100, url="http://explore.com", entry_url="http://b.hatena.ne.jp/kjkkjkj", eid=10
        )
        e.put()
        b1 = Bookmark(user="******", entry=e)
        b1.put()
        b2 = Bookmark(user="******", entry=e)
        b2.put()
        b3 = Bookmark(user="******", entry=e)
        b3.put()
        b4 = Bookmark(user="******", entry=e)
        b4.put()
        b_res = c.explore(e)
        print b_res
        print isinstance(b_res["win"], bool)
        print isinstance(b_res["results"], list)
Exemplo n.º 2
0
 def test_myuser(self):
     user = MyUser(email="*****@*****.**", first_name=u"testuser")
     user.put()
     # add_adventurer
     user.add_adventurer(u"testadventurer")
     adventurers = Adventurer.all().fetch(100)
     self.assertEquals(len(adventurers), 1)
     self.assertEquals(adventurers[0].name, "testadventurer")
     self.assertEquals(adventurers[0].user.first_name, "testuser")
     user2 = MyUser(email="*****@*****.**", first_name=u"hoge")
     user2.put()
     user2.add_adventurer(u"fuga")
     adventurers2 = Adventurer.all().filter("user ="******"fuga")
     # get_adventurer
     adventurer2 = user2.get_adventurer()
     self.assertEquals(adventurer2.name, "fuga")
Exemplo n.º 3
0
 def test_bookmark(self):
     u = MyUser(email="*****@*****.**", first_name="shin")
     u.put()
     e = Entry(title=u"タイトル4", count=7, url="http://fuga.com", entry_url="http://b.hatena.ne.jp/fuga", eid=4)
     e.put()
     b = Bookmark(
         user=u"jojo",
         tags=["aaa", "bbb"],
         timestamp=datetime.strptime("2011/07/22 21:22:06", "%Y/%m/%d %H:%M:%S"),
         comment=u"コメント",
         entry=e,
     )
     b.put()
     bs = Bookmark.all().fetch(100)
     self.assertEquals(len(bs), 1)
     # add_bookmarks
     e2 = Entry(
         title=u"タイトル5", count=100, url="http://aa.fuga.com", entry_url="http://b.hatena.ne.jp/fugaxxx", eid=5
     )
     e2.put()
     bookmarks = [
         {u"comment": u"", u"tags": [u"api"], u"timestamp": u"2011/07/22 15:36:47", u"user": u"cubick"},
         {
             u"comment": u"\u3053\u308c\u4f7f\u3063\u3066\u306a\u3093\u304b\u3084\u308a\u305f\u3044",
             u"tags": [u"hatena"],
             u"timestamp": u"2011/07/05 23:51:19",
             u"user": u"takuma510",
         },
     ]
     Bookmark.add_bookmarks(bookmarks, e2)
     bs2 = Bookmark.all().fetch(100)
     self.assertEquals(len(bs2), 3)
     self.assertEquals(bs2[1].user, u"cubick")
     # get_bookmarks
     bs3 = Bookmark.get_bookmarks(e)
     self.assertEquals(len(bs3), 1)
     self.assertEquals(bs[0].user, u"jojo")