Example #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)
Example #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")