Пример #1
0
 def setUp(self):
     self.logger = Log()
     self.config = ReadYaml(FileUtil.getProjectObsPath() + '/config/config.yaml').getValue()
     self.logger.info('########################### TestProjectUpdate START ###########################')
     self.projectName = '测试项目'
     self.startTime = time.strftime('%Y-%M-%d')
     self.endTime = time.strftime('%Y-%m-%d', time.localtime(time.time() + 86400))
     self.customerName = '测试之家'
     self.customerCode = 'CSZJ201710200001'
     self.phone = DataUtil().createmoble()
     self.projectId = CreateProject().create_project(self.projectName,self.startTime,self.endTime,self.customerName,
                                                     self.customerCode,self.phone,'黄经理')
 def project_one_choice(projectName, startTime, endTime, customerName,
                        customerCode, phone, customerDeveloper):
     project_list = ProjectSelect().project_select(
         rows='1000', projectStatus='1').json()['content']['dataList']
     if project_list != []:
         L = []
         for project in project_list:
             if project['projectName'] == projectName:
                 L.append(project['projectName'])
                 return project
         if len(L) == 0:
             projectId = CreateProject().create_project(
                 projectName, startTime, endTime, customerName,
                 customerCode, phone, customerDeveloper)
             project = {'projectId': projectId, 'projectName': projectName}
             return project
     else:
         projectId = CreateProject().create_project(projectName, startTime,
                                                    endTime, customerName,
                                                    customerCode, phone,
                                                    customerDeveloper)
         project = {'projectId': projectId, 'projectName': projectName}
         return project
Пример #3
0
 def project_choice(projectName='德邦物流', customerName='德邦集团', customerCode='DB20171101100',
                    phone='13077327043', customerDeveloper='张经理'):
     project_list = ProjectSelect().project_select(rows='1000', projectStatus='1').json()['content']['dataList']
     if project_list == []:
         startTime = time.strftime('%Y-%m-%d')
         endTime = time.strftime('%Y-%m-%d', time.localtime(time.time() + 2592000))
         projectId = CreateProject().create_project(projectName, startTime, endTime, customerName, customerCode,
                                                    phone, customerDeveloper)
         project = {'projectId': projectId, 'projectName': projectName}
         CreateLine.my_print('新建的项目是: {0}'.format(project))
     else:
         project = random.sample(project_list, 1)[0]
         CreateLine.my_print('选择的项目是: {0}'.format(project))
     return project
 def setUp(self):
     self.logger = Log()
     self.logger.info(
         '########################### TestProjectGet START ###########################'
     )
     self.projectName = '测试项目'
     self.beginTime = time.strftime('%Y-%m-%d')
     self.endTime = time.strftime('%Y-%m-%d',
                                  time.localtime(time.time() + 86400))
     self.customerName = '测试之家'
     self.customerCode = 'CSZJ201710200001'
     self.phone = DataUtil().createmoble()
     self.projectId = CreateProject().create_project(
         self.projectName, self.beginTime, self.endTime, self.customerName,
         self.customerCode, self.phone, '黄经理')
 def test_project_create_success(self):
     '''新增项目'''
     CreateProject().create_project(self.projectName, self.startTime,
                                    self.endTime, self.customerName,
                                    self.customerCode, self.phone, '黄经理')
     project_list = ProjectSelect().project_select(
         projectName=self.projectName,
         projectStatus='0').json()['content']['dataList']
     if project_list != []:
         L = []
         for project in project_list:
             L.append(str(project['projectName']))
         self.assertIn(self.projectName, L, 'project created fail!')
     else:
         self.logger.error(
             'Please check the results of the project for empty')
Пример #6
0
    def create_user(self,roleName,menuJson,name,userName,mobile,isLoginApp,carType):
        '''新增账号'''
        try:
            #选择角色
            role_list = RoleCompanyGet().role_company_get().json()['content']
            if role_list == []:
                roleId = CreateRole().create_role(roleName,menuJson)
                self.logger.info('公司没有角色时新增角色,新增角色名称是:{0}'.format(roleName))
            else:
                roleId = random.choice(role_list)['roleId']
                self.logger.info('新增账号的角色ID是:{0}'.format(roleId))

            #选择项目数据权限
            projectId = CreateProject().project_data_permission_choice()

            #新增账号
            response = UserCreate().user_create(roleId,name,userName,mobile,isLoginApp,projectId,carType)
            if response.json()['code'] == 0:
                return response.json()['content'],roleId
            # 需求变动(已删除的子账号不能再新建)
            # elif response.json()['code'] == 9110028:
            #     user_list = UserSelect().user_select().json()['content']['dataList']
            #     for user in user_list:
            #         if user['userName'] == userName:
            #             UserDelete().user_delete(user['loginId'])
            #     userId = UserCreate().user_create(roleId,name,userName,mobile,isLoginApp,projectId,carType).json()['content']
            #     return userId,roleId
            # elif response.json()['code'] == 9110029:
            #     user_list = UserSelect().user_select().json()['content']['dataList']
            #     for user in user_list:
            #         if user['mobile'] == mobile:
            #             UserDelete().user_delete(user['loginId'])
            #     userId = UserCreate().user_create(roleId,name,userName,mobile,isLoginApp,projectId,carType).json()['content']
            #     return userId,roleId
            elif response.json()['code'] == 9110028:
                sql = 'DELETE FROM YD_APP_APPROVAL_USER WHERE userName = \'{0}\' and partnerNo = \'{1}\''.format(
                    userName,self.config['partnerNo'])
                self.DBUtil = DBUtil(host=self.config['db_host'], port=self.config['db_port'],
                                     user=self.config['db_user'], passwd=self.config['db_passwd'],
                                     dbname=self.config['db_dbname'], charset=self.config['db_charset'])
                print(sql)
                self.DBUtil.execute_sql(sql)
                userId = UserCreate().user_create(roleId, name, userName, mobile, isLoginApp, projectId, carType
                                                  ).json()[ 'content']
                return userId, roleId
            elif response.json()['code'] == 9110029:
                sql = 'DELETE FROM YD_APP_APPROVAL_USER WHERE mobile = \'{0}\' and partnerNo = \'{1}\''.format(mobile,
                                                                                             self.config['partnerNo'])
                self.DBUtil = DBUtil(host=self.config['db_host'], port=self.config['db_port'],
                                     user=self.config['db_user'], passwd=self.config['db_passwd'],
                                     dbname=self.config['db_dbname'], charset=self.config['db_charset'])
                print(sql)
                self.DBUtil.execute_sql(sql)
                print(sql)
                userId = UserCreate().user_create(roleId, name, userName, mobile, isLoginApp, projectId, carType
                                                  ).json()['content']
                return userId, roleId
            else:
                self.logger.info('新增账号返回错误:{0}'.format(response.json()))
                return None,None
        except Exception as e:
            self.logger.error('新增账号发生异常:{0}'.format(e))
            return None