import unittest from woniuboss.lib.woniuboss_api.student_manage.phase_test import PhaseExam from parameterized import parameterized from woniuboss.tools.woniuboss_api.utility import Utility import time test_config_info = Utility.get_json( '..\\..\\conf\\woniuboss_api\\testdata_stu_manage.conf') # query_totalrow=Utility.get_excel_to_tuple(test_config_info[14]) do_test_info = Utility.get_excel_to_tuple(test_config_info[15]) do_down_grade_info = Utility.get_excel_to_tuple(test_config_info[16]) add_user_info = Utility.get_excel_to_user(test_config_info[16]) class TestPhaseTest(unittest.TestCase): @parameterized.expand(do_test_info) def test_a_do_phase(self, url, post, data, status_code, expect): sql1 = 'select count(*) from phase_exam' db_result1 = Utility.query_one(add_user_info, sql1) phase_resp = PhaseExam(add_user_info).click_do_phase(url, data) time.sleep(2) sql2 = 'select count(*) from phase_exam' db_result2 = Utility.query_one(add_user_info, sql2) if db_result2[0] - db_result1[0] == 1 and phase_resp.text == 'success': actual = 'test do test pass' else: actual = 'test do test fail' self.assertEqual(expect, actual) @parameterized.expand(do_down_grade_info) def test_b_down_grade(self, url, post, data, status_code, expect): resp1 = PhaseExam(add_user_info).query_totalrow()
from woniuboss.tools.woniuboss_api.utility import Utility import requests class Service: @classmethod def get_session(cls, base_info): #base_info = Utility.get_json('..\\conf\\base.conf') login_url = "%s://%s:%s/%s/" % (base_info['PROTOCOL'], base_info['HOSTNAME'], base_info['PORT'], base_info['AURL']) login_data = { "userName": base_info["USERNAME"], "userPass": base_info["PASSWORD"], "checkcode": base_info["VERIFYCODE"] } session = requests.session() resp = session.post(login_url, login_data) return session if __name__ == '__main__': test_config_info = Utility.get_json( '..\\..\\conf\\woniuboss_api\\testdata_stu_manage.conf') basicinfo_info = Utility.get_excel_to_tuple(test_config_info[0]) add_user_info = Utility.get_excel_to_user(test_config_info[0]) print(add_user_info) Service.get_session(add_user_info)
import unittest from woniuboss.lib.woniuboss_api.student_manage.basic_info import BasicInfo from woniuboss.tools.woniuboss_api.service import Service from parameterized import parameterized from woniuboss.tools.woniuboss_api.utility import Utility test_config_info=Utility.get_json('..\\..\\conf\\woniuboss_api\\testdata_stu_manage.conf') query_all_info = Utility.get_excel_to_tuple(test_config_info[0]) add_user_info1 = Utility.get_excel_to_user(test_config_info[0]) query_one_info = Utility.get_excel_to_tuple(test_config_info[1]) add_user_info2 = Utility.get_excel_to_user(test_config_info[1]) modify_student_info = Utility.get_excel_to_tuple(test_config_info[2]) add_user_info3 = Utility.get_excel_to_user(test_config_info[2]) # print(add_user_info3) class BasicInfoTest(unittest.TestCase): @parameterized.expand(query_all_info) def test_a_query_all(self,url,post,data,status_code,expect): sql='select count(*) from student' db_num=Utility.query_one(add_user_info1,sql) query_all_resp=BasicInfo(add_user_info1).query_all_student(url,data) query_all_resp_totalrow=query_all_resp.json()['totalRow'] if db_num[0]==query_all_resp_totalrow: actual="query all pass" else: actual="query all fail" self.assertEqual(expect,actual) @parameterized.expand(query_one_info) def test_b_view_one_student(self, url, post, data, status_code, expect): view_one_student_resp=BasicInfo(add_user_info2).view_one_student(url,data) resp_text=view_one_student_resp.text # print(resp_text)
from parameterized import parameterized import unittest from woniuboss.lib.woniuboss_api.login.login import Login from woniuboss.tools.woniuboss_api.service import Service from woniuboss.tools.woniuboss_api.utility import Utility #在该页面调试时test_config_info里需要多加一层跳出"..\\",testdata也需要多加一层 #准备数据 test_config_info=Utility.get_json('..\\..\\conf\\woniuboss_api\\testdata_login.conf') login_info = Utility.get_excel_to_tuple(test_config_info[0]) add_user_info = Utility.get_excel_to_user(test_config_info[0]) modify_passwd_info=Utility.get_excel_to_tuple(test_config_info[1]) add_user_info1 = Utility.get_user_to_dict(test_config_info[1]) modify_user_info=Utility.get_excel_to_user(test_config_info[1]) decrypt_info=Utility.get_excel_to_tuple(test_config_info[2]) add_user_info2 = Utility.get_user_to_dict(test_config_info[2]) decrypt_user_info=Utility.get_excel_to_user(test_config_info[2]) # ('http://192.168.75.128:8080/WoniuBoss2.5/user/login', 'POST', {'username': '******', 'password': '******', 'verifycode': '0000'}, 200, 'login-pass'), #login_info中[]的需要参照上面选取 class LoginTest(unittest.TestCase): # # 获取测试数据配置 # def __init__(self): # # self.data_config_info = add_user_info @parameterized.expand(login_info) def test_login(self,url,post,data,status_code,expect): login_resp = Login(add_user_info).do_login(url,data)
import urllib from parameterized import parameterized import unittest from woniuboss.lib.woniuboss_api.employment_management.employment_management import EmploymentManagement from woniuboss.tools.woniuboss_api.utility import Utility from urllib import parse,request # 在该页面调试时test_config_info里需要多加一层跳出"..\\",testdata也需要多加一层 # 准备数据 test_config_info=Utility.get_json('..\\..\\conf\\woniuboss_api\\EM\\testdata.conf') em_page_info = Utility.get_excel_to_tuple(test_config_info[0]) em_all_info = Utility.get_excel_to_tuple(test_config_info[1]) em_through_info = Utility.get_excel_to_tuple(test_config_info[2]) em_not_through_info = Utility.get_excel_to_tuple(test_config_info[3]) em_search_info = Utility.get_excel_to_tuple(test_config_info[4]) em_real_info = Utility.get_excel_to_tuple(test_config_info[5]) em_induction_info = Utility.get_excel_to_tuple(test_config_info[6]) em_technology_info = Utility.get_excel_to_tuple(test_config_info[7]) em_submit_info = Utility.get_excel_to_tuple(test_config_info[8]) em_simulation_info = Utility.get_excel_to_tuple(test_config_info[9]) # ('http://192.168.75.128:8080/WoniuBoss2.5/user/login', 'POST', # {'username': '******', 'password': '******', 'verifycode': '0000'}, 200, 'employment_management-pass'), # login_info中[]的需要参照上面选取 class EmploymentManagementTest(unittest.TestCase): def setUp(self): print("test start")
import unittest from woniuboss.lib.woniuboss_api.corporate_customers.corporate_customers import CorporateCustomers from parameterized import parameterized from woniuboss.tools.woniuboss_api.utility import Utility test_config_info = Utility.get_json( '..\\..\\conf\\woniuboss_api\\testdata_corporate_customers.conf') query_enterprise_info = Utility.get_excel_to_tuple(test_config_info[0]) add_enterprise_info = Utility.get_excel_to_tuple(test_config_info[1]) modify_enterprise_info = Utility.get_excel_to_tuple(test_config_info[2]) add_user_info = Utility.get_excel_to_user(test_config_info[1]) class TestCorporateCustomers(unittest.TestCase): @parameterized.expand(query_enterprise_info) def test_query_cor_cus(self, url, post, data, status_code, expect): sql = 'select count(enterprise_id) from enterprise_info' query_cor_cus_resp = CorporateCustomers( add_user_info).query_corporate_customer(url, data) db_result = Utility.query_one(add_user_info, sql) if db_result[0] == query_cor_cus_resp.json()['totalRow']: actual = 'test query corporate customers pass' else: actual = 'test query corporate customers fail' self.assertEqual(expect, actual) @parameterized.expand(add_enterprise_info) def test_add_cor_cus(self, url, post, data, status_code, expect): sql = 'select count(enterprise_id) from enterprise_info' db_result1 = Utility.query_one(add_user_info, sql) add_cor_cus_resp = CorporateCustomers(
import unittest from woniuboss.lib.woniuboss_api.student_manage.course_manage import CourseManage from parameterized import parameterized from woniuboss.tools.woniuboss_api.utility import Utility import time test_config_info = Utility.get_json( '..\\..\\conf\\woniuboss_api\\testdata_stu_manage.conf') add_course_schedule_info = Utility.get_excel_to_tuple(test_config_info[20]) add_user_info = Utility.get_excel_to_user(test_config_info[20]) modify_course_schedule_info = Utility.get_excel_to_tuple(test_config_info[21]) class TestCourseManage(unittest.TestCase): @parameterized.expand(add_course_schedule_info) def test_add_course_schedule(self, url, post, data, status_code, expect): sql1 = 'select count(*) from curriculum_schedule' db_result1 = Utility.query_one(add_user_info, sql1) add_course_schedule_resp = CourseManage( add_user_info).add_course_schedule(url, data) time.sleep(2) sql2 = 'select count(*) from curriculum_schedule' db_result2 = Utility.query_one(add_user_info, sql2) db_result = db_result2[0] - db_result1[0] result = add_course_schedule_resp.text if result == 'success' and db_result == 1: actual = 'test add course schedule pass' elif result == '保存失败.': actual = 'test add course schedule fail' else: actual = 'test add course schedule fail'
import unittest from woniuboss.lib.woniuboss_api.student_manage.class_manage import ClassManage from parameterized import parameterized from woniuboss.tools.woniuboss_api.utility import Utility test_config_info = Utility.get_json( '..\\..\\conf\\woniuboss_api\\testdata_stu_manage.conf') click_class_manage_info = Utility.get_excel_to_tuple(test_config_info[18]) add_user_info = Utility.get_excel_to_user(test_config_info[18]) separate_class_info = Utility.get_excel_to_tuple(test_config_info[19]) class TestClassManage(unittest.TestCase): @parameterized.expand(click_class_manage_info) def test_click_class_manage(self, url, post, data, status_code, expect): click_class_manage_resp = ClassManage( add_user_info).click_class_manage(url, data) if click_class_manage_resp.json()['totalRow'] == 19: actual = 'test query class manage pass' else: actual = 'test query class manage fail' self.assertEqual(expect, actual) @parameterized.expand(separate_class_info) def test_separate_class(self, url, post, data, status_code, expect): separate_class_resp = ClassManage(add_user_info).separate_class( url, data) if separate_class_resp.text == '处理完毕.': actual = 'test separate class pass' else: actual = 'test separate class fail' self.assertEqual(expect, actual)
import unittest from woniuboss.lib.woniuboss_api.student_manage.morning_exam_record import MorningExamRecord from parameterized import parameterized from woniuboss.tools.woniuboss_api.utility import Utility test_config_info = Utility.get_json( '..\\..\\conf\\woniuboss_api\\testdata_stu_manage.conf') click_exam_morning_record_info = Utility.get_excel_to_tuple( test_config_info[13]) add_user_info = Utility.get_excel_to_user(test_config_info[13]) class TestMorningExamRecord(unittest.TestCase): @parameterized.expand(click_exam_morning_record_info) def test_click_exam_morning_record(self, url, post, data, status_code, expect): click_exam_morning_record_resp = MorningExamRecord( add_user_info).click_morning_exam_record(url, data) result = click_exam_morning_record_resp.json()['totalRow'] if result == 19: actual = 'query morning record pass' else: actual = 'query morning record fail' self.assertEqual(expect, actual) if __name__ == '__main__': unittest.main(verbosity=2)
import unittest from woniuboss.lib.woniuboss_api.student_manage.take_leave import TakeLeave from parameterized import parameterized from woniuboss.tools.woniuboss_api.utility import Utility test_config_info = Utility.get_json( '..\\..\\conf\\woniuboss_api\\testdata_stu_manage.conf') query_take_leave_info = Utility.get_excel_to_tuple(test_config_info[8]) add_user_info = Utility.get_excel_to_user(test_config_info[8]) add_take_leave_info = Utility.get_excel_to_tuple(test_config_info[9]) modify_take_leave_info = Utility.get_excel_to_tuple(test_config_info[10]) upload_leave_permit_info = Utility.get_excel_to_tuple(test_config_info[11]) write_off_info = Utility.get_excel_to_tuple(test_config_info[12]) class TestTakeLeave(unittest.TestCase): @parameterized.expand(query_take_leave_info) def test_a_query_take_leave(self, url, post, data, status_code, expect): sql = 'select count(*) from student_leave where create_time >"2020-03-01" and leave_status="请假中"' db_result = Utility.query_one(add_user_info, sql) query_take_leave_resp = TakeLeave( add_user_info).query_take_leave_student(url, data) resp_totalrow = query_take_leave_resp.json()['totalRow'] if db_result[0] == resp_totalrow: actual = 'query take leave pass' else: actual = 'query take leave fail' self.assertEqual(expect, actual) @parameterized.expand(add_take_leave_info) def test_b_add_take_leave(self, url, post, data, status_code, expect): add_take_leave_resp = TakeLeave(add_user_info).add_take_leave(
import unittest from woniuboss.lib.woniuboss_api.student_manage.evaluation_record import EvaluationRecord from parameterized import parameterized from woniuboss.tools.woniuboss_api.utility import Utility test_config_info=Utility.get_json('..\\..\\conf\\woniuboss_api\\testdata_stu_manage.conf') query_eval_record_info=Utility.get_excel_to_tuple(test_config_info[17]) add_user_info = Utility.get_excel_to_user(test_config_info[17]) class TestEvaluationRecord(unittest.TestCase): @parameterized.expand(query_eval_record_info) def test_query_eval_record(self,url,post,data,status_code,expect): teacherid=add_user_info['USERNAME'] sql=f'select count(*) from phase_exam where operator_id="{teacherid}"' db_result=Utility.query_one(add_user_info,sql) eval_record_resp=EvaluationRecord(add_user_info).query_record_num(url,data) page_totalrow=eval_record_resp.json()['totalRow'] if db_result[0]==page_totalrow: actual='test query evaluation record pass' else: actual = 'test query evaluation record fail' self.assertEqual(expect,actual) if __name__ == '__main__': unittest.main(verbosity=2)
import unittest from woniuboss.lib.woniuboss_api.student_manage.today_morning_exam import TodayMorningExam from parameterized import parameterized from woniuboss.tools.woniuboss_api.utility import Utility test_config_info=Utility.get_json('..\\..\\conf\\woniuboss_api\\testdata_stu_manage.conf') query_student_info=Utility.get_excel_to_tuple(test_config_info[6]) add_user_info1 = Utility.get_excel_to_user(test_config_info[6]) do_morning_exam_info = Utility.get_excel_to_tuple(test_config_info[7]) add_user_info2 = Utility.get_excel_to_user(test_config_info[7]) class TestTodayMorningExam(unittest.TestCase): @parameterized.expand(query_student_info) def test_a_query_student(self,url,post,data,status_code,expect): query_student_resp=TodayMorningExam(add_user_info1).query_all_student(url,data) real=query_student_resp.json()['totalRow'] if real==19: actual='test query morning exam student pass' else: actual = 'test query morning exam student fail' self.assertEqual(expect,actual) @parameterized.expand(do_morning_exam_info) def test_b_do_moring_exam(self,url,post,data,status_code,expect): do_morning_exam_resp=TodayMorningExam(add_user_info2).do_morning_exam(url,data) import time local_time = time.strftime('%Y-%m-%d', time.localtime(time.time())) db_id=data['me.morn_exam_student_id'] sql=f'select * from morn_exam where morn_exam_student_id="{db_id}" and create_time like "{local_time}%"' db_result=Utility.query_one(add_user_info2,sql) if db_result: if do_morning_exam_resp.text=="success":
from parameterized import parameterized import unittest from woniuboss.lib.woniuboss_api.financial_management.financial_management import FinancialManagement from woniuboss.tools.woniuboss_api.utility import Utility # 在该页面调试时test_config_info里需要多加一层跳出"..\\",testdata也需要多加一层 # 准备数据 test_config_info=Utility.get_json('..\\..\\conf\\woniuboss_api\\FM\\testdata.conf') fm_page_info = Utility.get_excel_to_tuple(test_config_info[0]) fm_last_info = Utility.get_excel_to_tuple(test_config_info[1]) fm_this_info = Utility.get_excel_to_tuple(test_config_info[2]) fm_new_info = Utility.get_excel_to_tuple(test_config_info[3]) fm_modify_info = Utility.get_excel_to_tuple(test_config_info[4]) fm_pay_info = Utility.get_excel_to_tuple(test_config_info[5]) fm_refund_info = Utility.get_excel_to_tuple(test_config_info[6]) # ('http://192.168.75.128:8080/WoniuBoss2.5/user/login', 'POST', # {'username': '******', 'password': '******', 'verifycode': '0000'}, 200, 'employment_management-pass'), # login_info中[]的需要参照上面选取 class FinancialManagementTest(unittest.TestCase): def setUp(self): print("test start") def tearDown(self): print("test end") @parameterized.expand(fm_page_info) def test_fm_page(self, url, action, data, code, expect): # FM_001
#!/usr/bin/env python # -*- coding: utf-8 -*- from parameterized import parameterized import unittest from woniuboss.lib.woniuboss_api.administrative_management.administrative_management import AdministrativeManagement from woniuboss.tools.woniuboss_api.utility import Utility from urllib import parse, request # 在该页面调试时test_config_info里需要多加一层跳出"..\\",testdata也需要多加一层 # 准备数据 test_config_info=Utility.get_json('..\\..\\conf\\woniuboss_api\\AM\\testdata.conf') am_page_info = Utility.get_excel_to_tuple(test_config_info[0]) # ('http://192.168.75.128:8080/WoniuBoss2.5/user/login', 'POST', # {'username': '******', 'password': '******', 'verifycode': '0000'}, 200, 'employment_management-pass'), # login_info中[]的需要参照上面选取 class AdministrativeManagementTest(unittest.TestCase): def setUp(self): print("test start") def tearDown(self): print("test end") @parameterized.expand(am_page_info) # AM_001 def test_am_page(self, url, action, data, code, expect): am_page_url = f'{url}' am_page_resp = AdministrativeManagement().do_am_page(am_page_url)
from parameterized import parameterized import unittest from woniuboss.lib.woniuboss_api.personnel_management.personnel_management import PersonnelManagement from woniuboss.tools.woniuboss_api.utility import Utility # 在该页面调试时test_config_info里需要多加一层跳出"..\\",testdata也需要多加一层 # 准备数据 test_config_info = Utility.get_json( '..\\..\\conf\\woniuboss_api\\PM\\testdata.conf') pm_page_info = Utility.get_excel_to_tuple(test_config_info[0]) pm_new_info = Utility.get_excel_to_tuple(test_config_info[1]) pm_modify_info = Utility.get_excel_to_tuple(test_config_info[2]) # ('http://192.168.75.128:8080/WoniuBoss2.5/user/login', 'POST', # {'username': '******', 'password': '******', 'verifycode': '0000'}, 200, 'employment_management-pass'), # login_info中[]的需要参照上面选取 class PersonnelManagementTest(unittest.TestCase): def setUp(self): print("test start") def tearDown(self): print("test end") @parameterized.expand(pm_page_info) # PM_001 def test_pm_page(self, url, action, data, code, expect): pm_page_url = f'{url}' pm_page_resp = PersonnelManagement().do_pm_query(pm_page_url, data) pm_page_code = pm_page_resp.status_code if pm_page_code == code: actual = 'PM-succeed'
import unittest from woniuboss.lib.woniuboss_api.student_manage.today_attendance import TodayAttendance from parameterized import parameterized from woniuboss.tools.woniuboss_api.utility import Utility test_config_info = Utility.get_json( '..\\..\\conf\\woniuboss_api\\testdata_stu_manage.conf') do_one_attendance_info = Utility.get_excel_to_tuple(test_config_info[3]) add_user_info1 = Utility.get_excel_to_user(test_config_info[3]) search_student_information = Utility.get_excel_to_tuple(test_config_info[4]) add_user_info2 = Utility.get_excel_to_user(test_config_info[4]) do_all_attendance_info = Utility.get_excel_to_tuple(test_config_info[5]) add_user_info3 = Utility.get_excel_to_user(test_config_info[5]) import time local_time = time.strftime('%Y-%m-%d', time.localtime(time.time())) class TestTodayAttendance(unittest.TestCase): @parameterized.expand(do_one_attendance_info) def test_a_do_one_attendance(self, url, post, data, status_code, expect): one_data = data['value'] print(one_data) str_id, str_status = one_data.split('_') sql = f'select result from attendance where attendance_student_id={str_id} and update_time like "{local_time}%"' TodayAttendance(add_user_info1).do_one_attendance(url, data) db_result = Utility.query_one(add_user_info1, sql) print(db_result) if db_result[0] == str_status: actual = 'test one attendance pass' else: actual = 'test one attendance fail' self.assertEqual(expect, actual)