示例#1
0
    def test_01(self):
        "推送正式项目数据"
        data = process_task.JSONV2_Request(self.ProjectSysNo)
        sourceId = data['sourceId']

        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")

        elkLog = elkSearch.elkSoftware(sourceId, self.method)
        self.assertEqual(1, elkLog['uploadStatus'])
        self.assertEqual(self.ProjectSysNo, elkLog['projectSysNo'])

        mongoLog = self.mongo.getbySourceId(sourceId, "process_task")
        if "partitioningList" in mongoLog:
            del mongoLog['partitioningList']
        if "submitUserList" in mongoLog:
            del mongoLog['submitUserList']
        if "responsibleUserList" in mongoLog:
            del mongoLog['responsibleUserList']

        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongores=mongoLog, elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
示例#2
0
    def test_01(self):
        "推送正式项目数据"
        data = qualityCheck.JSONV2_Request(self.ProjectSysNo)
        sourceId = data['sourceId']
        self.sourceId_update = sourceId

        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkSoftware(sourceId, self.method)
        self.assertEqual(self.ProjectSysNo, elkLog['projectSysNo'])

        mongoLog = self.mongo.getbySourceId(sourceId, "quality_check")
        if 'checkUserList' in mongoLog:
            del mongoLog['checkUserList']
        if 'partitioningList' in mongoLog:
            del mongoLog['partitioningList']

        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongores=mongoLog, elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
示例#3
0
    def test_011(self):
        """推送测试设备数据-推送未定义字段"""
        data = tower_data.JSONV2_Request(self.NdeviceId)
        deviceTime = data['deviceTime']
        data['pm110'] = 100
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        self.assertEqual(1, elkLog['uploadStatus'])

        mongoLog = self.mongo.getbyDeviceTime(deviceTime, "tower_crane")
        if "momentPercent" in mongoLog:
            # data = json.loads(data)
            # la = round(data['liftingCapacity'] * data['amplitude'], 2) / 1.0
            # laa = round(la * data['ratedMoment'] * 100, 2)
            # data['momentPercent'] = laa
            # data = json.dumps(data)
            del mongoLog['momentPercent']

        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongores=mongoLog, elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
示例#4
0
    def test_01(self):
        "推送测试设备数据"
        data = concrete.JSONV2_Request("concrete")
        deviceTime = data['deviceTime']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")

        elkLog = elkSearch.elkDevice(deviceTime, self.method)

        mongoLog = self.mongo.getbyDeviceTime(deviceTime, "concrete_temp")

        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongores=mongoLog, elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
示例#5
0
    def test_04(self):
        "推送正式设备数据-推送未定义字段"
        data = vehicle.JSONV2_Request(deviceID=self.NdeviceId)
        deviceTime = data['deviceTime']
        data['pm110'] = 100
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        self.assertEqual(1, elkLog['uploadStatus'])
        mongoLog = self.mongo.getbyDeviceTime(deviceTime, "vehicle_management")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongores=mongoLog, elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
示例#6
0
    def test_03(self):
        """推送正式设备数据-无usingCount字段"""
        data = water.JSONV2_Request(self.NdeviceId)
        deviceTime = data['deviceTime']
        del data['usingCount']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        self.assertEqual("usingCount字段不能为空", elkLog['exceptionContent'])

        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
示例#7
0
    def test_SoftWare_smoke(self):
        """软件冒烟"""
        mongo = pyMongodb.pymongo('172.16.0.137', 20200)
        sourceID = str(uuid.uuid4())
        deviceTime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        data = {
            "sourceId": sourceID,
            "actualStartTime": deviceTime,
            "planStartTime": "2017-12-14 00:00:00",
            "parentSourceId": str(uuid.uuid4()),
            "sortIndex": 20,
            "completionRate": 0,
            "type": 1,
            "type1": 1,
            "projectSysNo": 10218,
            "partitioningName": "AutoTest-partitioningName2018-07-26 20:26:45",
            "name": "AutoTestName2018-07-26 20:26:45",
            "partitioningId": str(uuid.uuid4()),
            "actualEndTime": "2018-05-26 00:00:00",
            "planEndTime": "2018-05-25 00:00:00",
            "status": 1
        }

        data = json.dumps(data)
        # print(sourceID)
        res = OpenAPI(method='upload.processTaskData', data=data)
        # print(json.dumps(res.json(), indent=2, ensure_ascii=False))

        time.sleep(3.5)
        elkLog = elkSearch.elkSoftware(sourceID)
        # print(elkLog)

        time.sleep(1.5)
        mongoLog = mongo.getbySourceId(sourceID, "process_task")
        # print(mongoLog)

        # print(json.dumps(json.loads(data), indent=2, ensure_ascii=False))
        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongores=mongoLog, elkres=elkLog, reqdata=json.loads(data))
        print(Mongo_ELK_Match, Mongo_ReqData_Match)
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
示例#8
0
    def test_05(self):
        """推送测试设备数据-无safeLiftingCapacity字段"""
        data = tower_data.JSONV2_Request(self.NdeviceId)
        deviceTime = data['deviceTime']
        del data['safeLiftingCapacity']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        self.assertEqual("safeLiftingCapacity字段不能为空",
                         elkLog['exceptionContent'])

        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
示例#9
0
    def test_01(self):
        """推送正式设备数据"""
        data = water.JSONV2_Request(self.NdeviceId)
        deviceTime = data['deviceTime']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")

        elkLog = elkSearch.elkDevice(deviceTime, self.method)

        mongoLog = self.mongo.getbyDeviceTime(deviceTime, "water_meter")
        if 'increment' in mongoLog:
            del mongoLog['increment']

        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongores=mongoLog, elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
示例#10
0
    def test_05(self):
        "推送测试设备数据-推送未定义字段"
        data = concrete.JSONV2_Request("concrete")
        deviceTime = data['deviceTime']
        data['pm110'] = 100
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkDevice(deviceTime, self.method)

        # mongoLog = self.mongo.getbyDeviceTime(deviceTime, "env_monitor")

        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
示例#11
0
    def test_01(self):
        """推送正式设备数据"""
        data = env_data.JSONV2_Request(self.NdeviceId)
        deviceTime = data['deviceTime']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        self.assertEqual(1, elkLog['uploadStatus'], elkLog)

        mongoLog = self.mongo.getbyDeviceTime(deviceTime, "env_monitor")
        del mongoLog['aqiValue']

        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongores=mongoLog, elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
    def test_01(self):
        """推送测试设备数据"""
        # mongo = pyMongodb.pymongo('172.16.0.137', 20200)
        data = intrusion_detector.JSONV2_Request(deviceID=self.NdeviceId)
        deviceTime = data['deviceTime']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkDevice(deviceTime, self.method)

        mongoLog = self.mongo.getbyDeviceTime(deviceTime, "intrusion_detector")

        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongores=mongoLog, elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
    def test_01(self):
        "推送正式设备数据"
        data = construction.JSONV2_Request("construction")
        longitude = data['longitude']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'], res.json())

        elkLog = elkSearch.elkParams(longitude, self.method)

        mongoLog = self.mongo.getbyParams(
            longitude, "construction_elevator_device_params")
        del mongoLog['editDate']

        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongores=mongoLog, elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
示例#14
0
    def test_01(self):
        """推送正式设备数据"""
        data = unloading.JSONV2_Request("unloading")
        longitude = data['longitude']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")

        elkLog = elkSearch.elkParams(longitude, self.method)

        mongoLog = self.mongo.getbyParams(longitude,
                                          "unloading_platform_device_params")
        del mongoLog['editDate']

        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongores=mongoLog, elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
    def test_03(self):
        """推送测试设备数据-推送未定义字段"""
        # mongo = pyMongodb.pymongo('172.16.0.137', 20200)
        data = heart_data.JSONV2_Request("tower")
        deviceTime = data['deviceTime']
        data['pm110'] = 100
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkDevice(deviceTime)

        # mongoLog = self.mongo.getbyDeviceTime(deviceTime, "tower_crane_heartbeat")

        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
    def test_03(self):
        """推送正式设备数据-推送未定义字段"""
        data = tower_params.JSONV2_Request("tower")
        longitude = data['longitude']
        data['pm110'] = 100
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkParams(longitude, self.method)
        self.assertEqual(1, elkLog['uploadStatus'])
        mongoLog = self.mongo.getbyParams(longitude,
                                          "tower_crane_device_params")
        del mongoLog['editDate']
        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongores=mongoLog, elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
示例#17
0
    def test_03(self):
        """推送测试设备数据-无temp字段"""
        data = sewage_data.JSONV2_Request(self.NdeviceId)
        deviceTime = data['deviceTime']
        del data["temp"]
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        self.assertEqual("temp字段不能为空", elkLog['exceptionContent'])

        # mongoLog = self.mongo.getbyDeviceTime(deviceTime, "sewage_outfall")

        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
示例#18
0
    def test_04(self):
        "推送测试设备数据-无stress字段"
        data = concrete.JSONV2_Request("concrete")
        deviceTime = data['deviceTime']
        del data['stress']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        self.assertEqual("stress字段不能为空", elkLog['exceptionContent'])

        # mongoLog = self.mongo.getbyDeviceTime(deviceTime, "env_monitor")

        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
    def test_01(self):
        """推送正式设备数据"""
        data = unloading.JSONV2_Request(self.NdeviceId)
        deviceId = data['deviceId']
        deviceTime = data['deviceTime']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        # print(elkLog)
        self.assertEqual(deviceId, elkLog['deviceCode'])

        mongoLog = self.mongo.getbyDeviceTime(deviceTime, "unloading_platform")

        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongores=mongoLog, elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
    def test_03(self):
        """推送测试设备数据-无warning字段"""
        data = intrusion_detector.JSONV2_Request(deviceID=self.NdeviceId)
        deviceTime = data['deviceTime']
        del data["warning"]
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        self.assertEqual("warning字段不能为空", elkLog['exceptionContent'])

        # mongoLog = self.mongo.getbyDeviceTime(deviceTime, "construction_elevator")

        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
示例#21
0
    def test_02(self):
        """推送测试设备数据-推送未定义字段"""
        # mongo = pyMongodb.pymongo('172.16.0.137', 20200)
        data = hang_params_data.JSONV2_Request("hanging")
        longitude = data['longitude']
        data['pm110'] = 100
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkParams(longitude, self.method)

        # mongoLog = self.mongo.getbyDeviceTime(longitude, "env_monitor")

        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
示例#22
0
    def test_env_04(self):
        """推送测试设备数据-无pm10字段"""
        # mongo = pyMongodb.pymongo('172.16.0.137', 20200)
        data = env_data.JSONV2_Request("OpenAPI-Test")
        deviceTime = data['deviceTime']
        del data['pm10']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        self.assertEqual("pm10字段不能为空", elkLog['exceptionContent'])

        # mongoLog = self.mongo.getbyDeviceTime(deviceTime, "env_monitor")

        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
示例#23
0
    def test_05(self):
        """推送测试设备数据-无currentRatedLoad字段"""
        # mongo = pyMongodb.pymongo('172.16.0.137', 20200)
        data = cons_elevator.JSONV2_Request("construction")
        deviceTime = data['deviceTime']
        del data['currentRatedLoad']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        self.assertEqual("currentRatedLoad字段不能为空", elkLog['exceptionContent'])

        # mongoLog = self.mongo.getbyDeviceTime(deviceTime, "construction_elevator")

        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
示例#24
0
    def test_08(self):
        "推送测试设备数据-无groupName字段"
        # mongo = pyMongodb.pymongo('172.16.0.137', 20200)
        data = rain_data.JSONV2_Request(self.NdeviceId)
        deviceTime = data['deviceTime']
        del data['groupList'][0]['groupName']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        self.assertEqual("groupName字段不能为空", elkLog['exceptionContent'])

        # mongoLog = self.mongo.getbyDeviceTime(deviceTime, "rain_recovery")

        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
示例#25
0
    def test_Device_smoke(self):
        """硬件冒烟"""
        mongo = pyMongodb.pymongo('172.16.0.137', 20200)
        deviceTime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        data = {
            "temp": -4.0,
            "pm10": 43.9,
            "humid": 3.6,
            "deviceTime": deviceTime,
            "deviceId": "OPENAPI",
            "atoms": 1.6,
            "tsp": 3915.4,
            "pm25": 76.1,
            "noise": 33.9,
            "windSpeed": 12.2,
            "windDirect": 79.6
        }

        data = json.dumps(data)
        print(json.dumps(json.loads(data), indent=2, ensure_ascii=False))
        res = OpenAPI(method='upload.envMonitorLiveData', data=data)
        print(json.dumps(res.json(), indent=2, ensure_ascii=False))

        time.sleep(3.5)
        elkLog = elkSearch.elkDevice(deviceTime)
        # print("\nelkLog:")
        # print(json.dumps(elkLog))

        time.sleep(1.5)
        mongoLog = mongo.getbyDeviceTime(deviceTime, "env_monitor")
        # print("\nmongoLog:")
        # print(mongoLog)

        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongoLog, elkLog, json.loads(data))
        print(Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match)
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
示例#26
0
    def test_env_05(self):
        """推送测试设备数据-推送未定义字段"""
        # mongo = pyMongodb.pymongo('172.16.0.137', 20200)
        data = env_data.JSONV2_Request("OpenAPI-Test")
        deviceTime = data['deviceTime']
        data['pm110'] = 100
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkDevice(deviceTime, self.method)

        # mongoLog = self.mongo.getbyDeviceTime(deviceTime, "env_monitor")
        # if 'aqiValue' in mongoLog:
        # del mongoLog['aqiValue']

        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])
示例#27
0
    def test_01(self):
        """推送测试设备数据"""
        # mongo = pyMongodb.pymongo('172.16.0.137', 20200)
        data = hang_params_data.JSONV2_Request("hanging")
        longitude = data['longitude']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkParams(longitude, self.method)

        mongoLog = self.mongo.getbyParams(longitude,
                                          "hanging_basket_device_params")
        if 'editDate' in mongoLog:
            del mongoLog['editDate']

        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongores=mongoLog, elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")
        self.assertEqual(0, res.json()['code'])