def test_sdk_box(self):
     #登录
     info(u'box登录')
     url_sdk_boxlogin = '******' + self.ip + conf_sdk_boxlogin[
         'uri'] + '?extId=' + self.enterpriseId
     data = self.box
     sdk_boxlogin = requests_normal(conf_sdk_boxlogin['method'],
                                    url_sdk_boxlogin,
                                    data,
                                    self.token,
                                    verify=False,
                                    headers=self.headers_json)
     try:
         self.assertEqual(sdk_boxlogin.status_code, 200, msg=u'box登录')
         self.assertRegexpMatches(str(
             sdk_boxlogin.json()['userDevice']['type']),
                                  '8',
                                  msg=u'box登录')
         self.assertRegexpMatches(str(
             sdk_boxlogin.json()['userDevice']['securityKey']),
                                  '.+',
                                  msg=u'box登录')
         self.assertRegexpMatches(str(
             sdk_boxlogin.json()['userDevice']['nemoNumber']),
                                  '^\d{8}$',
                                  msg=u'box登录')
         numb_box = sdk_boxlogin.json()['userDevice']['nemoNumber']
         sk_box = sdk_boxlogin.json()['userDevice']['securityKey']
     except Exception, e:
         error(e)
         error(sdk_boxlogin.url)
         error(sdk_boxlogin.request.body)
         error(sdk_boxlogin.text)
         raise e
    def test_sdk_hard(self):
        deviceinfo = self.me40

        sn = self.me40tmp['SN']

        #me40登录
        info(u'me40登录')
        url_login_tvbox = 'http://' + self.iauth_ip + conf_login_tvbox['uri']
        data = {
            "deviceSN": sn,
            "packageName": deviceinfo['packageName'],
            "deviceModel": deviceinfo['deviceModel'],
            "category": deviceinfo['category']
        }

        login_me40 = requests_normal(conf_login_tvbox['method'],
                                     url_login_tvbox,
                                     data,
                                     self.token,
                                     verify=False,
                                     headers=self.headers_json)
        try:
            self.assertEqual(login_me40.status_code, 200, msg=u'me40登录')
            securityKey = login_me40.json()['userDevice']['securityKey']
            info(securityKey)
        except Exception, e:
            error(e)
            error(login_me40.url)
            error(login_me40.request.body)
            error(login_me40.text)
            raise e
 def test_sdk_user(self):
     #创建用户
     info(u'创建用户')
     url_sdk_user = '******' + self.ip + conf_sdk_user[
         'uri'] + '?extId=' + self.enterpriseId + '&externalUserId=' + self.externalUserId
     sdk_user = requests_normal(conf_sdk_user['method'],
                                url_sdk_user,
                                '',
                                self.token,
                                verify=False)
     try:
         self.assertEqual(sdk_user.status_code, 200, msg=u'创建用户')
         #self.assertRegexpMatches(sdk_user.text,'"autoRecording":false',msg=u'创建用户')
         account = sdk_user.json()['userName']
         password = sdk_user.json()['password']
     except Exception, e:
         error(e)
         error(sdk_user.url)
         error(sdk_user.request.body)
         error(sdk_user.text)
         raise e
 def test_wechart(self):
     #创建用户
     info(u'wechart创建用户')
     url_sdk_wechatuser = '******' + self.ip + conf_sdk_wechatuser[
         'uri'] + '?enterpriseId=' + self.extid + '&wechatEnId=aab&wechatUserId=bbb&displayName=test1'
     sdk_wechatuser = requests_normal(conf_sdk_wechatuser['method'],
                                      url_sdk_wechatuser,
                                      '',
                                      self.token,
                                      verify=False)
     try:
         self.assertEqual(sdk_wechatuser.status_code,
                          200,
                          msg=u'wechart创建用户')
         account = sdk_wechatuser.json()['userName']
         password = sdk_wechatuser.json()['password']
     except Exception, e:
         error(e)
         error(sdk_wechatuser.url)
         error(sdk_wechatuser.request.body)
         error(sdk_wechatuser.text)
         raise e
class sdk_basic_test(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.enterpriseId = allconf['enterprise']['enterpriseid']
        self.ip = allconf['enterprise']['pivotor_ip']
        self.token = str(allconf['enterprise']['token'])
        self.headers_json = {'content-type': 'application/json'}
        self.phone = json.loads(allconf['enterprise']['sdk_test'])['phone']
        self.pstn = json.loads(allconf['enterprise']['sdk_test'])['pstn']
        self.userconf = json.loads(
            allconf['enterprise']['sdk_test'])['userconf']
        self.cloudconf = json.loads(
            allconf['enterprise']['sdk_test'])['cloudconf']
        self.H323 = json.loads(allconf['enterprise']['sdk_test'])['H323']
        self.externalUserId = json.loads(
            allconf['enterprise']['sdk_test'])['externalUserId']
        self.securityKey_hard = json.loads(
            allconf['enterprise']['sdk_test'])['securityKey_hard']
        self.start_time = (int(time.time()) + 60) * 1000
        self.extid = allconf['enterprise']['extid']
        self.box = json.loads(allconf['enterprise']['box'])
        self.third = json.loads(allconf['enterprise']['third'])
        self.me40 = json.loads(allconf['sdk_login']['me40'])
        self.me40tmp = json.loads(allconf['enterprise']['me40tmp'])
        self.iauth_ip = allconf['sdk_login']['iauth_ip']
        self.me90tmp = json.loads(allconf['enterprise']['me90tmp'])

    def test_sdk_user(self):
        #创建用户
        info(u'创建用户')
        url_sdk_user = '******' + self.ip + conf_sdk_user[
            'uri'] + '?extId=' + self.enterpriseId + '&externalUserId=' + self.externalUserId
        sdk_user = requests_normal(conf_sdk_user['method'],
                                   url_sdk_user,
                                   '',
                                   self.token,
                                   verify=False)
        try:
            self.assertEqual(sdk_user.status_code, 200, msg=u'创建用户')
            #self.assertRegexpMatches(sdk_user.text,'"autoRecording":false',msg=u'创建用户')
            account = sdk_user.json()['userName']
            password = sdk_user.json()['password']
        except Exception, e:
            error(e)
            error(sdk_user.url)
            error(sdk_user.request.body)
            error(sdk_user.text)
            raise e
        time.sleep(1)
        #登录
        info(u'登录')
        url_sdk_login = '******' + self.ip + conf_sdk_login['uri']
        data = {
            "account": account,
            "password": password,
            "deviceSn": "12345666",
            "deviceType": 5,
            "model": "iphone 10",
            "deviceDisplayName": "test_user"
        }
        sdk_login = requests_normal(conf_sdk_login['method'],
                                    url_sdk_login,
                                    data,
                                    self.token,
                                    verify=False,
                                    headers=self.headers_json)
        try:
            self.assertEqual(sdk_login.status_code, 200, msg=u'登录')
            securityKey = sdk_login.json()['securityKey']
            userProfileid = sdk_login.json()['userProfile']['id']

        except Exception, e:
            error(e)
            error(sdk_login.url)
            error(sdk_login.request.body)
            error(sdk_login.text)
            raise e
            'uri'] + '?extId=' + self.enterpriseId
        data = {
            "startTime": self.start_time,
            "duration": "120000",
            "meetingName": "yhuitest",
            "maxParticipantCount": 2,
            "requirePassword": False,
            "autoRecord": False,
            "password": "",
            "meetingNumber": "",
            "autoMute": "0",
            "smartMutePerson": 5
        }
        sdk_conference = requests_normal(conf_sdk_conference['method'],
                                         url_sdk_conference,
                                         data,
                                         self.token,
                                         verify=False,
                                         headers=self.headers_json)
        try:
            self.assertEqual(sdk_conference.status_code,
                             200,
                             msg=u'sdk_conference')
            conference = sdk_conference.json()['meetingNumber']

        except Exception, e:
            error(e)
            error(sdk_conference.url)
            error(sdk_conference.request.body)
            error(sdk_conference.text)
            raise e
        #callurlInfo_phone