How to use list_app method in Airtest

Best Python code snippet using Airtest

test_file_storage.py

Source:test_file_storage.py Github

copy

Full Screen

1#!/usr/bin/python32"""unittest for filestorage"""3import unittest4import os5import json6from models.engine.file_storage import FileStorage7from models.base_model import BaseModel8from models.user import User9from models.place import Place10from models.state import State11from models.city import City12from models.amenity import Amenity13from models.review import Review14class TestFileStorage(unittest.TestCase):15 """class to test FileSTorage"""16 def test_class_variables(self):17 """class var test"""18 fs1 = FileStorage()19 list_app = []20 if os.path.exists('file.json'):21 os.remove('file.json')22 for exists in fs1.all().keys():23 list_app.append(fs1.all()[exists])24 for exists in list_app:25 del fs1.all()[exists.__class__.__name__ + '.' + exists.id]26 self.assertFalse(hasattr(FileStorage, '__file_path'))27 self.assertFalse(hasattr(FileStorage, '__objects'))28 self.assertFalse(hasattr(fs1, '__file_path'))29 self.assertFalse(hasattr(fs1, '__objects'))30 del fs131 if os.path.exists('file.json'):32 print('file still exists')33 os.remove('file.json')34 def test_all(self):35 """test all"""36 fs2 = FileStorage()37 list_app = []38 if os.path.exists('file.json'):39 os.remove('file.json')40 for exists in fs2.all().keys():41 list_app.append(fs2.all()[exists])42 for exists in list_app:43 del fs2.all()[exists.__class__.__name__ + '.' + exists.id]44 self.assertIsInstance(fs2.all(), dict)45 self.assertEqual(fs2.all(), {})46 bm1, bm2 = BaseModel(), BaseModel()47 fs2.new(bm1)48 fs2.new(bm2)49 self.assertEqual(fs2.all(), {'BaseModel.' + bm1.id : bm1,50 'BaseModel.' + bm2.id : bm2})51 del bm1, bm2, fs252 def test_new(self):53 """ test new """54 dic = {"id": "8d8b4200-z106-469d-aec9-70zae1224150",55 "__class__": "BaseModel",56 "updated_at": "2020-07-01T16:47:21.260793",57 "created_at": "2020-07-01T16:47:21.260752"}58 fs3 = FileStorage()59 list_app = []60 if os.path.exists('file.json'):61 os.remove('file.json')62 for exists in fs3.all().keys():63 list_app.append(fs3.all()[exists])64 for exists in list_app:65 del fs3.all()[exists.__class__.__name__ + '.' + exists.id]66 classes = [Amenity(**dic), BaseModel(**dic), City(**dic), Place(**dic),67 Review(**dic), State(**dic), User(**dic)]68 for cls in classes:69 fs3.new(cls)70 self.assertIn(cls.__class__.__name__ + '.' + cls.id,71 fs3.all())72 for cls in classes:73 name = cls.__class__.__name__74 self.assertTrue(name + '.' + cls.id in fs3.all().keys())75 for i in range(len(fs3.all().keys())):76 self.assertIn(fs3.all()[list(fs3.all().keys())[i]],77 classes)78 for exists in classes:79 del exists...

Full Screen

Full Screen

loop_p.py

Source:loop_p.py Github

copy

Full Screen

1class LOOP_FUNCTION():2 def FOR_LOOP_ADD(self,3 x_e,4 list_app=list):5 for x_s in x_e:6 try:7 list_app.append(x_s)8 except:9 pass10 def CX_FOR_LOOP_ADD(self,11 x_e,12 main_e,13 list_app=list,14 params=str):15 for x_s in x_e:16 try:17 list_app.append(main_e[x_s][params])18 except:19 pass20 def RANGE_FOR_LOOP_ADD(self,21 x_e,22 x_loop,23 list_app=list,24 x_list=list,25 params=str):26 for x_s in x_e:27 try:28 list_app.append(x_loop[x_list[x_s]][params])29 except:30 pass31 def TARGET_FOR_LOOP_ADD(self,32 x_e,33 x_loop,34 list_app=list,35 x_list=list,36 params=str,37 target=str):38 for x_s in x_e:39 try:40 list_app.append(x_loop[x_list[x_s]][params][target])41 except:42 pass434445class LOOP_OPS():46 def GET_LOOP():47 l_p = type("LOOP FUNCTIONS",48 (LOOP_FUNCTION,),49 {})50 loop_f = l_p() ...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful