Exemplo n.º 1
0
    def is_depend(self,
                  body,
                  url,
                  server,
                  de_key,
                  de_url,
                  de_body,
                  de_server,
                  ass,
                  interval=5):
        res1 = demo().request(body=body, url=url, server=server)
        print(res1)
        dict_de_body = eval(de_body)
        dict_res1 = eval(res1)
        dict_de_body[de_key] = dict_res1[de_key]  ##拼接查询接口的新body
        new_de_body2 = str(dict_de_body)
        fi_body = new_de_body2  ##  body  加""
        time.sleep(2)
        count = 0

        while count < 10:
            check_res = demo().request(body=fi_body,
                                       url=de_url,
                                       server=de_server)
            count += 1
            print(count)
            time.sleep(interval)
            if ass in check_res:
                print(ass, check_res, "成功:%sin%s" % (ass, check_res))
                return True
        else:
            print((ass, check_res, "失败原因:%s!in%s" % (ass, check_res)))
            raise AssertionError
    def test_case_1(self):
        '''账户余额查询'''
        if self.is_de is 'N':
            res = demo().request(body=self.body,
                                 url=self.url,
                                 server=self.server)
            if self.ass in res:  ###############断言
                print((self.ass, res, "成功:%sin%s" % (self.ass, res)))
                return True
            else:
                print((self.ass, res, "失败原因:%s!in%s" % (self.ass, res)))
                raise AssertionError

        if self.is_de == 'Y':
            is_de().is_depend(body=self.body,
                              url=self.url,
                              server=self.server,
                              de_key=self.de_key,
                              de_url=self.de_url,
                              de_body=self.de_body,
                              de_server=self.de_server,
                              ass=self.ass)

        else:
            print('Wrong')