Exemplo n.º 1
0
 def test1_query_equip_auth(self):
     '''
     请求设备认证
     :return:
     '''
     host = self.host
     lujing = 'query_equip_auth'
     text = {
         "EquipAuthSeq": "{}".format(self.EquipAuthSeq),
         "ConnectorID": self.connID
     }
     encrypt_data = encrypt(self.DataSecret, str(text))
     data = {
         "OperatorID":
         self.operator_id,
         "Data":
         "{}".format(encrypt_data),
         "TimeStamp":
         "{}".format(self.times),
         "Seq":
         "0001",
         "Sig":
         "{}".format(
             hmac_md5(self.SigSecret, self.operator_id + encrypt_data +
                      self.times + "0001"))
     }
     headers = self.headers
     res = RunMethod().run_main('post', host, lujing, data, headers)
     undata = eval(decrypt(self.DataSecret, res['Data']))
     miaoshu(url=host + lujing,
             method="post",
             data=text,
             check="{Ret and Msg}",
             respons=undata)
Exemplo n.º 2
0
 def setUpClass(cls):
     host = cls.host
     lujing = 'query_token'
     text = '{"OperatorID":"MA005DBW1","OperatorSecret":"2019092301abcdef"}'
     encrypt_data = encrypt(cls.DataSecret, text)
     data = {
         "OperatorID":
         cls.operator_id,
         "Data":
         "{}".format(encrypt_data),
         "TimeStamp":
         "{}".format(cls.times),
         "Seq":
         "0001",
         "Sig":
         "{}".format(
             hmac_md5(cls.SigSecret,
                      cls.operator_id + encrypt_data + cls.times + "0001"))
     }
     headers = cls.headers
     res = RunMethod().run_main('post', host, lujing, data, headers)
     # res = requests.post(url=host + lujing, data=data, headers=header
     print(res)
     token = eval(decrypt(cls.DataSecret, res['Data']))['AccessToken']
     cls.headers['Authorization'] = 'Bearer ' + token
     return cls.headers
Exemplo n.º 3
0
    def setUpClass(cls):
        host = cls.host
        lujing = 'query_token'
        text = '{"OperatorID":"MA59CU773","OperatorSecret":"7iPn98cO06iK6oP7"}'
        encrypt_data = encrypt(cls.DataSecret, text)
        print(encrypt_data)
        data = {
            "OperatorID":
            cls.operator_id,
            "Data":
            "{}".format(encrypt_data),
            "TimeStamp":
            "{}".format(cls.times),
            "Seq":
            "0001",
            "Sig":
            "{}".format(
                hmac_md5(cls.SigSecret,
                         cls.operator_id + encrypt_data + cls.times + "0001"))
        }

        headers = cls.headers
        res = RunMethod().run_main('post', host, lujing, data, headers)

        token = eval(decrypt(cls.DataSecret, res['Data']))['AccessToken']
        cls.headers['Authorization'] = 'Bearer ' + token
        return cls.headers
Exemplo n.º 4
0
 def test3_query_station_status(self):
     '''
     设备接口状态查询
     :return:
     '''
     host = self.host
     lujing = 'query_station_status'
     text = {"StationIDs": ["{}".format(self.stationID)]}
     encrypt_data = encrypt(self.DataSecret, str(text))
     data = {
         "OperatorID":
         self.operator_id,
         "Data":
         "{}".format(encrypt_data),
         "TimeStamp":
         "{}".format(self.times),
         "Seq":
         "0001",
         "Sig":
         "{}".format(
             hmac_md5(self.SigSecret, self.operator_id + encrypt_data +
                      self.times + "0001"))
     }
     headers = self.headers
     res = RunMethod().run_main('post', host, lujing, data, headers)
     undata = eval(decrypt(self.DataSecret, res['Data']))
     miaoshu(url=host + lujing,
             method="post",
             data=text,
             check="{'StationIDs', 'ConnectorStatusInfos'}",
             respons=undata)
     self.assertTrue(res['Ret'] == 0, msg="状态码不正确")
     self.assertIn('StationStatusInfos', undata, msg='返回内容不正确')
Exemplo n.º 5
0
    def test4_query_stations_stats(self):
        '''
        查询统计信息
        :return:
        '''
        host = self.host
        lujing = 'query_station_stats'
        text = {
            "StationID": "{}".format(self.stationID),
            "StartTime": "2019-10-20",
            "EndTime": "2019-11-20"
        }

        encrypt_data = encrypt(self.DataSecret, str(text))
        data = {
            "OperatorID":
            self.operator_id,
            "Data":
            "{}".format(encrypt_data),
            "TimeStamp":
            "{}".format(self.times),
            "Seq":
            "0001",
            "Sig":
            "{}".format(
                hmac_md5(self.SigSecret, self.operator_id + encrypt_data +
                         self.times + "0001"))
        }
        headers = self.headers
        res = RunMethod().run_main('post', host, lujing, data, headers)
        # res = requests.post(url=host + lujing, json=data, headers=headers)
        undata = eval(decrypt(self.DataSecret, res['Data']))
        miaoshu(url=host + lujing,
                method="post",
                data=text,
                check="{'Ret': 0, 'Msg': '请求成功',}",
                respons=undata)
        self.assertTrue(res['Ret'] == 0, msg="状态码不正确")
        self.assertIn('StationStatsInfo', undata, msg='返回内容不正确')
Exemplo n.º 6
0
 def test3_query_start_charge(self):
     '''
     请求开始充电
     :return:
     '''
     host = self.host
     lujing = 'query_start_charge'
     text = {
         "StartChargeSeq": "{}".format(self.order),
         "ConnectorID": "{}".format(self.connID)
     }
     encrypt_data = encrypt(self.DataSecret, str(text))
     data = {
         "OperatorID":
         self.operator_id,
         "Data":
         "{}".format(encrypt_data),
         "TimeStamp":
         "{}".format(self.times),
         "Seq":
         "0001",
         "Sig":
         "{}".format(
             hmac_md5(self.SigSecret, self.operator_id + encrypt_data +
                      self.times + "0001"))
     }
     headers = self.headers
     res = RunMethod().run_main('post', host, lujing, data, headers)
     undata = eval(decrypt(self.DataSecret, res['Data']))
     miaoshu(url=host + lujing,
             method="post",
             data=text,
             check="{Ret and Msg}",
             respons=undata)
     self.assertTrue(res['Ret'] == 0, msg="状态码不正确")
     self.assertTrue(res['Msg'] == "请求成功", msg="返回msg不正确")