Best Python code snippet using tempest_python
test_create_group.py
Source:test_create_group.py
1import requests2import unittest3import json4from lib.case_log import *5import os6import sys7sys.path.append("../../..")8from config.config import *9from lib.read_excel import *10from lib.case_log import log_case_info11class TestCreateGroup(unittest.TestCase):12 @classmethod13 def setUpClass(cls): # æ´ä¸ªæµè¯ç±»åªæ§è¡ä¸æ¬¡14 cls.data_list = excel_to_list(os.path.join(data_path, "test_dop_data.xlsx"), "TestCreateGroup") # 读å该æµè¯ç±»ææç¨ä¾æ°æ®15 def test_create_Group_ture(self):16 case_data = get_test_data(self.data_list,"test_create_Group_ture") # ä»æ°æ®å表ä¸æ¥æ¾å°è¯¥ç¨ä¾æ°æ®17 if not case_data: # æå¯è½ä¸ºNone18 logging.error("ç¨ä¾æ°æ®ä¸åå¨")19 url = case_data.get('url') # excelä¸çæ é¢ä¹å¿
é¡»æ¯å°åurl20 data = case_data.get('data') #éè¦ç¨json.loads()转å为åå
¸æ ¼å¼21 expect_res = case_data.get('expect_res')22 res = requests.post(url=url,json=json.loads(data),headers=headers)23 log_case_info('test_create_Group_ture', url, data, expect_res, res.text)24 self.assertEqual(expect_res, res.text)25 def test_create_Group_duplication(self):26 case_data = get_test_data(self.data_list,"test_create_Group_duplication")27 if not case_data:28 logging.error("ç¨ä¾æ°æ®ä¸åå¨")29 url = case_data.get('url')30 data =case_data.get('data')31 expect_res = case_data.get('expect_res')32 res = requests.post(url=url, json=json.loads(data), headers=headers)33 log_case_info('test_create_Group_duplication', url, data, expect_res, res.text)34 self.assertEqual(expect_res, res.text)35 def test_delete_Group(self):36 case_data = get_test_data(self.data_list,"test_delete_Group")37 if not case_data:38 logging.error("ç¨ä¾æ°æ®ä¸åå¨")39 40if __name__ == '__main__':...
test_del_group.py
Source:test_del_group.py
...13# #Ñдаление 1 ÑлеменÑа ÑпиÑка14# old_groups[index:index+1] = []15# assert old_groups == new_groups16#17# def test_delete_group(app, db, check_ui):18# if len(db.get_group_list()) == 0:19# app.group.create(Group(name="test", header="header", footer="footer"))20# old_groups = db.get_group_list()21# group = random.choice(old_groups)22# app.group.delete_group_by_id(group.id)23# new_groups = db.get_group_list()24# assert len(old_groups) - 1 == len(new_groups)25# #Ñдаление 1 ÑлеменÑа ÑпиÑка26# old_groups.remove(group)27# assert old_groups == new_groups28# if check_ui:29# assert sorted(new_groups, key=Group.id_or_max) == sorted(app.group.get_group_list(), key=Group.id_or_max)30def test_delete_group(app, db, check_ui):31 if len(db.get_group_list()) == 0:32 app.group.create(Group(name="test", header="header", footer="footer"))33 old_groups = db.get_group_list()34 group = random.choice(old_groups)35 app.group.delete_group_by_id(group.id)36 new_groups = db.get_group_list()37 assert len(old_groups) - 1 == len(new_groups)38 #Ñдаление 1 ÑлеменÑа ÑпиÑка39 old_groups.remove(group)40 assert old_groups == new_groups41 if check_ui:...
group_scenarios.py
Source:group_scenarios.py
...3@scenario('groups.feature', 'Add new group')4def test_add_new_group():5 pass6@scenario('groups.feature', 'Delete a group')7def test_delete_group():...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!