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)
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)
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)
def test_c_do_all_attendance(self, url, post, data, status_code, expect): TodayAttendance(add_user_info3).do_all_attendance(url, data) sql = f'select count(teacher_id) from attendance where create_time like "{local_time}%"' db_result = Utility.query_one(add_user_info3, sql) print(db_result) if db_result[0] == 19: actual = 'test all attendance pass' else: actual = 'test all attendance fail' self.assertEqual(expect, actual)
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)
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": actual="test do morning exam pass" else: actual="test do morning exam fail" else: actual="test do morning exam fail" self.assertEqual(expect,actual)
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.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.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.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.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.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)