Beispiel #1
0
 def get_token(self):
     """
     获取token
     :return:
     """
     token = LoginApi().login(unionID=self.union_id,
                              source=self.source,
                              nickname=self.nickname,
                              head_pic=self.head_pic,
                              only_token=True)
     return token
 def test_modify_password_successful(self):
     rep_modify = ModifyPassWordApi(USER_MOBILE, PASSWORD).post({
         "oldPassword":
         PASSWORD,
         "password":
         NEW_PASSWORD
     })
     self.assertEqual(rep_modify.status_code, STATUS_CODE)
     message = json.loads(rep_modify.content)['message']
     self.assertEqual(message, '')
     rep = LoginApi().login(USER_MOBILE, NEW_PASSWORD)
     token = json.loads(rep.content)['token']
     self.assertEqual(len(token), 36)
    def test_login_sign_null(self):
        """
        测试请求登录接口sign为空
        """
        login_api = LoginApi()
        login_api.login(unionID=self.union_id, sign_is_null=True)

        self.assertEqual(login_api.get_resp_code(), 301)
        self.assertEqual(login_api.get_resp_message(), u'the sign failed')
    def test_login_head_pic_null(self):
        """
        测试请求登录接口head_pic为空
        """
        login_api = LoginApi()
        login_api.login(unionID=self.union_id, head_pic=None)

        self.assertEqual(login_api.get_resp_code(), 301)
        self.assertEqual(login_api.get_resp_message(), u'the sign failed')
    def test_login_nickname_null(self):
        """
        测试请求登录接口nickname为空
        """
        login_api = LoginApi()
        login_api.login(unionID=self.union_id, nickname=None)

        self.assertEqual(login_api.get_resp_code(), 301)
        self.assertEqual(login_api.get_resp_message(), u'the sign failed')
    def test_login_success(self):
        """
        测试登录成功
        """
        login_api = LoginApi()
        login_api.login(unionID=self.union_id)

        self.assertEqual(login_api.get_resp_code(), 200)
        self.assertEqual(login_api.get_resp_message(), u'success')

        user_details = MysqlHelper().get_user_details(self.union_id)
        result = login_api.get_resp_result()
        self.assertEqual(result['id'], user_details['id'])
        self.assertEqual(result['userName'], user_details['user_name'])
        self.assertEqual(result['userStatus'], user_details['user_status'])
        self.assertEqual(result['unionId'], self.union_id)
        self.assertEqual(result['nickname'], user_details['nickname'])
        self.assertEqual(result['headPic'], user_details['head_pic'])
        self.assertEqual(result['platformId'], user_details['platform_id'])
        self.assertEqual(result['authId'], user_details['auth_id'])
    def test_first_login_register(self):
        """
        测试首次登录数据库信息
        """
        nickname = '我是测试001'
        head_pic = 'https://pic.dawang.tv/files/images/heads/2a/22/20170705213141666.jpeg'
        login_api = LoginApi()
        login_api.login(unionID=self.new_union_id, source=1, nickname=nickname, head_pic=head_pic)

        self.assertEqual(login_api.get_resp_code(), 200)
        self.assertEqual(login_api.get_resp_message(), u'success')

        user_details = MysqlHelper().get_user_details(self.new_union_id)
        result = login_api.get_resp_result()
        self.assertEqual(result['id'], user_details['id'])
        self.assertEqual(result['userName'], user_details['user_name'])
        self.assertEqual(result['userStatus'], user_details['user_status'])
        self.assertEqual(result['unionId'], self.new_union_id)
        self.assertEqual(result['nickname'], user_details['nickname'])
        self.assertEqual(result['headPic'], user_details['head_pic'])
        self.assertEqual(result['platformId'], user_details['platform_id'])
        self.assertEqual(result['authId'], user_details['auth_id'])