Exemplo n.º 1
0
    def __createuser(self, pid):
        login = hummingbird.make_uuid()
        password = "******"

        print("----newuser---- pid: {0} login: {1} password: {2}".format(
            pid, login, password))
        jresult = hummingbird.post(
            "http://localhost:5555/newuser/{0}".format(pid),
            login=login,
            password=password)
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertEqual(jresult["code"], 0)

        print("----loginuser---- pid: {0} login: {1} password: {2}".format(
            pid, login, password))
        jresult = hummingbird.post(
            "http://localhost:5555/loginuser/{0}".format(pid),
            login=login,
            password=password)
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertEqual(jresult["code"], 0)
        self.assertIn("token", jresult)

        token = jresult["token"]

        return token
        pass
Exemplo n.º 2
0
    def test_12_messages(self):
        print("----messages----")

        print("----newmessageschannel---- token: {0} pid: {1}".format(
            Testing.account_token, Testing.pid))
        jresult = hummingbird.post(
            "http://localhost:5555/newmessageschannel/{0}/{1}".format(
                Testing.account_token, Testing.pid),
            maxpost=64)
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertEqual(jresult["code"], 0)
        self.assertIn("uid", jresult)

        channel = jresult["uid"]

        token0 = self.__createuser(Testing.pid)
        token1 = self.__createuser(Testing.pid)

        postid0 = self.__postmessagechannel(token0, channel, "Hello World!",
                                            "<hello>")
        postid1 = self.__postmessagechannel(token1, channel, "Happy World!",
                                            "<happy>")

        print("----getmessageschannel---- token: {0}".format(token0))
        jresult = hummingbird.post(
            "http://localhost:5555/getmessageschannel/{0}".format(token0),
            uid=channel,
            postid=0)
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertEqual(jresult["code"], 0)
        pass
Exemplo n.º 3
0
    def test_13_events(self):
        print("----events----")

        print("----neweventstopic---- token: {0} pid: {1}".format(
            Testing.account_token, Testing.pid))
        jresult = hummingbird.post(
            "http://localhost:5555/neweventstopic/{0}/{1}".format(
                Testing.account_token, Testing.pid),
            name="daily",
            delay=5)
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertEqual(jresult["code"], 0)
        self.assertIn("uid", jresult)

        topic = jresult["uid"]

        print("topic: ", topic)

        token0 = self.__createuser(Testing.pid)

        self.__geteventstopic(token0, topic)
        self.__geteventstopic(token0, topic)
        self.__geteventstopic(token0, topic)
        pass
Exemplo n.º 4
0
    def test_11_getleaderboard(self):
        begin = 0
        end = 10
        print("----getleaderboard---- token: {0} beign: {1} end: {2}".format(
            Testing.user_token, begin, end))
        jresult = hummingbird.post(
            "http://localhost:5555/getleaderboard/{0}".format(
                Testing.user_token),
            begin=begin,
            end=end)
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertEqual(jresult["code"], 0)
        self.assertEqual(jresult["leaderboard"][0]["nickname"], "nick")
        self.assertEqual(jresult["leaderboard"][0]["score"], 250)
        self.assertEqual(jresult["leaderboard"][1]["nickname"], "alice")
        self.assertEqual(jresult["leaderboard"][1]["score"], 200)
        self.assertEqual(jresult["leaderboard"][2]["nickname"], "jennifer")
        self.assertEqual(jresult["leaderboard"][2]["score"], 150)
        self.assertEqual(jresult["leaderboard"][3]["nickname"], "bob")
        self.assertEqual(jresult["leaderboard"][3]["score"], 100)
        self.assertEqual(jresult["leaderboard"][4]["nickname"], "dave")
        self.assertEqual(jresult["leaderboard"][4]["score"], 50)
        pass
Exemplo n.º 5
0
    def __setleaderscore(self, token, score):
        print("----setleaderscore---- token: {0} {1}".format(token, score))
        jresult = hummingbird.post(
            "http://localhost:5555/setleaderscore/{0}".format(token),
            score=score)
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertEqual(jresult["code"], 0)
        pass
Exemplo n.º 6
0
    def __setusernickname(self, token, nickname):
        print("----setusernickname---- token: {0} {1}".format(token, nickname))
        jresult = hummingbird.post(
            "http://localhost:5555/setusernickname/{0}".format(token),
            nickname=nickname)
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertEqual(jresult["code"], 0)
        pass
Exemplo n.º 7
0
    def test_02_newproject(self):
        print("----newproject---- token: {0}".format(Testing.account_token))
        jresult = hummingbird.post(
            "http://localhost:5555/newproject/{0}".format(
                Testing.account_token))
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertEqual(jresult["code"], 0)
        self.assertIn("pid", jresult)

        Testing.pid = jresult["pid"]
        pass
Exemplo n.º 8
0
    def test_01_loginaccount(self):
        print("----loginaccount---- login: {0} password: {1}".format(
            Testing.account_login, Testing.account_password))
        jresult = hummingbird.post("http://localhost:5555/loginaccount",
                                   login=Testing.account_login,
                                   password=Testing.account_password)
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertEqual(jresult["code"], 0)
        self.assertIn("token", jresult)

        Testing.account_token = jresult["token"]
        pass
Exemplo n.º 9
0
    def test_00_newaccount(self):
        Testing.account_login = hummingbird.make_uuid()
        Testing.account_password = "******"

        print("----newaccount---- login: {0} password: {1}".format(
            Testing.account_login, Testing.account_password))
        jresult = hummingbird.post("http://localhost:5555/newaccount",
                                   login=Testing.account_login,
                                   password=Testing.account_password)
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertEqual(jresult["code"], 0)
        pass
Exemplo n.º 10
0
    def test_05_newuser(self):
        Testing.user_login = hummingbird.make_uuid()
        Testing.user_password = "******"

        print("----newuser---- pid: {0} login: {1} password: {2}".format(
            Testing.pid, Testing.user_login, Testing.user_password))
        jresult = hummingbird.post("http://localhost:5555/newuser/{0}".format(
            Testing.pid),
                                   login=Testing.user_login,
                                   password=Testing.user_password)
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertEqual(jresult["code"], 0)
        pass
Exemplo n.º 11
0
    def test_06_loginuser(self):
        print("----loginuser---- pid: {0} login: {1} password: {2}".format(
            Testing.pid, Testing.user_login, Testing.user_password))
        jresult = hummingbird.post(
            "http://localhost:5555/loginuser/{0}".format(Testing.pid),
            login=Testing.user_login,
            password=Testing.user_password)
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertEqual(jresult["code"], 0)
        self.assertIn("token", jresult)

        Testing.user_token = jresult["token"]
        pass
Exemplo n.º 12
0
    def __postmessagechannel(self, token, channel, message, metainfo):
        print("----postmessageschannel---- token: {0} channel: {1}".format(
            token, channel))
        jresult = hummingbird.post(
            "http://localhost:5555/postmessageschannel/{0}".format(token),
            uid=channel,
            message=message,
            metainfo=metainfo)
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertEqual(jresult["code"], 0)
        self.assertIn("postid", jresult)

        postid = jresult["postid"]

        return postid
        pass
Exemplo n.º 13
0
    def test_11_getleaderrank(self):
        print("----getleaderrank----")

        token0 = self.__createuser(Testing.pid)

        self.__setusernickname(token0, "test")

        self.__setleaderscore(token0, 175)

        print("----getleaderrank---- token: {0}".format(token0))
        jresult = hummingbird.post(
            "http://localhost:5555/getleaderrank/{0}".format(token0))
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertIn("rank", jresult)
        self.assertEqual(jresult["rank"], 2)
        pass
Exemplo n.º 14
0
    def __geteventstopic(self, token, topic):
        print("----geteventstopic---- token: {0}".format(token))
        jresult = hummingbird.post(
            "http://localhost:5555/geteventstopic/{0}".format(token),
            uid=topic,
            index=-1)
        print("response: ", jresult)

        self.assertIsNotNone(jresult)
        self.assertEqual(jresult["code"], 0)

        index = jresult["index"]
        message = jresult["message"]

        print("index: ", index)
        print("message: ", message)

        return index
        pass