コード例 #1
0
 def get_driver(cls, path):
     contents = Utility.get_json(path)
     from selenium import webdriver
     driver = getattr(webdriver, contents['BROWSER'])()
     driver.implicitly_wait(10)
     driver.maximize_window()
     return driver
コード例 #2
0
 def test_query_one(self):
     self.turn.resource_turn_query_one()
     sql = 'select count(*) from customer'
     result = Utility.query_one('../config/base.conf', sql)
     print(result)
     if result[0] == 27:
         actual = 'query-pass'
     else:
         actual = 'query-fail'
     self.assertEqual(actual, 'query-pass')
コード例 #3
0
 def get_session(cls, sum):
     base_info = Utility.get_json('..\\config\\base.conf')
     login_url = "%s://%s:%s/%s/" % (
         base_info['PROTOCOL'],
         base_info['HOSTNAME'],
         base_info['PORT'],
         base_info['AURL'],
     )
     # print(login_url)
     base_data = Utility.get_json('..\\config\\Account.conf')
     login_data = {
         'userName': base_data[sum]['userName'],
         'userPass': base_data[sum]['userPass'],
         'checkcode': base_data[sum]['checkcode']
     }
     # print(login_data)
     session = requests.session()
     resp = session.post(login_url, login_data)
     # print(resp.text)
     return session
コード例 #4
0
 def test_alloacation_query_three(self, name):
     self.allocation.allocation_query_three(name)
     sql = 'select count(*) from customer where name="%s"' % name
     result = Utility.query_one('../config/base.conf', sql)
     try:
         if result[0] == 1:
             actual = 'query-pass'
         else:
             actual = 'query-fail'
         self.assertEqual(actual, 'query-pass')
     except Exception:
         raise Exception
コード例 #5
0
 def test_alloacation_query_two(self):
     self.allocation.allocation_query_two()
     sql = 'select count(source) from customer where work_id="0"'
     result = Utility.query_one('../config/base.conf', sql)
     try:
         if result[0] == 8:
             actual = 'query-pass'
         else:
             actual = 'query-fail'
         self.assertEqual(actual, 'query-pass')
     except Exception:
         raise Exception
コード例 #6
0
 def test_a_entry_sigle_phase_exam(self, class_name, score, phase, comment,
                                   expect):
     self.phase_exam.do_entry_sigle_phase_exam(class_name, score, phase,
                                               comment)
     if Service.is_element_present(
             self.driver, By.CSS_SELECTOR,
             'body > div.bootbox.modal.fade.mydialog.in > '
             'div > div'):
         actual = 'test import sigle phase exam fail'
         self.driver.refresh()
     else:
         ele = self.driver.find_element_by_css_selector(
             '#pe-result > tbody > tr:nth-child(1) > '
             'td:nth-child(9) > button')
         attr = ele.get_attribute('onclick')
         attr_dict = attr.split('(')[1].split(')')[0]
         import json
         dict_attr = json.loads(attr_dict, encoding='utf-8')
         student_id = dict_attr['student_id']
         phase1_score = dict_attr['phase1']
         phase2_score = dict_attr['phase2']
         phase3_score = dict_attr['phase3']
         phase4_score = dict_attr['phase4']
         sql = f"select score from phase_exam where phase_exam_student_id ='{student_id}' and phase_exam_class_id = '1' order by phase asc"
         db_result = Utility.query_all('../config/base.conf', sql)
         num = len(db_result)
         if num == 1:
             if float(db_result[0][0]) == float(phase1_score):
                 actual = 'test import sigle phase exam pass'
             else:
                 actual = 'test import sigle phase exam fail'
         elif num == 2:
             if float(db_result[0][0]) == float(phase1_score) and float(
                     db_result[1][0]) == float(phase2_score):
                 actual = 'test import sigle phase exam pass'
             else:
                 actual = 'test import sigle phase exam fail'
         elif num == 3:
             if float(db_result[0][0]) == float(phase1_score) and float(db_result[1][0]) == float(phase2_score) and \
                     float(db_result[2][0]) == float(phase3_score):
                 actual = 'test import sigle phase exam pass'
             else:
                 actual = 'test import sigle phase exam fail'
         elif num == 4:
             if float(db_result[0][0]) == float(phase1_score) and float(db_result[1][0]) == float(phase2_score) and float(db_result[2][0]) == float(phase3_score)\
                      and float(db_result[3][0]) == float(phase4_score):
                 actual = 'test import sigle phase exam pass'
             else:
                 actual = 'test import sigle phase exam fail'
         else:
             actual = 'test import sigle phase exam fail'
     self.assertEqual(expect, actual)
コード例 #7
0
 def test_query_two(self):
     self.turn.resource_turn_query_two()
     sql = 'select count(*) from customer where name="huhu"'
     result = Utility.query_one('../config/base.conf', sql)
     print(result)
     try:
         if self.driver.find_element_by_xpath('//table[@id="transmit-table"]/tbody/tr[1]/td[2]').text == 'huhu' \
                 and result[0] == 1:
             actual = 'query-pass'
         else:
             actual = 'query-fail'
         self.assertEqual(actual, 'turn-pass')
     except Exception:
         raise Exception
コード例 #8
0
 def miss_login(cls, driver, base_config_path):
     cls.open_page(driver, base_config_path)
     # 通过字典方式传递cookie信息
     contents = Utility.get_json(base_config_path)
     driver.add_cookie({
         'name': 'JSESSIONID',
         'value': contents['JSESSIONID']
     })
     driver.add_cookie({
         'name': 'rememberMe',
         'value': contents['rememberMe']
     })
     time.sleep(2)
     cls.open_page(driver, base_config_path)
コード例 #9
0
from WoniuBoss4.lib.resource_allocation import ResourceAllocation
from WoniuBoss4.tools.utility import Utility
from WoniuBoss4.tools.service import Service
from parameterized import parameterized
import unittest
import time

# 获取测试数据
resource_allocation_datas = Utility.get_json("../config/testdata.conf")
resource_allocation_query = Utility.get_excel_GUI_tuple(resource_allocation_datas[6])


class TestResourceTrain(unittest.TestCase):

    def setUp(self):
        print('test start')
        self.driver = Service.get_driver('../config/base.conf')
        Service.miss_login(self.driver, '../config/base.conf')
        self.driver.find_element_by_link_text(u'资源管理').click()
        self.allocation = ResourceAllocation(self.driver)

    def tearDown(self):
        print('test over')
        time.sleep(2)
        self.driver.quit()

    def test_alloacation_query_one(self):
        self.allocation.allocation_query_one()
        sql = 'select count(work_id) from customer'
        result = Utility.query_one('../config/base.conf', sql)
        try:
コード例 #10
0
 def open_page(cls, driver, path):
     contents = Utility.get_json(path)
     URL = '%s://%s:%s/%s' % (contents['PROTOCOL'], contents['HOSTNAME'],
                              contents['PORT'], contents['AURL'])
     # print(URL)
     driver.get(URL)
コード例 #11
0
import time
from selenium.webdriver.common.by import By

import unittest

from parameterized import parameterized

from WoniuBoss4.lib.student_info import StudentInfo
from WoniuBoss4.tools.service import Service
from WoniuBoss4.tools.utility import Utility

test_config_info = Utility.get_json('../config/testdata.conf')
# search_stu_info = Utility.get_excel_GUI_tuple(test_config_info[1])

modify_stu_info = Utility.get_excel_GUI_tuple(test_config_info[2])


class StudentInfoTest(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.driver = Service.get_driver('../config/base.conf')
        cls.student_info = StudentInfo(cls.driver)

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()

    # @parameterized.expand(search_stu_info)
    # def test_a_serach_stu_info(cls, orien_name,class_name,status_name,stu_name,expect):
    #     cls.student_info.do_search_info(orien_name,class_name,status_name,stu_name)
    #     time.sleep(2)
コード例 #12
0
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from WoniuBoss4.lib.resource_public import ResourcePublic
from WoniuBoss4.tools.utility import Utility
from WoniuBoss4.tools.service import Service
from parameterized import parameterized
import unittest
import time

# 获取测试数据
resource_public_datas = Utility.get_json("../config/testdata.conf")
resource_public_query = Utility.get_excel_GUI_tuple(resource_public_datas[7])


class TestRePublic(unittest.TestCase):

    def setUp(self):
        print('test start')
        self.driver = Service.get_driver('../config/base.conf')
        Service.miss_login(self.driver, '../config/base.conf')
        self.driver.find_element_by_link_text(u'资源管理').click()
        self.public = ResourcePublic(self.driver)

    def tearDown(self):
        print('test over')
        time.sleep(2)
        self.driver.quit()

    def test_resource_public_query_one(self):
        self.public.public_resource_query_one()
        try:
コード例 #13
0
from selenium.webdriver.common.by import By
import unittest
from parameterized import parameterized
from WoniuBoss4.lib.pychase_exam import PhaseExam
from WoniuBoss4.tools.service import Service
from WoniuBoss4.tools.utility import Utility

test_config_info = Utility.get_json('../config/testdata.conf')
import_sigle_phase_info = Utility.get_excel_GUI_tuple(test_config_info[3])


class PhaseExamTest(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.driver = Service.get_driver('../config/base.conf')
        cls.phase_exam = PhaseExam(cls.driver)

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()

    @parameterized.expand(import_sigle_phase_info)
    def test_a_entry_sigle_phase_exam(self, class_name, score, phase, comment,
                                      expect):
        self.phase_exam.do_entry_sigle_phase_exam(class_name, score, phase,
                                                  comment)
        if Service.is_element_present(
                self.driver, By.CSS_SELECTOR,
                'body > div.bootbox.modal.fade.mydialog.in > '
                'div > div'):
            actual = 'test import sigle phase exam fail'