Ejemplo n.º 1
0
    def test_18(self):
        "推送正式项目数据- 根据sourceId更新软件数据"
        pdata = process_task.JSONV2_Request(self.ProjectSysNo)
        sourceId = pdata['sourceId']
        pdata = json.dumps(pdata)
        pres = OpenAPI(method=self.method, data=pdata)
        self.assertEqual(0, pres.json()['code'], "Send OpenAPI Fail")

        fake = Faker('zh_CN')
        data = json.loads(pdata)
        # 转换UTC时间为本地时间
        for k, v in data.items():
            if isinstance(k, datetime):
                data[k] = data[k].replace(
                    tzinfo=pytz.utc).astimezone(local_timezone)
        data['completionRate'] = data['completionRate'] + 1
        data['actualEndTime'] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        data['partitioningName'] = fake.text(max(range(10, 500)))

        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'], elkLog)
Ejemplo n.º 2
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'])
Ejemplo n.º 3
0
    def test_02(self):
        "推送测试项目数据"
        data = process_task.JSONV2_Request(self.ProjectSysNo)
        sourceId = data['sourceId']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkSoftware(sourceId, self.method)
        self.assertEqual(self.ProjectSysNo, elkLog['projectSysNo'])
        self.assertEqual(0, res.json()['code'])
Ejemplo n.º 4
0
    def test_12(self):
        "推送正式项目数据- 项目未添加应用"
        data = process_task.JSONV2_Request(10)
        sourceId = data['sourceId']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkSoftware(sourceId, self.method)
        self.assertEqual(0, res.json()['code'])
        self.assertEqual("不能使用该项目", elkLog['exceptionContent'])
Ejemplo n.º 5
0
    def test_05(self):
        "推送正式项目数据- 无name"
        data = process_task.JSONV2_Request(self.ProjectSysNo)
        sourceId = data['sourceId']
        del data['name']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkSoftware(sourceId, self.method)
        self.assertEqual(0, res.json()['code'])
        self.assertEqual(2, elkLog['uploadStatus'], elkLog)
        self.assertEqual("name字段不能为空", elkLog['exceptionContent'], sourceId)
Ejemplo n.º 6
0
    def test_22(self):
        """推送正式设备数据-json 格式不正确"""
        data = process_task.JSONV2_Request(self.ProjectSysNo)
        sourceId = data['sourceId']
        data = json.dumps(data)
        data = data[:-1]
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'])

        elkLog = elkSearch.elkSoftware(sourceId, self.method)
        self.assertEqual("json格式不正确", elkLog['exceptionContent'], elkLog)
        self.assertEqual(2, elkLog['uploadStatus'])
Ejemplo n.º 7
0
    def test_10(self):
        "推送正式项目数据- 字段类型不一致 datetime->string"
        data = process_task.JSONV2_Request(self.ProjectSysNo)
        sourceId = data['sourceId']
        data['actualStartTime'] = 'actualStartTime'
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkSoftware(sourceId, self.method)
        self.assertEqual(0, res.json()['code'])
        self.assertEqual(2, elkLog['uploadStatus'], elkLog)
        self.assertEqual("actualStartTime字段类型不正确", elkLog['exceptionContent'],
                         elkLog)