Beispiel #1
0
 def __init__(self, charset="utf-8"):
     self.host = Config().db
     self.user = Config().db_user
     self.password = Config().db_password
     self.port = int(Config().db_port)
     self.database = Config().db_name
     self.charset = charset
Beispiel #2
0
 def __init__(self, zby_user=None, zby_pwd=None):
     self.S = requests.Session()
     self.host = Config().zby_host
     if zby_user == None and zby_pwd == None:
         self.user = Config().getValue("zby_user")
         self.password = Config().getValue("zby_pwd")
     else:
         self.user = zby_user
         self.password = zby_pwd
Beispiel #3
0
 def __init__(self, user=None, pwd=None):
     self.S = requests.Session()
     self.host = Config().roadSide_host
     if user == None and pwd == None:
         self.user = Config().getValue("roadSide_user")
         self.password = Config().getValue("roadSide_pwd")
     else:
         self.user = user
         self.password = pwd
Beispiel #4
0
 def __init__(self, user=None, pwd=None):
     self.conf = Config()
     self.host = self.conf.host
     self.Seesion = requests.Session()
     if user == None and pwd == None:
         self.user = Config().getValue("user")
         self.password = Config().getValue("password")
     else:
         self.user = user
         self.password = pwd
Beispiel #5
0
 def __init__(self):
     #super(Config, self).__init__()
     Config.__init__(self)
     time = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
     self.save_weight_dir = os.path.join(Config.get_save_weight_dir(self),time)
     if not os.path.exists(self.save_weight_dir):
         os.mkdir(self.save_weight_dir)
     self.result_path = os.path.join(Config.get_result_path(self),time)
     if not os.path.exists(self.result_path):
         os.mkdir(self.result_path)
     self.batch_size = 256
Beispiel #6
0
    def test_payleave_account(self):
        """
		用例描述:付费离场(余额支付)
		"""
        A = ApiCase(carNum=Config().common_carNum)
        A.car_run_inside()
        P = ChargesPage()
        P.pay_charges(Config().common_carNum)
        result = P.submit_pay()
        assert result == True
        A.car_run_outside()
Beispiel #7
0
    def test_payleave_weixin(self):
        """
		用例描述:付费离场(微信支付)
		"""
        A = ApiCase(carNum=Config().common_carNum)
        A.car_run_inside()
        self.P.pay_charges(Config().common_carNum)
        result = self.P.submit_pay(type="微信")
        assert result == True
        A.pay_charge()
        A.car_run_outside()
Beispiel #8
0
    def test_lock_and_unlock(self):
        """
		用例描述:车辆锁定-解锁
		"""
        A = ApiCase(carNum=Config().common_carNum)
        A.car_run_inside()
        P = ChargesPage()
        result = P.lock_car(Config().common_carNum)
        assert result == True
        P.unlock_car(Config().common_carNum)
        A.pay_charge()
        A.car_run_outside()
        P.web_refresh()
Beispiel #9
0
 def simulationTestAllThread(self):
     self.lock = Lock()
     
     import psyco
     psyco.full()
     
     settingsToRun = {}
     settings = dir(Global)
     settingsToRunLen = []
     for setting in settings:
         if setting.endswith("TESTSET"):
             a = getattr(Global, setting)
             settingName = setting.split("TESTSET")[0]
             settingsToRun[settingName] = a
             settingsToRunLen.append(len(a))
     #settingsToRun contains all set data to run
     if len(settingsToRunLen) < 1:
         settingsCount = 1
     else:
         settingsCount = reduce(lambda x,y: x*y, settingsToRunLen)
     self.testToRunCount = settingsCount * len(Config.GetConfigs()) * len(Global.RandomSeeds)
     self.currentTestIndex = 0
     self.testRunStarted = time.time()
     
     self.simulationTestAllRecursive(settingsToRun)
Beispiel #10
0
    def test_001(self):
        '''
        参数信息
        :return:
        '''

        #实例化配置文件读取类、断言类、测试数据类
        config = Config()
        data = Test()
        _assert = Assert.Assert()
        request = Requests.Request()
        #读取host,读取url,data,headers
        host = config.activity_front_host
        urls = data.url
        params = data.data

        allure.attach('用例参数:{0}'.format(params))
        with allure.step("测试步骤调用"):
            allure.attach('失败', '期望结果')

        api_url = host + urls[0]
        response = request.post(url=api_url, data=params[0][0])
        setattr(Reflex.Reflex_api, 'num', 1000)
        print(response['response_code'])
        assert _assert.assert_status(response['response_code'], 200)
Beispiel #11
0
class TestBasic(object):
    log = Log.MyLog()
    data = Basic()
    case_data = data.case_data
    request = Request.Request()
    test = Assert.Assertions()
    config = Config()
    noti = notify()

    # ids = [
    #     "测试:{}".
    #         format(case['test_name']) for case in case_data
    # ]
    @allure.feature('Home')
    @allure.severity('blocker')
    @allure.story('Basic')
    @allure.issue('https://baidu.com')
    @allure.testcase('https://baidu.com')
    @pytest.mark.flaky(reruns=3)
    # @pytest.mark.parametrize('case', case_data, ids=ids)
    @pytest.mark.parametrize('case', case_data)
    def test_login(self,case):
        """
        小程序登录
        """
        self.log.info('demo, utl={}, data={}, header={}'.format(case['url'], case['data'], case['header']))
        if case['method'] == 'post_request_urlencoded':
            result = self.request.post_request_urlencoded(case['url'], case['data'], case['header'])
            # 写入配置文件
            self.config.set_conf('parameter', 'token', result['data']['token'])
            assert self.test.assert_text(result['status'], 0)
            self.log.info('配置文件中token ={}'.format(self.config.get_conf('parameter', 'token')))
        allure.attach.file(BASE_PATH+'/Log/log.log', '附件内容是: ' + '老王调试日志', '我是附件名', allure.attachment_type.TEXT)
        Consts.RESULT_LIST.append('True')
Beispiel #12
0
 def runOneTestSuite(self, settingsText):
     nowTime = time.strftime("%Y-%m-%d--%H-%M-%S")
     configsToTest = Config.GetConfigs()
     randomSeeds = Global.RandomSeeds
     
     savePath = "../../tests/" + nowTime + "/"
     os.makedirs(savePath)
             
     if Global.SafeMode:
         for randomSeed in randomSeeds:
             for configName in configsToTest:
                 try:
                     self.runOneSimulation(savePath, configName, randomSeed)
                 except:
                     e = sys.exc_info()[1]
                     if type(e) == TclError: raise SystemExit
                     print e
                     time.sleep(1)
     else:
         for randomSeed in randomSeeds:
             for configName in configsToTest:
                 self.runOneSimulation(savePath, configName, randomSeed)
     
     copyfile("Enviroment/Global.py", savePath + "Global.py")
     copyfile("plotter.py", "../../tests/plotter.py")
     copyfile("../statter.exe", "../../tests/statter.exe")
     copyfile("../LumenWorks.Framework.IO.dll", "../../tests/LumenWorks.Framework.IO.dll")
     f = open(savePath + "Global.py", "a")
     f.write("\n#real settings of Global.py\n")
     f.write(settingsText)
     f.close()
Beispiel #13
0
    def test_getusermenu_01(self, action):
        """
            用例描述:systemId、terminalType正常
        """
        conf = Config()
        data = GetUserMenu()
        test = Assert.Assertions()
        request = Request.Request(action)

        host = conf.host_base
        req_url = 'http://' + host
        urls = data.url
        params = data.data
        headers = data.header

        he = {
            'Content-Type': 'application/json;charset=UTF-8',
            'token': "fbe62213-d9f6-4805-b239-1c232c5f2a9f"
        }

        api_url = req_url + urls[0]
        response = request.post_request(api_url, json.dumps(he), headers[0])

        print(json.dumps(he))
        assert test.assert_code(response['body']['code'], '1003')
        # assert test.assert_body(response['body'], 'description', '密码错误')
        # assert test.assert_time(response['time_consuming'], 200)
        Consts.RESULT_LIST.append('True')
class TestProcess(object):
    config = Config()
    noti = notify()
    log = Log.MyLog()
    data = Process()
    case_data = data.case_data
    test = Assert.Assertions()
    # ids = [
    #     " 测试:{} ==>  预期结果:状态码={} ".
    #         format(case['test_name'], case['expected']) for case in case_data
    # ]
    @allure.feature('Home')
    @allure.severity('blocker')
    @allure.story('Process')
    @allure.issue(config.test04_unified_url)
    @allure.testcase(config.test04_unified_url)
    # @pytest.mark.flaky(reruns=3)
    # @pytest.mark.parametrize('case', case_data, ids=ids)
    @pytest.mark.parametrize('case', case_data)
    def test_process(self, case):
        TestProcess.test_process.__doc__ = case['test_name']
        self.log.info('demo, utl={}, data={}, header={}'.format(
            case['url'], case['data'], case['header']))
        # 判断请求方法
        result = self.noti.notify_result(case['mode'], case['url'],
                                         case['data'], case['header'])
        self.log.info('响应结果:%s' % result)
        print(result)
        parser(result, case['parser'], case['expected'])
        # self.test.assert_in_text(result,case['expected']),True)
        allure.attach.file((BASE_PATH + '/Log/log.log'), '附件内容是: ' + '老王调试日志',
                           '我是附件名', allure.attachment_type.TEXT)
        Consts.RESULT_LIST.append('True')
Beispiel #15
0
def get_Graph():
    """
    返回图
    :return: 图
    """
    from Config.Config import Config
    config = Config('neo4j').getInfo()
    return Graph(config['url2'], auth=(config['name'], config['password']))
Beispiel #16
0
    def __init__(self, Session=None):
        super(Req, self).__init__()

        self.conf = Config()
        self.host = self.conf.host
        if Session == None:
            self.Session = requests.Session()
        else:
            self.Session = Session
Beispiel #17
0
 def __init__(self, user=None, pwd=None):
     self.conf = Config()
     self.host = self.conf.weiXin_host
     self.S = requests.session()
     if user == None and pwd == None:
         self.user = self.conf.weiXin_user
         self.password = self.conf.weiXin_pwd
     else:
         self.user = user
         self.password = pwd
Beispiel #18
0
 def __init__(self, user=None, pwd=None):
     self.S = requests.Session()
     self.C = Config()
     self.host = self.C.zby_host
     if user == None and pwd == None:
         self.user = self.C.zby_user
         self.password = self.C.zby_pwd
     else:
         self.user = user
         self.password = pwd
Beispiel #19
0
    def test_setting_often_carNum(self):
        """
		用例描述:设置常用车牌
		"""
        P = ChargesPage()
        carCode = P.create_carNum()
        P.binding_carCode(carCode)
        P.set_often_carNum(carCode)
        result = P.set_often_carNum(Config().common_carNum)
        P.del_carCode(carCode)
        assert result == True
Beispiel #20
0
def action():
    # 定义环境
    env = Consts.API_ENVIRONMENT_RELEASE
    # 定义报告中environment
    conf = Config()
    host = conf.host_release
    tester = conf.tester_release
    allure.environment(environment=env)
    allure.environment(hostname=host)
    allure.environment(tester=tester)
    return env
Beispiel #21
0
    def __init__(self, carNum=None):

        self.url = Config().vems_host
        self.carNum = carNum
        self.usernameToken = self.get_center_people_token()
        self.realTimeCarSeq = ""
        self.stopTime = ""
        self.basicFee = ""
        self.taxPay = ""
        self.chargingTime = ""
        self.enterTime = time.strftime('%Y-%m-%d %H:%M:%S',
                                       time.localtime(time.time() - 1800))
Beispiel #22
0
        def clone_fn(batch_queue):
            network_config = Config(weight_decay=FLAGS.weight_decay)
            images, labels = batch_queue.dequeue()

            logits, endpoints = network_fn(images, network_config)
            # loss = tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(labels=labels, logits=logits, name='loss'))
            loss = weighted_softmax_loss(logits, labels)
            # loss = dice_loss(logits, labels)
            slim.losses.add_loss(loss)
            endpoints['images'] = images
            endpoints['labels'] = labels
            return endpoints
Beispiel #23
0
 def runOneSimulation(self, savePath, configName, randomSeed):
     savePath = savePath + str(randomSeed) + "-" + configName + "/"
     os.makedirs(savePath)
     Global.LogStart(savePath)   
     Global.Log("Starting new simulation and world for Config: " + configName)
     try:
         seed(randomSeed)
         config = Config.Get(configName)
         world = World(config)
         Global.World = world
 
         self.agent = Agent(config)
         world.SetAgent(self.agent)
         self.mapRenderer = MapRenderer(self.wxCanvas, Global.Map, self.agent, self, False)
         
         self.currentTestIndex = self.currentTestIndex + 1
         self.mapRenderer.RenderProgress(self, configName)
         self.mapRenderer.RenderProgressInTest(world.step, Global.MaxTestSteps)
         time.sleep(0.1)
         
         elayer = world.agent.intelligence.spaceMap.Layer
         while world.step < Global.MaxTestSteps:
             world.Step()
             self.mapRenderer.RenderToFile(world, savePath + "PIL" + str(world.step).zfill(6) + ".png")
             self.mapRenderer.RenderProgressInTest(world.step, Global.MaxTestSteps)
     
         world.SendAgentOut()
         while world.step < Global.MaxTestSteps + Global.MaxTestStepAfter:
             world.Step()
             self.mapRenderer.RenderToFile(world, savePath + "PIL" + str(world.step).zfill(6) + ".png")
             self.mapRenderer.RenderProgressInTest(world.step, Global.MaxTestSteps)
                 
         if Global.CalculateVisibilityHistory:
             self.mapRenderer.RenderToFile(world, savePath + "visibilityheatmap.png", ["vh"])
         self.mapRenderer.RenderToFile(world, savePath + "visibilityobjectheatmap.png", ["ovh"])
         map = Global.Map
         map.SaveHeatMap()
         self.agent.intelligence.spaceMap.Layer.SaveHeatMap()
     except:
         Global.Log("FATAL ERROR occured: ")
         ss = traceback.format_exc()
         Global.Log(ss)
         time.sleep(1)
         raise
     finally:        
         Global.Log("Stoping simulation...")
         Global.LogEnd()
         Global.Reset()
         self.agent = None
         self.mapRenderer.Clear()
         self.mapRenderer = None
Beispiel #24
0
 def __init__(self, Session=None):
     # super(Req, self).__init__()
     super().__init__()
     self.conf = Config()
     self.host = self.conf.host
     self.monitor_host = self.conf.monitor_host
     self.zby_host = self.conf.zby_host
     self.aomp_host = self.conf.aomp_host
     self.weiXin_host = self.conf.weiXin_host
     self.openYDT_host = self.conf.openYDT_host
     self.mock_host = self.conf.mock_host
     self.roadSide_host = self.conf.roadSide_host
     if Session == None:
         self.Session = requests.Session()
     else:
         self.Session = Session
Beispiel #25
0
 def __init__(self):
     self.host = Config().aomp_host
     seccodeUrl = self.host + "/getValidateCode.do"
     checkLoginUrl = self.host + "/checkLogin.do"
     headers = {
         "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
     }
     self.S = requests.Session()
     self.S.get(seccodeUrl)
     data = {
         "user": "******",
         "pwd": "123456",
         "isOnLine": "isOnLine",
         "flag": -1,
         "validateCode": 9999
     }
     result =self.S.post(checkLoginUrl, data, headers=headers)
Beispiel #26
0
 def __init__(self):
     self.host = Config().pomp_host
     seccodeUrl = self.host + "/mgr/normal/authz/seccode.do"
     verify_seccode = self.host + "/mgr/normal/authz/verify_seccode.do"
     loginURl = self.host + "/mgr/normal/ajax/login.do"
     headers = {
         "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
     }
     self.S = requests.Session()
     self.S.get(seccodeUrl)
     seccodeData = {"seccode": 9999}
     self.S.post(verify_seccode, data=seccodeData)
     data = {
         "username": "******",
         "password": "******",
         "seccode": 9999
     }
     self.S.post(loginURl, data, headers=headers)
    def test_personal_02(self, action):
        """
            用例描述:登陆状态下更新Personal个人简介
        """
        conf = Config()
        data = Personal()
        request = Request.Request(action)

        host = conf.host_debug
        req_url = 'http://' + host
        urls = data.url
        params = data.data
        headers = data.header

        api_url = req_url + urls[1]
        response = request.post_request(api_url, params[1][0], headers[1])
        assert response['code'] == 200
        Consts.RESULT_LIST.append('True')
    def test_collections_02(self, action):
        """
            用例描述:查看用户'95c34f9cc50c'的Collections
        """
        conf = Config()
        data = Collections()
        test = Assert.Assertions()
        request = Request.Request(action)

        host = conf.host_debug
        req_url = 'http://' + host
        urls = data.url
        params = data.data
        headers = data.header

        api_url = req_url + urls[1]
        response = request.post_request(api_url, params[1], headers[1])
        assert test.assert_code(response['code'], 208)
        assert test.assert_in_text(response['body'], '每日一篇技术文')
        Consts.RESULT_LIST.append('True')
    def test_collections_01(self, action):
        """
            用例描述:查看用户'da1677475c27'的Collections
        """
        conf = Config()
        data = Collections()
        test = Assert.Assertions()
        request = Request.Request(action)

        host = conf.host_debug
        req_url = 'http://' + host
        urls = data.url
        params = data.data
        headers = data.header

        api_url = req_url + urls[0]
        response = request.post_request(api_url, params[0], headers[0])
        assert test.assert_code(response['code'], 200)
        assert test.assert_in_text(response['body'], '软件测试-各种技能集合')
        Consts.RESULT_LIST.append('True')
Beispiel #30
0
    def test_basic_02(self, action):
        """
            用例描述:登陆状态下查看基础设置
        """
        conf = Config()
        data = Basic()
        test = Assert.Assertions()
        request = Request.Request(action)

        host = conf.host_debug
        req_url = 'http://' + host
        urls = data.url
        params = data.data
        headers = data.header

        api_url = req_url + urls[1]
        response = request.post_request(api_url, params[1], headers[1])

        assert test.assert_code(response['code'], 401)
        assert test.assert_text(response['text'], '{"error":"继续操作前请注册或者登录."}')
        Consts.RESULT_LIST.append('True')