Exemplo n.º 1
0
 def case_1(self, title, expected, data1, data2, dimension1):
     #按用户查看1月合同金额
     self.current_case = title
     _login = login.Login()
     _login.login(self.userinfo_super['username'],
                  self.userinfo_super['password'],
                  self.userinfo_super['role'])
     self.cookie = _login.cookie
     self.csrf = _login.csrf
     _Roles = testGetRoles.GetRole(self.cookie, self.csrf)
     list = [
         'organization_own', 'self_and_subordinate_department_own',
         'self_department_own', 'self_own'
     ]
     for i in range(4):
         _Roles.ding_set_data_authority(list[i])
         # print('==========')
         # print (expected[i])
         # print ('============')
         _result = result.result(self.cookie, self.csrf)
         Actual_result = _result.gole_quarter(data1,
                                              data2,
                                              type='contract_rank',
                                              dimension=dimension1)
         print(Actual_result)
         test_result = operator.eq(expected[i], Actual_result)
         print(test_result)
         if test_result == True:
             f = codecs.open('contract_rank_year.txt', 'a', 'utf-8')
             a = str(self.current_case + ': '
                     "is right " + str(datetime.datetime.now()))
             f.write(a + '\n')
         else:
             f = codecs.open('contract_rank_year.txt', 'a', 'utf-8')
             a = str(i) + str(self.current_case + ': '
                              "is wrong, expected_result:'\n'" +
                              str(expected[i]) + "Actual_result:'\n'" +
                              str(Actual_result) + ',' +
                              str(datetime.datetime.now()))
             f.write(a + '\n')
Exemplo n.º 2
0
 def case_2(self):
     self.current_case = 'case 2'
     # print (self.userinfo_list)
     _login = login.Login()
     _login.login(self.userinfo_super['username'],
                  self.userinfo_super['password'],
                  self.userinfo_super['role'])
     self.cookie = _login.cookie
     self.csrf = _login.csrf
     _ContractsApproval = ContractsApproval.Approvals(
         self.cookie, self.csrf)
     _ContractsApproval.close_contract_approval()
     _DeleteContracts = DeleteContract.DeleteContract(
         self.cookie, self.csrf)
     b = _DeleteContracts.get_contract_ids()
     page = b[0][0]
     print(page)
     for i in range(int(page)):
         c = _DeleteContracts.get_contract_ids()
         contracts_list = c[1]
         for contracts in contracts_list:
             _DeleteContracts.delete_contract(contracts)
 def check_data_first(self, i=0):
     current_case = self.title_list_first[i]
     _login = login.Login()
     _login.login(self.userinfo_super['username'],
                  self.userinfo_super['password'],
                  self.userinfo_super['role'])
     self.cookie = _login.cookie
     self.csrf = _login.csrf
     _result = result.result(self.cookie, self.csrf)
     # 只返回表格的排名
     Actual_result = _result.sales_rank(
         tpye="product_category_count",
         scope_unit=self.date_list_first[i][0])
     # print('========')
     # print(Actual_result)
     # print('===========')
     # 返回中间的统计值,表格的排名
     Expected_result_all = _result.count_get_user(self.month_list_first[i],
                                                  s=4)
     Expected_result = Expected_result_all[1]
     s = len(Actual_result)
     print(s)
     for i in range(s):
         test_result = operator.eq(Expected_result[i], Actual_result[i])
         print(test_result)
         if test_result == True:
             f = codecs.open('product_category_count.txt', 'a', 'utf-8')
             a = str(
                 str(current_case) + '工作台对比' + ': '
                 "is right " + str(datetime.datetime.now()))
             f.write(a + '\n')
         else:
             f = codecs.open('product_category_count.txt', 'a', 'utf-8')
             a = str(
                 str(current_case) + '工作台对比' + ': '
                 "is wrong, expected_result:'\n'" +
                 str(Expected_result[i]) + "Actual_result:'\n'" +
                 str(Actual_result[i]) + ',' + str(datetime.datetime.now()))
             f.write(a + '\n')
Exemplo n.º 4
0
    def approve_verify(self):
        self.current_case = 'case 1'
        _login = login.Login()
        _login.login(self.userinfo_super['username'], self.userinfo_super['password'], self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _CustomersApproval = CustomersApproval.ApprovalSettings(self.cookie, self.csrf)
        _CustomersApproval.open_approval()
        # a =0
        customer_id = ''
        dict = {}
        list = []
        for userinfo in self.userinfo_list:
            print(userinfo['username'])
            _login.login(userinfo['username'], userinfo['password'], userinfo['role'])
            self.cookie = _login.cookie
            self.csrf = _login.csrf
            _AddCustomer = AddCustomer.AddCustomer(self.cookie, self.csrf)
            # 8个用户新增一条关闭审批的客户
            ##添加
            customer_id = _AddCustomer.add_customers(approve_status='applying', DepartmentId=0)
            _CustomersApproval.approve_verify(customer_id)
            dict.update({userinfo['username']: customer_id})
            list.append(customer_id)
            print(list)
        a = list
        # a = [1233194, 1233195, 1233196, 1233197, 1233198, 1233199, 1233200, 1233201]

        b = 1
        for userinfo in self.userinfo_list:
            print(userinfo['username'])
            _login.login(userinfo['username'], userinfo['password'], userinfo['role'])
            self.cookie = _login.cookie
            self.csrf = _login.csrf
            _UpdateCustomer = UpdateCustomer.UpdateCustomer(self.cookie, self.csrf)
            for i in range(b):
                for j in range(6):
                    _UpdateCustomer.add_customer_revisit_log(a[b - 1 - i], date_list=self.date_list[j],data='审批通过')
            b = b + 1
Exemplo n.º 5
0
    def case_test(self):
        os.remove('product_count_month.txt')
        _login = login.Login()
        print(self.userinfo_super['username'])
        _login.login(self.userinfo_super['username'],
                     self.userinfo_super['password'],
                     self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        # 1月----
        _result_amount.case_1(title=_result_amount.title1,
                              expected=_result_amount.expected1,
                              data1=_result_amount.date_list[1][0],
                              data2=_result_amount.date_list[1][1],
                              dimension1=_result_amount.dimension1)

        # # 3月
        _result_amount.case_1(title=_result_amount.title2,
                              expected=_result_amount.expected2,
                              data1=_result_amount.date_list[2][0],
                              data2=_result_amount.date_list[2][1],
                              dimension1=_result_amount.dimension1)
        # #
        # # # 上季度
        # # _result_amount.case_1(title=_result_amount.title3, expected=_result_amount.expected3,
        # #                       data1=_result_amount.date_list[3][0], data2=_result_amount.date_list[3][1],
        # #                       dimension1=_result_amount.dimension1)
        # #
        # # #1 2 3
        _result_amount.case_1(title=_result_amount.title4,
                              expected=_result_amount.expected4,
                              data1=_result_amount.date_list[4][0],
                              data2=_result_amount.date_list[4][1],
                              dimension1=_result_amount.dimension1)
        # #
        # # # 4 5 6
        _result_amount.case_1(title=_result_amount.title5,
                              expected=_result_amount.expected5,
                              data1=_result_amount.date_list[5][0],
                              data2=_result_amount.date_list[5][1],
                              dimension1=_result_amount.dimension1)
        # # #
        #
        # # # #本年
        _result_amount.case_1(title=_result_amount.title6,
                              expected=_result_amount.expected6,
                              data1=_result_amount.date_list[6][0],
                              data2=_result_amount.date_list[6][1],
                              dimension1=_result_amount.dimension1)
        # # #
        # # #上半年
        _result_amount.case_1(title=_result_amount.title7,
                              expected=_result_amount.expected7,
                              data1=_result_amount.date_list[7][0],
                              data2=_result_amount.date_list[7][1],
                              dimension1=_result_amount.dimension1)
        # #
        # # # #下半年
        _result_amount.case_1(title=_result_amount.title8,
                              expected=_result_amount.expected8,
                              data1=_result_amount.date_list[8][0],
                              data2=_result_amount.date_list[8][1],
                              dimension1=_result_amount.dimension1)

        # # # 2019-04-01--2019-08-31
        _result_amount.case_1(title=_result_amount.title9,
                              expected=_result_amount.expected9,
                              data1=_result_amount.date_list[9][0],
                              data2=_result_amount.date_list[9][1],
                              dimension1=_result_amount.dimension1)
        # # # # #
        # # # #7 8 9
        _result_amount.case_1(title=_result_amount.title10,
                              expected=_result_amount.expected10,
                              data1=_result_amount.date_list[10][0],
                              data2=_result_amount.date_list[10][1],
                              dimension1=_result_amount.dimension1)
        # # # # #
        # # # #10 11 12
        _result_amount.case_1(title=_result_amount.title11,
                              expected=_result_amount.expected11,
                              data1=_result_amount.date_list[11][0],
                              data2=_result_amount.date_list[11][1],
                              dimension1=_result_amount.dimension1)
Exemplo n.º 6
0
    def check_data_first(self,
                         i=0,
                         _users=['设计部-用户1', '销售部-用户5', '同部门下属-用户7']):
        current_case = self.title_list_first[i]
        time.sleep(1)
        _login = login.Login()
        _login.login(self.userinfo_super['username'],
                     self.userinfo_super['password'],
                     self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _Roles = testGetRoles.GetRole(self.cookie, self.csrf)
        for m in range(len(self.field_permission_grant_scope)):
            ### 设置用户的角色必须是普通管理员的角色
            _Roles.ding_set_data_authority(
                self.field_permission_grant_scope[m])
            print(self.field_permission_grant_scope[m])

            _login = login.Login()
            _login.login(self.userinfo_['username'],
                         self.userinfo_['password'], self.userinfo_['role'])
            self.cookie = _login.cookie
            self.csrf = _login.csrf

            _result = result.result(self.cookie, self.csrf)
            Actual_result = _result.sales_rank_completion(
                type="contract_money", scope_unit=self.date_list_first[i][0])
            Actual_result[0]['month'] = self.title_list_first[i][0]
            Actual_result_list = []
            Actual_result_month = []
            Actual_result_month.append(Actual_result[0]['month'])
            Actual_result_new = {
                'month': Actual_result_month,
                'amount': Actual_result[0]['count'],
                'goal_data': Actual_result[0]['goal_data'],
                'percentage_data': Actual_result[0]['percentage_data']
            }
            Actual_result_list.append(Actual_result_new)
            print(Actual_result_list)

            Expected_result_all = _result.gongzuotai_contract_amount_get_completion(
                _months=self.month_list_first[i],
                _users=_users,
                _month_view=self._month_view_first[i])
            print(Expected_result_all)

            s = len(Expected_result_all)
            for i in range(s):
                test_result = operator.eq(Actual_result_list[i],
                                          Expected_result_all[i])
                print(test_result)
                if test_result == True:
                    f = codecs.open('contract_number.txt', 'a', 'utf-8')
                    a = str(
                        str(current_case) + '工作台对比' + ': '
                        "is right " + str(datetime.datetime.now()))
                    f.write(a + '\n')
                else:
                    f = codecs.open('contract_number.txt', 'a', 'utf-8')
                    a = str(
                        str(current_case) + '工作台对比' + ': '
                        "is wrong, expected_result:'\n'" +
                        str(Expected_result_all[i]) + "Actual_result:'\n'" +
                        str(Actual_result_list[i]) + ',' +
                        str(datetime.datetime.now()))
                    f.write(a + '\n')
Exemplo n.º 7
0
    def case_1(self):
        self.current_case = 'case 1'
        _login = login.Login()
        _login.login(self.userinfo_super['username'],
                     self.userinfo_super['password'],
                     self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _ContractsApproval = ContractsApproval.Approvals(
            self.cookie, self.csrf)
        _ContractsApproval.close_contract_approval()
        a = 0
        for userinfo in self.userinfo_list:
            print(userinfo['username'])
            _login.login(userinfo['username'], userinfo['password'],
                         userinfo['role'])
            self.cookie = _login.cookie
            self.csrf = _login.csrf
            _AddContract = AddContract.AddContract(self.cookie, self.csrf)
            _ContractsApproval = ContractsApproval.Approvals(
                self.cookie, self.csrf)
            _DeleteContracts = DeleteContract.DeleteContract(
                self.cookie, self.csrf)
            # contracts_list =_DeleteContracts.get_contract_ids()
            # print (contracts_list)
            a = a + 1
            for i in range(6):
                if userinfo['username'] == '13799999999' and i >= 3:
                    # print(i)
                    # print(a)
                    #添加合同
                    _AddContract.add_contracts(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1),
                        DepartmentId=1)

                    _AddContract.add_contracts(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][1] *
                        (i + 1),
                        DepartmentId=1)

                    #添加草稿
                    _AddContract.add_contracts(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1),
                        DepartmentId=1,
                        approve_status='draft')
                    _AddContract.add_contracts(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][1] *
                        (i + 1),
                        DepartmentId=1,
                        approve_status='draft')

                else:
                    # print(i)
                    # print(a)
                    # 添加合同
                    _AddContract.add_contracts(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1))
                    _AddContract.add_contracts(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][1] *
                        (i + 1))
                    # 添加草稿
                    _AddContract.add_contracts(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1),
                        approve_status='draft')
                    _AddContract.add_contracts(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][1] *
                        (i + 1),
                        approve_status='draft')

        _login.login(self.userinfo_super['username'],
                     self.userinfo_super['password'],
                     self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _ContractsApproval = ContractsApproval.Approvals(
            self.cookie, self.csrf)
        _ContractsApproval.open_contract_approval()
        a = 0
        for userinfo in self.userinfo_list:
            _login.login(userinfo['username'], userinfo['password'],
                         userinfo['role'])
            print(userinfo['username'])
            self.cookie = _login.cookie
            self.csrf = _login.csrf
            _AddContract = AddContract.AddContract(self.cookie, self.csrf)
            _ContractsApproval = ContractsApproval.Approvals(
                self.cookie, self.csrf)
            a = a + 1
            for i in range(6):
                if userinfo['username'] == '13799999999' and i >= 3:
                    # 待审批的合同
                    _AddContract.add_contracts(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1),
                        approve_status='applying',
                        DepartmentId=1)
                    # _AddContract.add_contracts(sign_date=self.sign_date_list[i],
                    #                            total_amount=self.total_amount_list[a - 1][1] * (i + 1),
                    #                            approve_status='applying',DepartmentId=1)

                    # 审批通过的合同
                    _ContractsApproval.verify_contracts(
                        _AddContract.add_contracts(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][0] *
                            (i + 1),
                            approve_status='applying',
                            DepartmentId=1)[0])
                    _ContractsApproval.verify_contracts(
                        _AddContract.add_contracts(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][1] *
                            (i + 1),
                            approve_status='applying',
                            DepartmentId=1)[0])

                    # 审批通过后否决
                    contracts_id = _AddContract.add_contracts(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1),
                        approve_status='applying',
                        DepartmentId=1)[0]
                    _ContractsApproval.verify_contracts(contracts_id)
                    print(_AddContract.contracts_id)
                    _ContractsApproval.deny_contracts(contracts_id)

                    # 审批否决的合同
                    _ContractsApproval.deny_contracts(
                        _AddContract.add_contracts(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][0] *
                            (i + 1),
                            approve_status='applying',
                            DepartmentId=1)[0])

                    # 合同撤销
                    _ContractsApproval.cancel_contracts(
                        _AddContract.add_contracts(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][0] *
                            (i + 1),
                            approve_status='applying',
                            DepartmentId=1)[0])

                else:
                    # 待审批的合同
                    _AddContract.add_contracts(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1),
                        approve_status='applying')
                    # _AddContract.add_contracts(sign_date=self.sign_date_list[i], total_amount=self.total_amount_list[a-1][1]*(i+1),approve_status='applying')

                    # 审批通过的合同
                    _ContractsApproval.verify_contracts(
                        _AddContract.add_contracts(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][0] *
                            (i + 1),
                            approve_status='applying')[0])
                    _ContractsApproval.verify_contracts(
                        _AddContract.add_contracts(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][1] *
                            (i + 1),
                            approve_status='applying')[0])

                    # 审批通过后否决
                    contracts_id = _AddContract.add_contracts(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1),
                        approve_status='applying')[0]
                    _ContractsApproval.verify_contracts(contracts_id)
                    print(_AddContract.contracts_id)
                    _ContractsApproval.deny_contracts(contracts_id)

                    # contracts_id=_AddContract.add_contracts(sign_date=self.sign_date_list[i],total_amount=self.total_amount_list[a - 1][1] * (i + 1),approve_status='applying')[0]
                    # _ContractsApproval.verify_contracts(contracts_id)
                    # _ContractsApproval.deny_contracts(contracts_id)
                    # 审批否决的合同
                    _ContractsApproval.deny_contracts(
                        _AddContract.add_contracts(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][0] *
                            (i + 1),
                            approve_status='applying')[0])
                    # _ContractsApproval.deny_contracts(_AddContract.add_contracts(sign_date=self.sign_date_list[i],total_amount=self.total_amount_list[a - 1][1] * (i + 1),approve_status='applying')[0])
                    # 合同撤销
                    _ContractsApproval.cancel_contracts(
                        _AddContract.add_contracts(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][0] *
                            (i + 1),
                            approve_status='applying')[0])
Exemplo n.º 8
0
 def __init__(self, ):
     self.csrf = ""
     self.cookie = ""
     self.Login = login.Login()
     # self.contract_approval = ContractApproval(cookie, csrf)
     pass
Exemplo n.º 9
0
    def case_1(self):
        self.current_case = 'case 1'
        _login = login.Login()
        _login.login(self.userinfo_super['username'], self.userinfo_super['password'], self.userinfo_super['role'])
        self.cookie =_login.cookie
        self.csrf = _login.csrf
        _ApprovalOppo =ApprovalOppo.Approvals(self.cookie,self.csrf)
        _ApprovalOppo.close_opportunitie_approval()
        # #独立
        # # stage = [268994, 268992, 268991, 268990, 268989, 308555, 308556, 308557, 3085558, 308559, 308560, 308561, '']
        # 钉钉test
        stage = [222996, 222995, 222994, 222993, 222992, 222991, 222990, 308557, 3085558, 308559, 308560, 308561, '']
        stage_win = '222997'
        #钉钉staging
        # stage = [199480, 199479, 199478, 199477, 199476, 199475, 308557, 3085558, 308559, 308560, 308561, '']
        # stage_win = '199481'
        a =0
        for userinfo in self.userinfo_list:
            _login.login(userinfo['username'], userinfo['password'], userinfo['role'])
            print (userinfo['username'])
            self.cookie =_login.cookie
            self.csrf = _login.csrf
            _AddOppo = AddOppo.AddOpportunities(self.cookie,self.csrf)
            _ApprovalOppo =ApprovalOppo.Approvals(self.cookie,self.csrf)
            a= a+1
            for i in range(6):
                if userinfo['username'] == '13799999999' and i >= 3:
                    for b in range(a):
                    #添加商机审批关闭 268893为赢单
                        _AddOppo.add_opportunities(sign_date=self.sign_date_list[i],total_amount=self.total_amount_list[a - 1][0] * (i + 1), stage=stage_win,DepartmentId=1)
                    _AddOppo.add_opportunities(sign_date=self.sign_date_list[i],total_amount=self.total_amount_list[a - 1][0] * (i + 1), stage=stage[i],DepartmentId=1)
                else:
                    for b in range(a):
                    # 添加商机审批关闭 268893为赢单
                        _AddOppo.add_opportunities(sign_date =self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),stage=stage_win)
                    _AddOppo.add_opportunities(sign_date=self.sign_date_list[i],total_amount=self.total_amount_list[a - 1][0] * (i + 1), stage=stage[i])


        _login.login(self.userinfo_super['username'], self.userinfo_super['password'],self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _ApprovalOppo = ApprovalOppo.Approvals(self.cookie, self.csrf)
        _ApprovalOppo.open_opportunitie_approval()
        a = 0
        for userinfo in self.userinfo_list:
            _login.login(userinfo['username'], userinfo['password'], userinfo['role'])
            self.cookie =_login.cookie
            self.csrf = _login.csrf
            _AddOppo = AddOppo.AddOpportunities(self.cookie, self.csrf)
            _ApprovalOppo = ApprovalOppo.Approvals(self.cookie, self.csrf)
            a= a+1
            for i in range(6):
                    if userinfo['username'] == '13799999999' and i >= 3:
                        # 待审批的商机
                        _AddOppo.add_opportunities(sign_date =self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage_win,DepartmentId=1)
                        _AddOppo.add_opportunities(sign_date=self.sign_date_list[i],total_amount=self.total_amount_list[a - 1][0] * (i+1), approve_status='applying',stage=stage[i],DepartmentId=1)
                        for b in range(a):
                        # 审批通过的商机
                            _ApprovalOppo.approve_opportunity(_AddOppo.add_opportunities(sign_date =self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage_win,DepartmentId=1))
                        _ApprovalOppo.approve_opportunity(_AddOppo.add_opportunities(sign_date=self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage[i],DepartmentId=1))
    #
                        # 审批通过后否决
                        oppo_id=_AddOppo.add_opportunities(sign_date =self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage_win,DepartmentId=1)
                        _ApprovalOppo.approve_opportunity(oppo_id)
                        _ApprovalOppo.deny_opportunities_approval(oppo_id)

                        # 审批通过后否决
                        oppo_id = _AddOppo.add_opportunities(sign_date=self.sign_date_list[i],
                                                             total_amount=self.total_amount_list[a - 1][0] * (i + 1),
                                                             approve_status='applying', stage=stage[i], DepartmentId=1)
                        _ApprovalOppo.approve_opportunity(oppo_id)
                        _ApprovalOppo.deny_opportunities_approval(oppo_id)


                        # # 审批否决的商机
                        _ApprovalOppo.deny_opportunities_approval(_AddOppo.add_opportunities(sign_date =self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage_win,DepartmentId=1))
                        _ApprovalOppo.deny_opportunities_approval(_AddOppo.add_opportunities(sign_date=self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage[i],DepartmentId=1))

                        # # 商机撤销
                        _ApprovalOppo.cancel_opportunities_approval(_AddOppo.add_opportunities(sign_date =self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage_win,DepartmentId=1))
                        _ApprovalOppo.cancel_opportunities_approval(_AddOppo.add_opportunities(sign_date=self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage[i],DepartmentId=1))

                    else:
                        # 待审批的商机
                        _AddOppo.add_opportunities(sign_date =self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage_win)
                        _AddOppo.add_opportunities(sign_date=self.sign_date_list[i],total_amount=self.total_amount_list[a - 1][0] * (i+1), approve_status='applying',stage=stage[i])
                        for b in range(a):
                            # 审批通过的商机
                            _ApprovalOppo.approve_opportunity(_AddOppo.add_opportunities(sign_date =self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage_win))
                        _ApprovalOppo.approve_opportunity(_AddOppo.add_opportunities(sign_date=self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage[i]))
    #
                        # 审批通过后否决
                        oppo_id=_AddOppo.add_opportunities(sign_date =self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage_win)
                        _ApprovalOppo.approve_opportunity(oppo_id)
                        _ApprovalOppo.deny_opportunities_approval(oppo_id)

                        oppo_id = _AddOppo.add_opportunities(sign_date=self.sign_date_list[i],total_amount=self.total_amount_list[a - 1][0] * (i + 1),
                                                             approve_status='applying', stage=stage[i])
                        _ApprovalOppo.approve_opportunity(oppo_id)
                        _ApprovalOppo.deny_opportunities_approval(oppo_id)

                        # # 审批否决的商机
                        _ApprovalOppo.deny_opportunities_approval(_AddOppo.add_opportunities(sign_date =self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage_win))
                        _ApprovalOppo.deny_opportunities_approval(_AddOppo.add_opportunities(sign_date=self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage[i]))

                        # # 商机撤销
                        _ApprovalOppo.cancel_opportunities_approval(_AddOppo.add_opportunities(sign_date =self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage_win))
                        _ApprovalOppo.cancel_opportunities_approval(_AddOppo.add_opportunities(sign_date=self.sign_date_list[i],total_amount=self.total_amount_list[a-1][0]*(i+1),approve_status='applying',stage=stage[i]))
Exemplo n.º 10
0
    def case_1(self):
        stage = self.stage
        stage_win = self.stage_win
        self.current_case = 'case 1'
        _login = login.Login()
        a = 0
        _login.login(self.userinfo_super['username'],
                     self.userinfo_super['password'],
                     self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _ApprovalOppo = ApprovalOppo.Approvals(self.cookie, self.csrf)
        _ApprovalOppo.close_opportunitie_approval()

        for userinfo in self.userinfo_list:
            _login.login(userinfo['username'], userinfo['password'],
                         userinfo['role'])
            self.cookie = _login.cookie
            self.csrf = _login.csrf
            _AddOppo = AddOppo.AddOpportunities(self.cookie, self.csrf)
            _ApprovalOppo = ApprovalOppo.Approvals(self.cookie, self.csrf)
            a = a + 1
            for i in range(6):
                if userinfo['username'] == '13799999999' and i >= 3:
                    # if userinfo['username'] == '13660139206' and i >= 3:
                    #添加商机审批关闭 268893为赢单
                    _AddOppo.add_opportunities(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1),
                        stage=stage_win,
                        DepartmentId=1)
                    _AddOppo.add_opportunities(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][1] *
                        (i + 1),
                        stage=stage_win,
                        DepartmentId=1)
                    _AddOppo.add_opportunities(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1),
                        stage=stage[i],
                        DepartmentId=1)
                else:
                    # 添加商机审批关闭 268893为赢单
                    _AddOppo.add_opportunities(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1),
                        stage=stage_win)
                    _AddOppo.add_opportunities(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][1] *
                        (i + 1),
                        stage=stage_win)
                    _AddOppo.add_opportunities(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1),
                        stage=stage[i])

        _login.login(self.userinfo_super['username'],
                     self.userinfo_super['password'],
                     self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _ApprovalOppo = ApprovalOppo.Approvals(self.cookie, self.csrf)
        _ApprovalOppo.open_opportunitie_approval()
        a = 0
        for userinfo in self.userinfo_list:
            _login.login(userinfo['username'], userinfo['password'],
                         userinfo['role'])
            self.cookie = _login.cookie
            self.csrf = _login.csrf
            _AddOppo = AddOppo.AddOpportunities(self.cookie, self.csrf)
            _ApprovalOppo = ApprovalOppo.Approvals(self.cookie, self.csrf)
            a = a + 1
            for i in range(6):
                if userinfo['username'] == '13799999999' and i >= 3:
                    # if userinfo['username'] == '13660139206' and i >= 3:
                    # 待审批的商机
                    _AddOppo.add_opportunities(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1),
                        approve_status='applying',
                        stage=stage_win,
                        DepartmentId=1)

                    # 审批通过的商机
                    _ApprovalOppo.approve_opportunity(
                        _AddOppo.add_opportunities(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][0] *
                            (i + 1),
                            approve_status='applying',
                            stage=stage_win,
                            DepartmentId=1))
                    _ApprovalOppo.approve_opportunity(
                        _AddOppo.add_opportunities(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][1] *
                            (i + 1),
                            approve_status='applying',
                            stage=stage_win,
                            DepartmentId=1))
                    _ApprovalOppo.approve_opportunity(
                        _AddOppo.add_opportunities(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][0] *
                            (i + 1),
                            approve_status='applying',
                            stage=stage[i],
                            DepartmentId=1))

                    # 审批通过后否决
                    oppo_id = _AddOppo.add_opportunities(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1),
                        approve_status='applying',
                        stage=stage_win,
                        DepartmentId=1)
                    _ApprovalOppo.approve_opportunity(oppo_id)
                    _ApprovalOppo.deny_opportunities_approval(oppo_id)

                    # # 审批否决的商机
                    _ApprovalOppo.deny_opportunities_approval(
                        _AddOppo.add_opportunities(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][0] *
                            (i + 1),
                            approve_status='applying',
                            stage=stage_win,
                            DepartmentId=1))

                    # # 商机撤销
                    _ApprovalOppo.cancel_opportunities_approval(
                        _AddOppo.add_opportunities(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][0] *
                            (i + 1),
                            approve_status='applying',
                            stage=stage_win,
                            DepartmentId=1))

                else:
                    # 待审批的商机
                    _AddOppo.add_opportunities(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1),
                        approve_status='applying',
                        stage=stage_win)

                    # 审批通过的商机
                    _ApprovalOppo.approve_opportunity(
                        _AddOppo.add_opportunities(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][0] *
                            (i + 1),
                            approve_status='applying',
                            stage=stage_win))
                    _ApprovalOppo.approve_opportunity(
                        _AddOppo.add_opportunities(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][1] *
                            (i + 1),
                            approve_status='applying',
                            stage=stage_win))
                    _ApprovalOppo.approve_opportunity(
                        _AddOppo.add_opportunities(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][0] *
                            (i + 1),
                            approve_status='applying',
                            stage=stage[i]))

                    # 审批通过后否决
                    oppo_id = _AddOppo.add_opportunities(
                        sign_date=self.sign_date_list[i],
                        total_amount=self.total_amount_list[a - 1][0] *
                        (i + 1),
                        approve_status='applying',
                        stage=stage_win)
                    _ApprovalOppo.approve_opportunity(oppo_id)
                    _ApprovalOppo.deny_opportunities_approval(oppo_id)

                    # # 审批否决的商机
                    _ApprovalOppo.deny_opportunities_approval(
                        _AddOppo.add_opportunities(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][0] *
                            (i + 1),
                            approve_status='applying',
                            stage=stage_win))

                    # # 商机撤销
                    _ApprovalOppo.cancel_opportunities_approval(
                        _AddOppo.add_opportunities(
                            sign_date=self.sign_date_list[i],
                            total_amount=self.total_amount_list[a - 1][0] *
                            (i + 1),
                            approve_status='applying',
                            stage=stage_win))
Exemplo n.º 11
0
    def case_1(self):
        self.current_case = 'case 1'
        _login = login.Login()
        _login.login(self.userinfo_super['username'],
                     self.userinfo_super['password'],
                     self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _CustomersApproval = Approval.ApprovalSettings(self.cookie, self.csrf)
        _CustomersApproval.close_approval()
        a = 1
        customers = {}
        for userinfo in self.userinfo_list:
            print(userinfo['username'])
            _login.login(userinfo['username'], userinfo['password'],
                         userinfo['role'])
            self.cookie = _login.cookie
            self.csrf = _login.csrf
            _AddCustomers = AddCustomers.AddCustomer(self.cookie, self.csrf)
            _CustomersApprovall = Approval.ApprovalSettings(
                self.cookie, self.csrf)
            for i in range(6 * a):
                month = int(math.ceil((i + 1) / a))
                # print(month)
                if userinfo['username'] == '13799999999' and i >= 18:
                    #添加客户
                    id = _AddCustomers.add_customers(DepartmentId=1)
                else:
                    id = _AddCustomers.add_customers()
                if month not in customers:
                    customers[month] = []
                customers[month].append(id)
            a += 1
        self.customers = customers

        for i in range(6):
            self.sql(self.date_list[i], tuple(customers[i + 1]))

        _login.login(self.userinfo_super['username'],
                     self.userinfo_super['password'],
                     self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _CustomersApproval = Approval.ApprovalSettings(self.cookie, self.csrf)
        _CustomersApproval.open_approval()
        a = 1
        customers = {}
        customers[1] = []
        for userinfo in self.userinfo_list:
            _login.login(userinfo['username'], userinfo['password'],
                         userinfo['role'])
            print(userinfo['username'])
            self.cookie = _login.cookie
            self.csrf = _login.csrf
            _AddCustomers = AddCustomers.AddCustomer(self.cookie, self.csrf)
            _CustomersApproval = Approval.ApprovalSettings(
                self.cookie, self.csrf)

            # 待审批的客户
            customer_id = _AddCustomers.add_customers(
                approve_status='applying', DepartmentId=0)
            customers[1].append(customer_id)
            # print(customers_data)
            # 审批通过后否决
            customer_id = _AddCustomers.add_customers()
            _CustomersApproval.approve_verify(customer_id)
            _CustomersApproval.deny_approval(customer_id)
            customers[1].append(customer_id)
            # 审批否决的客户
            customer_id = _CustomersApproval.deny_approval(
                _AddCustomers.add_customers(approve_status='applying'))
            customers[1].append(customer_id)
            # 客户撤销
            customer_id = _CustomersApproval.cancel_approval(
                _AddCustomers.add_customers(approve_status='applying'))
            customers[1].append(customer_id)
            # print(customers_data)
            if userinfo['username'] == '13799999999':
                for i in range(6 * a):
                    month = int(math.ceil((i + 1) / a))
                    # print(month)
                    if i >= 18:
                        # 审批通过的客户
                        customer_id = _CustomersApproval.approve_verify(
                            _AddCustomers.add_customers(
                                approve_status='applying', DepartmentId=1))
                    else:
                        customer_id = _CustomersApproval.approve_verify(
                            _AddCustomers.add_customers(
                                approve_status='applying', DepartmentId=0))
                    if month not in customers:
                        customers[month] = []
                    customers[month].append(customer_id)
            else:

                for i in range(6 * a):
                    month = int(math.ceil((i + 1) / a))
                    # print(month)
                    # 审批通过的客户
                    customer_id = _CustomersApproval.approve_verify(
                        _AddCustomers.add_customers(approve_status='applying',
                                                    DepartmentId=0))
                    if month not in customers:
                        customers[month] = []
                    customers[month].append(customer_id)
            # print(customers_data)
            a += 1
        print(customers)
        for i in range(6):
            self.sql(self.date_list[i], tuple(customers[i + 1]))
Exemplo n.º 12
0
    def case_1(self):
        self.current_case = 'case 1'
        _login = login.Login()
        a = 0
        # # 超管登录 关闭合同回款审批,新增回款===================================
        # _login.login(self.userinfo_super['username'], self.userinfo_super['password'], self.userinfo_super['role'])
        _login.login(self.userinfo_super['username'],
                     self.userinfo_super['password'],
                     self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _ContractsApproval = ContractsApproval.Approvals(
            self.cookie, self.csrf)
        _ReceivedPaymentApproval = ReceivedPaymentApproval.Approvals(
            self.cookie, self.csrf)
        #关闭合同审批和回款审批
        _ContractsApproval.close_contract_approval()
        _ReceivedPaymentApproval.close_received_payment_approval()
        for userinfo in self.userinfo_list:
            _login.login(userinfo['username'], userinfo['password'],
                         userinfo['role'])
            self.cookie = _login.cookie
            self.csrf = _login.csrf
            _ContractsApproval = ContractsApproval.Approvals(
                self.cookie, self.csrf)
            _ReceivedPaymentApproval = ReceivedPaymentApproval.Approvals(
                self.cookie, self.csrf)
            _AddReceivedPayments = AddReceivedPayments.AddReceivedPayment(
                self.cookie, self.csrf)
            _AddContract = AddContract.AddContract(self.cookie, self.csrf)
            a = a + 1
            # 添加一个合同
            if userinfo['username'] == '13799999999':
                # 新增合同后返回的合同id和客户id:contract_return_id[0]为合同id contract_return_id[1]为客户id
                # 用户6--合同所属部门:设计部
                contract_return_id = _AddContract.add_contracts(DepartmentId=1)
                for i in range(6):
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][0] * (i + 1),
                        customer_id=contract_return_id[1])
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][1] * (i + 1),
                        customer_id=contract_return_id[1])
                #用户6--合同所属部门:产品部
                contract_return_id = _AddContract.add_contracts(DepartmentId=0)
                for i in range(6):
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][0] * (i + 1),
                        customer_id=contract_return_id[1])
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][1] * (i + 1),
                        customer_id=contract_return_id[1])

            else:
                # 新增合同后返回的合同id和客户id:contract_return_id[0]为合同id contract_return_id[1]为客户id
                contract_return_id = _AddContract.add_contracts(
                    DepartmentId=0)  # id[0]为合同id id[1]为客户id
                for i in range(6):
                    # 添加新增回款记录
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][0] * (i + 1),
                        customer_id=contract_return_id[1])
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][1] * (i + 1),
                        customer_id=contract_return_id[1])

        # 超管登录 关闭合同审批,开启回款审批,=========================
        _login.login(self.userinfo_super['username'],
                     self.userinfo_super['password'],
                     self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _ReceivedPaymentApproval = ReceivedPaymentApproval.Approvals(
            self.cookie, self.csrf)
        _ReceivedPaymentApproval.open_received_payment_approval()
        a = 0
        for userinfo in self.userinfo_list:
            _login.login(userinfo['username'], userinfo['password'],
                         userinfo['role'])
            self.cookie = _login.cookie
            self.csrf = _login.csrf
            _ContractsApproval = ContractsApproval.Approvals(
                self.cookie, self.csrf)
            _ReceivedPaymentApproval = ReceivedPaymentApproval.Approvals(
                self.cookie, self.csrf)
            _AddReceivedPayments = AddReceivedPayments.AddReceivedPayment(
                self.cookie, self.csrf)
            _AddContract = AddContract.AddContract(self.cookie, self.csrf)
            a = a + 1
            if userinfo['username'] == '13799999999':
                # 新增合同后返回的合同id和客户id:contract_return_id[0]为合同id contract_return_id[1]为客户id
                contract_return_id = _AddContract.add_contracts(DepartmentId=1)
                for i in range(6):
                    # 新增审批通过后的回款
                    _ReceivedPaymentApproval.received_payments_verify(
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][0] * (i + 1),
                            customer_id=contract_return_id[1]))
                    _ReceivedPaymentApproval.received_payments_verify(
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][1] * (i + 1),
                            customer_id=contract_return_id[1]))
                contract_return_id = _AddContract.add_contracts(DepartmentId=0)
                for i in range(6):
                    _ReceivedPaymentApproval.received_payments_verify(
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][0] * (i + 1),
                            customer_id=contract_return_id[1]))
                    _ReceivedPaymentApproval.received_payments_verify(
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][1] * (i + 1),
                            customer_id=contract_return_id[1]))
                # 新增合同后返回的合同id和客户id:contract_return_id[0]为合同id contract_return_id[1]为客户id
                contract_return_id = _AddContract.add_contracts(DepartmentId=1)
                for i in range(6):
                    # 新增待审批的回款
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][0] * (i + 1),
                        customer_id=contract_return_id[1])
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][1] * (i + 1),
                        customer_id=contract_return_id[1])
                contract_return_id = _AddContract.add_contracts(DepartmentId=0)
                for i in range(6):
                    # 新增待审批的回款
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][0] * (i + 1),
                        customer_id=contract_return_id[1])
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][1] * (i + 1),
                        customer_id=contract_return_id[1])
                # 新增合同后返回的合同id和客户id:contract_return_id[0]为合同id contract_return_id[1]为客户id
                contract_return_id = _AddContract.add_contracts(DepartmentId=1)
                for i in range(6):
                    # 新增审批否决后的回款
                    _ReceivedPaymentApproval.received_payments_deny(
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][0] * (i + 1),
                            customer_id=contract_return_id[1]))
                    _ReceivedPaymentApproval.received_payments_deny(
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][1] * (i + 1),
                            customer_id=contract_return_id[1]))
                contract_return_id = _AddContract.add_contracts(DepartmentId=0)
                for i in range(6):
                    _ReceivedPaymentApproval.received_payments_deny(
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][0] * (i + 1),
                            customer_id=contract_return_id[1]))
                    _ReceivedPaymentApproval.received_payments_deny(
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][1] * (i + 1),
                            customer_id=contract_return_id[1]))
                contract_return_id = _AddContract.add_contracts(DepartmentId=1)
                for i in range(6):
                    # 新增审批通过后驳回的回款
                    _ReceivedPaymentApproval.received_payments_deny(
                        _ReceivedPaymentApproval.received_payments_verify(
                            _AddReceivedPayments.add_received_payments(
                                contract_id=contract_return_id[0],
                                receive_date=self.sign_date_list[i],
                                amount=self.total_amount_list[a - 1][0] *
                                (i + 1),
                                customer_id=contract_return_id[1])))
                    _ReceivedPaymentApproval.received_payments_deny(
                        _ReceivedPaymentApproval.received_payments_verify(
                            _AddReceivedPayments.add_received_payments(
                                contract_id=contract_return_id[0],
                                receive_date=self.sign_date_list[i],
                                amount=self.total_amount_list[a - 1][1] *
                                (i + 1),
                                customer_id=contract_return_id[1])))
                contract_return_id = _AddContract.add_contracts(DepartmentId=0)
                for i in range(6):
                    # 新增审批通过后驳回的回款
                    _ReceivedPaymentApproval.received_payments_deny(
                        _ReceivedPaymentApproval.received_payments_verify(
                            _AddReceivedPayments.add_received_payments(
                                contract_id=contract_return_id[0],
                                receive_date=self.sign_date_list[i],
                                amount=self.total_amount_list[a - 1][0] *
                                (i + 1),
                                customer_id=contract_return_id[1])))
                    _ReceivedPaymentApproval.received_payments_deny(
                        _ReceivedPaymentApproval.received_payments_verify(
                            _AddReceivedPayments.add_received_payments(
                                contract_id=contract_return_id[0],
                                receive_date=self.sign_date_list[i],
                                amount=self.total_amount_list[a - 1][1] *
                                (i + 1),
                                customer_id=contract_return_id[1])))

            else:
                # 添加一个合同
                contract_return_id = _AddContract.add_contracts()
                for i in range(6):
                    # 新增审批通过后的回款
                    _ReceivedPaymentApproval.received_payments_verify(
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][0] * (i + 1),
                            customer_id=contract_return_id[1]))
                    _ReceivedPaymentApproval.received_payments_verify(
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][1] * (i + 1),
                            customer_id=contract_return_id[1]))
                contract_return_id = _AddContract.add_contracts()
                for i in range(6):
                    # 新增待审批的回款
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][0] * (i + 1),
                        customer_id=contract_return_id[1])
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][1] * (i + 1),
                        customer_id=contract_return_id[1])
                # # 添加一个合同
                contract_return_id = _AddContract.add_contracts()
                for i in range(6):
                    # 新增审批否决后的回款
                    _ReceivedPaymentApproval.received_payments_deny(
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][0] * (i + 1),
                            customer_id=contract_return_id[1]))
                    _ReceivedPaymentApproval.received_payments_deny(
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][1] * (i + 1),
                            customer_id=contract_return_id[1]))
                # #添加一个合同
                contract_return_id = _AddContract.add_contracts()
                for i in range(6):
                    # 新增审批通过后驳回的回款
                    _ReceivedPaymentApproval.received_payments_deny(
                        _ReceivedPaymentApproval.received_payments_verify(
                            _AddReceivedPayments.add_received_payments(
                                contract_id=contract_return_id[0],
                                receive_date=self.sign_date_list[i],
                                amount=self.total_amount_list[a - 1][0] *
                                (i + 1),
                                customer_id=contract_return_id[1])))
                    _ReceivedPaymentApproval.received_payments_deny(
                        _ReceivedPaymentApproval.received_payments_verify(
                            _AddReceivedPayments.add_received_payments(
                                contract_id=contract_return_id[0],
                                receive_date=self.sign_date_list[i],
                                amount=self.total_amount_list[a - 1][1] *
                                (i + 1),
                                customer_id=contract_return_id[1])))
Exemplo n.º 13
0
    def case_2(self):
        _login = login.Login()
        a = 0
        # 超管登录 合同审批开启 回款审批关闭,新增回款===================================
        _login.login(self.userinfo_super['username'],
                     self.userinfo_super['password'],
                     self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _ContractsApproval = ContractsApproval.Approvals(
            self.cookie, self.csrf)
        _ReceivedPaymentApproval = ReceivedPaymentApproval.Approvals(
            self.cookie, self.csrf)
        # 开启合同审批和 关闭回款审批
        _ContractsApproval.open_contract_approval()
        _ReceivedPaymentApproval.close_received_payment_approval()
        for userinfo in self.userinfo_list:
            _login.login(userinfo['username'], userinfo['password'],
                         userinfo['role'])
            print(userinfo['username'])
            self.cookie = _login.cookie
            self.csrf = _login.csrf
            _ContractsApproval = ContractsApproval.Approvals(
                self.cookie, self.csrf)
            _ReceivedPaymentApproval = ReceivedPaymentApproval.Approvals(
                self.cookie, self.csrf)
            _AddReceivedPayments = AddReceivedPayments.AddReceivedPayment(
                self.cookie, self.csrf)
            _AddContract = AddContract.AddContract(self.cookie, self.csrf)
            a = a + 1
            if userinfo['username'] == '13799999999':
                for b in range(2):
                    # 添加一个待审批的合同(p1-1);新增合同后返回的合同id和客户id:contract_return_id[0]为合同id contract_return_id[1]为客户id
                    contract_return_id = _AddContract.add_contracts(
                        DepartmentId=b, approve_status='applying')
                    _ContractsApproval.verify_contracts(contract_return_id[0])
                    # print (contract_return_id[0])
                    for i in range(6):
                        # 添加新增回款记录
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][0] * (i + 1),
                            customer_id=contract_return_id[1])
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][1] * (i + 1),
                            customer_id=contract_return_id[1])
                    print(u'合同审批通过,回款关闭,数据完成================================')

                    # 添加一个待审批的合同(p2-1)
                    contract_return_id = _AddContract.add_contracts(
                        DepartmentId=b, approve_status='applying')
                    for i in range(6):
                        # 添加新增回款记录
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][0] * (i + 1),
                            customer_id=contract_return_id[1])
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][1] * (i + 1),
                            customer_id=contract_return_id[1])
                    print(u'合同待审批,回款关闭,数据完成================================')

                    # 添加一个待审批的合同 合同驳回(P3-1)
                    contract_return_id = _AddContract.add_contracts(
                        DepartmentId=b,
                        approve_status='applying')  # id[0]为合同id id[1]为客户id
                    # print(contract_return_id)
                    # 审批通过
                    _ContractsApproval.verify_contracts(contract_return_id[0])
                    _ContractsApproval.deny_contracts(contract_return_id[0])
                    for i in range(6):
                        # 添加新增回款记录
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][0] * (i + 1),
                            customer_id=contract_return_id[1])
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][1] * (i + 1),
                            customer_id=contract_return_id[1])
                    # 添加一个撤销的合同(p4-1)
                    contract_return_id = _AddContract.add_contracts(
                        DepartmentId=b, approve_status='applying')
                    for i in range(6):
                        # 添加新增回款记录
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][0] * (i + 1),
                            customer_id=contract_return_id[1])
                        _AddReceivedPayments.add_received_payments(
                            contract_id=contract_return_id[0],
                            receive_date=self.sign_date_list[i],
                            amount=self.total_amount_list[a - 1][1] * (i + 1),
                            customer_id=contract_return_id[1])
                    _ContractsApproval.cancel_contracts(contract_return_id[0])

                    print(u'合同待撤销,回款关闭,数据完成================================')
            else:
                # 添加一个待审批的合同(p1-1)
                contract_return_id = _AddContract.add_contracts(
                    DepartmentId=0, approve_status='applying')
                # 审批通过
                _ContractsApproval.verify_contracts(contract_return_id[0])
                print(contract_return_id[0])
                for i in range(6):
                    # 添加新增回款记录
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][0] * (i + 1),
                        customer_id=contract_return_id[1])
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][1] * (i + 1),
                        customer_id=contract_return_id[1])
                print(u'合同审批通过,回款关闭,数据完成================================')

                # 添加一个待审批的合同(p2-1)
                contract_return_id = _AddContract.add_contracts(
                    DepartmentId=0, approve_status='applying')
                for i in range(6):
                    # 添加新增回款记录
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][0] * (i + 1),
                        customer_id=contract_return_id[1])
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][1] * (i + 1),
                        customer_id=contract_return_id[1])
                print(u'合同待审批,回款关闭,数据完成================================')

                # 添加一个待审批的合同 合同通过后驳回(P3-1)
                contract_return_id = _AddContract.add_contracts(
                    DepartmentId=0, approve_status='applying')
                # 审批通过
                _ContractsApproval.verify_contracts(contract_return_id[0])
                _ContractsApproval.deny_contracts(contract_return_id[0])
                for i in range(6):
                    # 添加新增回款记录
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][0] * (i + 1),
                        customer_id=contract_return_id[1])
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][1] * (i + 1),
                        customer_id=contract_return_id[1])
                # 添加一个撤销的合同(p4-1)
                contract_return_id = _AddContract.add_contracts(
                    DepartmentId=0, approve_status='applying')
                for i in range(6):
                    # 添加新增回款记录
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][0] * (i + 1),
                        customer_id=contract_return_id[1])
                    _AddReceivedPayments.add_received_payments(
                        contract_id=contract_return_id[0],
                        receive_date=self.sign_date_list[i],
                        amount=self.total_amount_list[a - 1][1] * (i + 1),
                        customer_id=contract_return_id[1])
                _ContractsApproval.cancel_contracts(contract_return_id[0])

                print(u'合同待撤销,回款关闭,数据完成================================')

        #超管登录 合同审批开启 回款审批开启,新增回款===================================
        _login.login(self.userinfo_super['username'],
                     self.userinfo_super['password'],
                     self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _ReceivedPaymentApproval = ReceivedPaymentApproval.Approvals(
            self.cookie, self.csrf)
        _ReceivedPaymentApproval.open_received_payment_approval()
        a = 0
        for userinfo in self.userinfo_list:
            _login.login(userinfo['username'], userinfo['password'],
                         userinfo['role'])
            self.cookie = _login.cookie
            self.csrf = _login.csrf
            _ContractsApproval = ContractsApproval.Approvals(
                self.cookie, self.csrf)
            _ReceivedPaymentApproval = ReceivedPaymentApproval.Approvals(
                self.cookie, self.csrf)
            _AddReceivedPayments = AddReceivedPayments.AddReceivedPayment(
                self.cookie, self.csrf)
            _AddContract = AddContract.AddContract(self.cookie, self.csrf)
            a = a + 1
            if userinfo['username'] == '13799999999':
                self.add_data(a, DepartmentId=0)
                self.add_data(a, DepartmentId=1)
            else:
                self.add_data(a, DepartmentId=0)
Exemplo n.º 14
0
from commons.const import const
from testCase.departments import testGetDepartment as departments
# from testCase.performance import test1


class Main:
    def __init__(self):
        self.cookie = ''
        self.csrf = ''

if __name__ == "__main__":
    os.remove('status_code_ok.txt')
    os.remove('status_code.txt')
    for userinfo in const.USER:
        # print (userinfo)
        _login = login.Login()
        # _login.private_login(userinfo['username'], userinfo['password'])
        print(userinfo['username'], userinfo['password'])
        _login.uc_login(userinfo['username'], userinfo['password'], userinfo['role'])
        # _login.cook_get()
        # _login.get_csrf_by_home_html()
        main = Main()
        main.cookie = _login.cookie
        main.csrf = _login.csrf

        # 线索
        # _leads = leads.Leads(main.cookie, main.csrf)
        # _leads.testLeads()
        # print(u'%s线索模块已执行完成' %(userinfo['username']))
        # 线索池
        # _lead_common = lead_common.LeadCommon(main.cookie, main.csrf)
    def check_data_user(self,
                        s1,
                        type1,
                        i=0,
                        _users=['设计部-用户1', '销售部-用户5', '同部门下属-用户7'],
                        k=0):
        current_case = self.title[i]
        time.sleep(2)
        _login = login.Login()
        _login.login(self.userinfo_super['username'],
                     self.userinfo_super['password'],
                     self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _Roles = testGetRoles.GetRole(self.cookie, self.csrf)
        ### 设置用户的角色必须是普通管理员的角色
        _Roles.ding_set_data_authority(self.field_permission_grant_scope[k])
        print(self.field_permission_grant_scope[k])
        _login = login.Login()
        _login.login(self.userinfo_['username'], self.userinfo_['password'],
                     self.userinfo_['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _result = result.result(self.cookie, self.csrf)
        ##Actual_result输出三个值 图表,中间值,表格
        ## 业绩类型切换 合同数:contract_count 商机数:win_count 产品销量:product_count 产品分类销量:product_category_count s= 4
        Actual_result_all = _result.gole_completion(
            from_date=self.date_list[i][0],
            to_date=self.date_list[i][1],
            type=type1,
            dimension='year',
            data=self.date[i][0])

        # print(Actual_result_all[0])
        # # # Expected_result输出两个值 中间值,表格
        Expected_result_all = _result.count_get_completion_year(
            _months=self.month[i],
            _users=_users,
            _month_view=self._month_view[i],
            s=s1)
        # # # # 比较图表的统计值是否相同
        Actual_result = Actual_result_all[0]
        # #图表的预期结果和表格的预期结果相同 所以取的是表格预期结果的值
        Expected_result = Expected_result_all
        s = len(Actual_result)
        for i in range(s):
            test_result = operator.eq(Expected_result[i], Actual_result[i])
            if test_result == True:
                f = codecs.open('contract_number.txt', 'a', 'utf-8')
                a = str(_users) + str(
                    str(current_case) + '图表的排名' + ': '
                    "is right " + str(datetime.datetime.now()))
                f.write(a + '\n')
            else:
                f = codecs.open('contract_number.txt', 'a', 'utf-8')
                a = str(_users) + '\n' + str(
                    str(current_case) + '图表的排名' + ': '
                    "is wrong, expected_result:'\n'" +
                    str(Expected_result[i]) + "Actual_result:'\n'" +
                    str(Actual_result[i]) + ',' + str(datetime.datetime.now()))
                f.write(a + '\n')
        # ##比较实际中间的统计值和预期中间的统计值是否相同
        Actual_result = Actual_result_all[1]
        Expected_result = Expected_result_all
        s = len(Actual_result)
        for i in range(s):
            test_result = operator.eq(Expected_result[i], Actual_result[i])
            if test_result == True:
                f = codecs.open('contract_number_y.txt', 'a', 'utf-8')
                a = str(_users) + '\n' + str(
                    str(current_case) + '中间统计排名' + ': '
                    "is right " + str(datetime.datetime.now()))
                f.write(a + '\n')
            else:
                f = codecs.open('contract_number_y.txt', 'a', 'utf-8')
                a = str(_users) + '\n' + str(
                    str(current_case) + '中间统计排名' + ': '
                    "is wrong, expected_result:'\n'" +
                    str(Expected_result[i]) + "Actual_result:'\n'" +
                    str(Actual_result[i]) + ',' + str(datetime.datetime.now()))
                f.write(a + '\n')
            #
        #比较表格实际排名和预期排名是否相等
        Actual_result = Actual_result_all[2]
        Expected_result = Expected_result_all
        s = len(Actual_result)
        for i in range(s):
            test_result = operator.eq(Expected_result[i], Actual_result[i])
            if test_result == True:
                f = codecs.open('contract_number_y.txt', 'a', 'utf-8')
                a = str(_users) + '\n' + str(
                    str(current_case) + '表格排名' + ': '
                    "is right " + str(datetime.datetime.now()))
                f.write(a + '\n')
            else:
                f = codecs.open('contract_number_y.txt', 'a', 'utf-8')
                a = str(_users) + '\n' + str(
                    str(current_case) + '表格排名' + ': '
                    "is wrong, expected_result:'\n'" +
                    str(Expected_result[i]) + "Actual_result:'\n'" +
                    str(Actual_result[i]) + ',' + str(datetime.datetime.now()))
                f.write(a + '\n')
Exemplo n.º 16
0
    def check_data_department(self,i =0):
        current_case = self.title[i]
        _login = login.Login()
        _login.login(self.userinfo_super['username'], self.userinfo_super['password'], self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _result = result.result(self.cookie, self.csrf)
        # Actual_result输出三个值 图表,中间值,表格
        Actual_result_all = _result.gole_d(from_date=self.date_list[i][0],to_date=self.date_list[i][1],type = 'product_category_count',dimension ='department')
        # Expected_result输出两个值 中间值,表格
        Expected_result_all =_result.count_get_department(self.month[i],s=4)

        # 比较图表的统计值是否相同
        Actual_result = Actual_result_all[0]
        #图表的预期结果和表格的预期结果相同 所以取的是表格预期结果的值
        Expected_result = Expected_result_all[1]

        s = len(Actual_result)
        for i in range(s):
            test_result = operator.eq(Expected_result[i], Actual_result[i])
            if test_result == True:
                f = codecs.open('product_category_count_d.txt', 'a', 'utf-8')
                a =str(i)+ str(str(current_case)+'图表的排名' + ': '  "is right " + str(datetime.datetime.now()))
                f.write(a + '\n')
            else:
                f = codecs.open('product_category_count_d.txt', 'a', 'utf-8')
                a = str(i)+str(str(current_case)+'图表的排名' + ': '  "is wrong, expected_result:'\n'" + str(
                    Expected_result[i]) + "Actual_result:'\n'" + str(Actual_result[i]) + ',' + str(
                    datetime.datetime.now()))
                f.write(a + '\n')
        #
        #比较实际中间的统计值和预期中间的统计值是否相同
        Actual_result=Actual_result_all[1]
        Expected_result=Expected_result_all[0]
        s = len(Actual_result)
        for i in range(s):
            test_result = operator.eq(Expected_result[i], Actual_result[i])
            if test_result == True :
                f = codecs.open('product_category_count_d.txt', 'a', 'utf-8')
                a = str(str(current_case)+'中间统计排名' + ': '  "is right " + str(datetime.datetime.now()))
                f.write(a + '\n')
            else:
                f = codecs.open('product_category_count_d.txt', 'a', 'utf-8')
                a = str(str(current_case)+'中间统计排名' + ': '  "is wrong, expected_result:'\n'" + str(
                    Expected_result[i]) + "Actual_result:'\n'" + str(Actual_result[i]) + ',' + str(datetime.datetime.now()))
                f.write(a + '\n')
        #
        #比较表格的是否相等
        Actual_result = Actual_result_all[2]
        Expected_result = Expected_result_all[1]
        s = len(Actual_result)
        for i in range(s):
            test_result = operator.eq(Expected_result[i], Actual_result[i])
            if test_result == True:
                f = codecs.open('product_category_count_d.txt', 'a', 'utf-8')
                a = str(str(current_case) +'表格排名'+ ': '  "is right " + str(datetime.datetime.now()))
                f.write(a + '\n')
            else:
                f = codecs.open('product_category_count_d.txt', 'a', 'utf-8')
                a = str(str(current_case) +'表格排名'+ ': '  "is wrong, expected_result:'\n'" + str(
                    Expected_result[i]) + "Actual_result:'\n'" + str(Actual_result[i]) + ',' + str(
                    datetime.datetime.now()))
                f.write(a + '\n')
    def check_data_user(self,
                        s1,
                        type1,
                        i=0,
                        _users=['设计部-用户1', '销售部-用户5', '同部门下属-用户7']):
        current_case = self.title[i]
        time.sleep(1)
        _login = login.Login()
        _login.login(self.userinfo_['username'], self.userinfo_['password'],
                     self.userinfo_['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _result = result.result(self.cookie, self.csrf)
        # Actual_result输出三个值 图表,中间值,表格
        Actual_result_all = _result.gole_completion(
            from_date=self.date_list[i][0],
            to_date=self.date_list[i][1],
            type=type1,
            dimension='month',
            data=self.date[i][0])
        # print(Actual_result_all)
        # Expected_result输出两个值 中间值,表格
        Expected_result_all = _result.count_get_completion(
            _months=self.month[i],
            _users=_users,
            _month_view=self._month_view[i],
            s=s1)
        # # # 比较图表的统计值是否相同
        Actual_result = Actual_result_all[0]
        # #图表的预期结果和表格的预期结果相同 所以取的是表格预期结果的值
        Expected_result = Expected_result_all[0]
        s = len(Actual_result)
        for i in range(s):
            test_result = operator.eq(Expected_result[i], Actual_result[i])
            if test_result == True:
                f = codecs.open('contract_number.txt', 'a', 'utf-8')
                a = str(_users) + '\n' + str(
                    str(current_case) + '图表的排名' + ': '
                    "is right " + str(datetime.datetime.now()))
                f.write(a + '\n')
            else:
                f = codecs.open('contract_number.txt', 'a', 'utf-8')
                a = str(_users) + '\n' + str(
                    str(current_case) + '图表的排名' + ': '
                    "is wrong, expected_result:'\n'" +
                    str(Expected_result[i]) + "Actual_result:'\n'" +
                    str(Actual_result[i]) + ',' + str(datetime.datetime.now()))
                f.write(a + '\n')

        ##比较实际中间的统计值和预期中间的统计值是否相同
        Actual_result = Actual_result_all[1]
        Expected_result = Expected_result_all[1]
        s = len(Actual_result)
        for i in range(s):
            test_result = operator.eq(Expected_result[i], Actual_result[i])
            if test_result == True:
                f = codecs.open('contract_number.txt', 'a', 'utf-8')
                a = str(_users) + '\n' + str(
                    str(current_case) + '中间统计排名' + ': '
                    "is right " + str(datetime.datetime.now()))
                f.write(a + '\n')
            else:
                f = codecs.open('contract_number.txt', 'a', 'utf-8')
                a = str(_users) + '\n' + str(
                    str(current_case) + '中间统计排名' + ': '
                    "is wrong, expected_result:'\n'" +
                    str(Expected_result[i]) + "Actual_result:'\n'" +
                    str(Actual_result[i]) + ',' + str(datetime.datetime.now()))
                f.write(a + '\n')
            #
        #比较表格实际排名和预期排名是否相等
        Actual_result = Actual_result_all[2]
        Expected_result = Expected_result_all[0]
        s = len(Actual_result)
        for i in range(s):
            test_result = operator.eq(Expected_result[i], Actual_result[i])
            if test_result == True:
                f = codecs.open('contract_number.txt', 'a', 'utf-8')
                a = str(_users) + '\n' + str(
                    str(current_case) + '表格排名' + ': '
                    "is right " + str(datetime.datetime.now()))
                f.write(a + '\n')
            else:
                f = codecs.open('contract_number.txt', 'a', 'utf-8')
                a = str(_users) + '\n' + str(
                    str(current_case) + '表格排名' + ': '
                    "is wrong, expected_result:'\n'" +
                    str(Expected_result[i]) + "Actual_result:'\n'" +
                    str(Actual_result[i]) + ',' + str(datetime.datetime.now()))
                f.write(a + '\n')
Exemplo n.º 18
0
    def case_1(self):
        self.current_case = 'case 1'
        _login = login.Login()
        _login.login(self.userinfo_super['username'],
                     self.userinfo_super['password'],
                     self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _ContractsApproval = ContractsApproval.Approvals(
            self.cookie, self.csrf)
        _ContractsApproval.close_contract_approval()
        a = 0
        for userinfo in self.userinfo_list:
            _login.login(userinfo['username'], userinfo['password'],
                         userinfo['role'])
            self.cookie = _login.cookie
            self.csrf = _login.csrf
            _AddContract = AddContract.AddContract(self.cookie, self.csrf)
            _ContractsApproval = ContractsApproval.Approvals(
                self.cookie, self.csrf)
            _DeleteContracts = DeleteContract.DeleteContract(
                self.cookie, self.csrf)
            # contracts_list =_DeleteContracts.get_contract_ids()
            a = a + 1
            for i in range(6):
                q1 = a
                q2 = a
                p1 = 15 * (i + 1)
                p2 = 10 * (i + 1)
                if userinfo['username'] == '13799999999' and i >= 3:
                    # 添加合同
                    _AddContract.add_contracts_products_add(
                        sign_date=self.sign_date_list[i],
                        goods_id_list=[g1, g2],
                        quantity_list=[q1, q2],
                        price_list=[p1, p1],
                        approve_status='approved',
                        DepartmentId=1)
                    _AddContract.add_contracts_products_add(
                        sign_date=self.sign_date_list[i],
                        goods_id_list=[g3, g2],
                        quantity_list=[q2, q2],
                        price_list=[p2, p2],
                        approve_status='approved',
                        DepartmentId=1)
                    # #添加草稿
                    _AddContract.add_contracts_products_add(
                        sign_date=self.sign_date_list[i],
                        goods_id_list=[g1, g2],
                        quantity_list=[q1, q2],
                        price_list=[p1, p1],
                        approve_status='draft',
                        DepartmentId=1)
                else:
                    #添加合同
                    _AddContract.add_contracts_products_add(
                        sign_date=self.sign_date_list[i],
                        goods_id_list=[g1, g2],
                        quantity_list=[q1, q2],
                        price_list=[p1, p1],
                        approve_status='approved')
                    _AddContract.add_contracts_products_add(
                        sign_date=self.sign_date_list[i],
                        goods_id_list=[g3, g2],
                        quantity_list=[q2, q2],
                        price_list=[p2, p2],
                        approve_status='approved')
                    #添加草稿
                    _AddContract.add_contracts_products_add(
                        sign_date=self.sign_date_list[i],
                        goods_id_list=[g1, g2],
                        quantity_list=[q1, q1],
                        price_list=[p1, p1],
                        approve_status='draft')

        _login.login(self.userinfo_super['username'],
                     self.userinfo_super['password'],
                     self.userinfo_super['role'])
        self.cookie = _login.cookie
        self.csrf = _login.csrf
        _ContractsApproval = ContractsApproval.Approvals(
            self.cookie, self.csrf)
        _ContractsApproval.open_contract_approval()
        a = 0

        for userinfo in self.userinfo_list:
            _login.login(userinfo['username'], userinfo['password'],
                         userinfo['role'])
            print(userinfo['username'])
            self.cookie = _login.cookie
            self.csrf = _login.csrf
            _AddContract = AddContract.AddContract(self.cookie, self.csrf)
            _ContractsApproval = ContractsApproval.Approvals(
                self.cookie, self.csrf)
            a = a + 1
            for i in range(6):
                q1 = a
                q2 = a
                p1 = 15 * (i + 1)
                p2 = 10 * (i + 1)
                if userinfo['username'] == '13799999999' and i >= 3:
                    # 待审批的合同
                    _AddContract.add_contracts_products_add(
                        sign_date=self.sign_date_list[i],
                        goods_id_list=[g1, g1],
                        quantity_list=[q1, q1],
                        price_list=[p1, p1],
                        approve_status='applying',
                        DepartmentId=1)
                    # 审批通过的合同
                    _ContractsApproval.verify_contracts(
                        _AddContract.add_contracts_products_add(
                            sign_date=self.sign_date_list[i],
                            goods_id_list=[g1, g3],
                            quantity_list=[q1, q1],
                            price_list=[p1, p1],
                            approve_status='approved',
                            DepartmentId=1))
                    _ContractsApproval.verify_contracts(
                        _AddContract.add_contracts_products_add(
                            sign_date=self.sign_date_list[i],
                            goods_id_list=[g3, g2],
                            quantity_list=[q1, q2],
                            price_list=[p1, p2],
                            approve_status='approved',
                            DepartmentId=1))
                    # # 审批通过后否决
                    contracts_id = _AddContract.add_contracts_products_add(
                        sign_date=self.sign_date_list[i],
                        goods_id_list=[g1, g1],
                        quantity_list=[q1, q1],
                        price_list=[p1, p1],
                        approve_status='applying',
                        DepartmentId=1)
                    _ContractsApproval.verify_contracts(contracts_id)
                    _ContractsApproval.deny_contracts(contracts_id)
                    # 审批否决的合同
                    _ContractsApproval.deny_contracts(
                        _AddContract.add_contracts_products_add(
                            sign_date=self.sign_date_list[i],
                            goods_id_list=[g1, g3],
                            quantity_list=[q1, q1],
                            price_list=[p1, p1],
                            approve_status='applying',
                            DepartmentId=1))
                    # 合同撤销
                    _ContractsApproval.cancel_contracts(
                        _AddContract.add_contracts_products_add(
                            sign_date=self.sign_date_list[i],
                            goods_id_list=[g1, g2],
                            quantity_list=[q1, q1],
                            price_list=[p1, p1],
                            approve_status='applying',
                            DepartmentId=1))

                else:
                    # 待审批的合同
                    _AddContract.add_contracts_products_add(
                        sign_date=self.sign_date_list[i],
                        goods_id_list=[g1, g2],
                        quantity_list=[q1, q1],
                        price_list=[p1, p1],
                        approve_status='applying')
                    # 审批通过的合同
                    _ContractsApproval.verify_contracts(
                        _AddContract.add_contracts_products_add(
                            sign_date=self.sign_date_list[i],
                            goods_id_list=[g1, g3],
                            quantity_list=[q1, q2],
                            price_list=[p1, p2],
                            approve_status='approved'))
                    _ContractsApproval.verify_contracts(
                        _AddContract.add_contracts_products_add(
                            sign_date=self.sign_date_list[i],
                            goods_id_list=[g3, g2],
                            quantity_list=[q1, q2],
                            price_list=[p1, p2],
                            approve_status='approved'))
                    # 审批通过后否决
                    contracts_id = _AddContract.add_contracts_products_add(
                        sign_date=self.sign_date_list[i],
                        goods_id_list=[g1, g2],
                        quantity_list=[q1, q1],
                        price_list=[p1, p1],
                        approve_status='applying')
                    _ContractsApproval.verify_contracts(contracts_id)
                    _ContractsApproval.deny_contracts(contracts_id)
                    # 审批否决的合同
                    _ContractsApproval.deny_contracts(
                        _AddContract.add_contracts_products_add(
                            sign_date=self.sign_date_list[i],
                            goods_id_list=[g1, g3],
                            quantity_list=[q1, q1],
                            price_list=[p1, p1],
                            approve_status='applying'))
                    # 合同撤销
                    _ContractsApproval.cancel_contracts(
                        _AddContract.add_contracts_products_add(
                            sign_date=self.sign_date_list[i],
                            goods_id_list=[g1, g2],
                            quantity_list=[q1, q2],
                            price_list=[p1, p2],
                            approve_status='applying'))