예제 #1
0
 def test_02(self):
     """推送正式设备数据-无deviceTime字段"""
     data = env_data.JSONV2_Request(self.NdeviceId)
     del data['deviceTime']
     data = json.dumps(data)
     res = OpenAPI(method=self.method, data=data)
     self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
예제 #2
0
    def test_09(self):
        "推送正式设备数据-设备未激活"
        # mongo = pyMongodb.pymongo('172.16.0.137', 20200)
        data = env_data.JSONV2_Request("OpenAPI-NotActive")
        deviceTime = data['deviceTime']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'])

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        self.assertEqual("设备未激活", elkLog['exceptionContent'])
        self.assertEqual(2, elkLog['uploadStatus'])
예제 #3
0
    def test_22(self):
        """推送正式设备数据-json 格式不正确"""
        data = env_data.JSONV2_Request(self.NdeviceId)
        deviceTime = data['deviceTime']
        data = json.dumps(data)
        data = data[:-1]
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'])

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        self.assertEqual("json格式不正确", elkLog['exceptionContent'], elkLog)
        self.assertEqual(2, elkLog['uploadStatus'])
예제 #4
0
    def test_06(self):
        """推送正式设备数据-字段类型不正确int->string"""
        data = env_data.JSONV2_Request(self.NdeviceId)
        deviceTime = data['deviceTime']
        data['pm10'] = "string"
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'])

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        self.assertEqual("pm10字段类型不正确", elkLog['exceptionContent'], elkLog)
        self.assertEqual(2, elkLog['uploadStatus'])
예제 #5
0
    def test_env_03(self):
        """推送测试设备数据-无pm25字段"""
        # mongo = pyMongodb.pymongo('172.16.0.137', 20200)
        data = env_data.JSONV2_Request("OpenAPI-Test")
        deviceTime = data['deviceTime']
        del data['pm25']
        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("pm25字段不能为空", elkLog['exceptionContent'])
예제 #6
0
    def test_env_02(self):
        """推送测试设备数据-无deviceTime字段"""
        # mongo = pyMongodb.pymongo('172.16.0.137', 20200)
        data = env_data.JSONV2_Request("OpenAPI-Test")
        del data['deviceTime']
        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")
예제 #7
0
    def test_04(self):
        """推送正式设备数据-无pm10字段"""
        data = env_data.JSONV2_Request(self.NdeviceId)
        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'], elkLog)

        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'])
예제 #8
0
    def test_05(self):
        """推送正式设备数据-推送未定义字段"""
        data = env_data.JSONV2_Request(self.NdeviceId)
        deviceTime = data['deviceTime']
        data['pm110'] = 100
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkDevice(deviceTime, self.method)
        self.assertEqual(1, elkLog['uploadStatus'])
        mongoLog = self.mongo.getbyDeviceTime(deviceTime, "env_monitor")
        del mongoLog['aqiValue']
        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'])
예제 #9
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'])
예제 #10
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'])