Best Python code snippet using autotest_python
test_user.py
Source:test_user.py
1# -*- coding: utf-8 -*-2# @Time : 2021/7/18 20:353# @Author : wkRonin4# @File :test_user.py5from faker import Faker6from wechatworkApi.api.user import User7class TestUser:8 def setup_class(self):9 self.user = User()10 self.fake = Faker('zh_CN')11 def test_add(self, get_unique_name):12 """13 æµè¯æ·»å æåæ¥å£14 :param get_unique_name: èªå®ä¹å称15 :return: æè¨æ·»å æåæ¯å¦æå以åæ·»å åæ¯å¦è½æ¥è¯¢å¾å°16 """17 name = self.fake.name()18 mobile = self.fake.phone_number()19 new_userid = self.user.add(get_unique_name, name, mobile, 1).json()20 assert new_userid.get("errcode") == 021 assert self.user.get(get_unique_name).json().get("errcode") == 022 def test_get(self, get_unique_name):23 """24 æµè¯æ¥è¯¢æåæ¥å£25 :param get_unique_name: èªå®ä¹å称26 :return: æè¨æ¯å¦è½æ¥è¯¢å°æ°å¢çæå27 """28 name = self.fake.name()29 mobile = self.fake.phone_number()30 self.user.add(get_unique_name, name, mobile, 1)31 assert self.user.get(get_unique_name).json().get("errcode") == 032 def test_delete(self, get_unique_name):33 """34 æµè¯å é¤æåæ¥å£35 :param get_unique_name: èªå®ä¹å称36 :return: æè¨å é¤æåæ¯å¦æå以åæ¥è¯¢æ¤æåè¿åçé误ç æ¯å¦ä¸ºæåä¸å¨ä¼ä¸ä¸çé误ç 37 """38 name = self.fake.name()39 mobile = self.fake.phone_number()40 self.user.add(get_unique_name, name, mobile, 1)41 assert self.user.delete(get_unique_name).json().get("errcode") == 042 assert self.user.userid_is_not_exist(get_unique_name)43 def test_update(self, get_unique_name):44 """45 æµè¯æ´æ°æåæ¥å£46 :param get_unique_name: èªå®ä¹å称47 :return: æè¨æåå§åæ¯å¦æ´æ°æå48 """49 name = self.fake.name()50 mobile = self.fake.phone_number()51 new_name = self.fake.name()52 self.user.add(get_unique_name, name, mobile, 1)...
test_premium_export_utils.py
Source:test_premium_export_utils.py
1from baserow_premium.export.utils import get_unique_name, safe_xml_tag_name, to_xml2def test_get_unique_name():3 assert get_unique_name({"name": ""}, "name") == "name_2"4 assert get_unique_name({"name": ""}, "name", separator=" ") == "name 2"5 assert get_unique_name({"name": "", "name_2": "", "name_4": ""}, "name") == "name_3"6 assert (7 get_unique_name({"name": "", "name_2": "", "name_3": "", "name_4": ""}, "name")8 == "name_5"9 )10 assert (11 get_unique_name({"name": "", "name_2": "", "name_3": "", "name_4": ""}, "else")12 == "else"13 )14def test_safe_xml_tag_name():15 assert safe_xml_tag_name("name") == "name"16 assert safe_xml_tag_name("/name<>") == "name"17 assert safe_xml_tag_name("/name<>test") == "name-test"18 assert safe_xml_tag_name("Test 1 // <> @#$$%&%*$^%&%") == "Test-1"19 assert safe_xml_tag_name("123") == "tag-123"20 assert safe_xml_tag_name("123", "prefix-") == "prefix-123"21 assert safe_xml_tag_name("/", "prefix-", "empty") == "empty"22def test_to_xml():23 xml = to_xml(24 {25 "name": "<value>",...
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!!