How to use get_storage method in Airtest

Best Python code snippet using Airtest

test_account_db.py

Source:test_account_db.py Github

copy

Full Screen

...92 state.delete_account(INVALID_ADDRESS)93 with pytest.raises(ValidationError):94 state.account_has_code_or_nonce(INVALID_ADDRESS)95def test_storage(account_db):96 assert account_db.get_storage(ADDRESS, 0) == 097 account_db.set_storage(ADDRESS, 0, 123)98 assert account_db.get_storage(ADDRESS, 0) == 12399 assert account_db.get_storage(ADDRESS, 1) == 0100 assert account_db.get_storage(OTHER_ADDRESS, 0) == 0101def test_storage_deletion(account_db):102 account_db.set_storage(ADDRESS, 0, 123)103 account_db.set_storage(OTHER_ADDRESS, 1, 321)104 account_db.delete_storage(ADDRESS)105 assert account_db.get_storage(ADDRESS, 0) == 0106 assert account_db.get_storage(OTHER_ADDRESS, 1) == 321107def test_account_db_storage_root(account_db):108 """109 Make sure that pruning doesn't screw up addresses that temporarily share storage roots110 """111 account_db.set_storage(ADDRESS, 1, 2)112 account_db.set_storage(OTHER_ADDRESS, 1, 2)113 # both addresses will share the same root114 account_db.make_state_root()115 account_db.set_storage(ADDRESS, 3, 4)116 account_db.set_storage(OTHER_ADDRESS, 3, 5)117 # addresses will have different roots118 account_db.make_state_root()119 assert account_db.get_storage(ADDRESS, 1) == 2120 assert account_db.get_storage(OTHER_ADDRESS, 1) == 2121 assert account_db.get_storage(ADDRESS, 3) == 4122 assert account_db.get_storage(OTHER_ADDRESS, 3) == 5123 account_db.persist()124 assert account_db.get_storage(ADDRESS, 1) == 2125 assert account_db.get_storage(OTHER_ADDRESS, 1) == 2126 assert account_db.get_storage(ADDRESS, 3) == 4127 assert account_db.get_storage(OTHER_ADDRESS, 3) == 5128def test_account_db_update_then_make_root_then_read(account_db):129 assert account_db.get_storage(ADDRESS, 1) == 0130 account_db.set_storage(ADDRESS, 1, 2)131 assert account_db.get_storage(ADDRESS, 1) == 2132 account_db.make_state_root()133 assert account_db.get_storage(ADDRESS, 1) == 2134 account_db.persist()135 assert account_db.get_storage(ADDRESS, 1) == 2136def test_account_db_read_then_update_then_make_root_then_read(account_db):137 account_db.set_storage(ADDRESS, 1, 2)138 # must always explicitly make the root before persisting139 account_db.make_state_root()140 account_db.persist()141 # read out of a non-empty account, to build a read-cache trie142 assert account_db.get_storage(ADDRESS, 1) == 2143 account_db.set_storage(ADDRESS, 1, 3)144 assert account_db.get_storage(ADDRESS, 1) == 3145 account_db.make_state_root()146 assert account_db.get_storage(ADDRESS, 1) == 3147 account_db.persist()148 # if you start caching read tries, then you might get this answer wrong:...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...34 return iter(self.steps)35 def generate_steps(self, cart):36 self.cart = cart37 self.billing = BillingAddressStep(38 self.request, self.get_storage('billing'))39 self.steps.append(self.billing)40 if self.is_shipping_required():41 self.shipping = ShippingStep(42 self.request, self.get_storage('shipping'),43 self.cart, default_address=self.billing_address)44 self.steps.append(self.shipping)45 else:46 self.shipping = None47 summary_step = SummaryStep(48 self.request, self.get_storage('summary'), checkout=self)49 self.steps.append(summary_step)50 @property51 def anonymous_user_email(self):52 storage = self.get_storage('billing')53 return storage.get('anonymous_user_email')54 @anonymous_user_email.setter55 def anonymous_user_email(self, email):56 storage = self.get_storage('billing')57 storage['anonymous_user_email'] = email58 @anonymous_user_email.deleter59 def anonymous_user_email(self):60 storage = self.get_storage('billing')61 storage['anonymous_user_email'] = ''62 @property63 def billing_address(self):64 storage = self.get_storage('billing')65 address_data = storage.get('address', {})66 return Address(**address_data)67 @billing_address.setter68 def billing_address(self, address):69 storage = self.get_storage('billing')70 storage['address'] = address.as_data()71 @billing_address.deleter72 def billing_address(self):73 storage = self.get_storage('billing')74 storage['address'] = None75 @property76 def shipping_address(self):77 storage = self.get_storage('shipping')78 address_data = storage.get('address', {})79 return Address(**address_data)80 @shipping_address.setter81 def shipping_address(self, address):82 storage = self.get_storage('shipping')83 storage['address'] = address.as_data()84 @shipping_address.deleter85 def shipping_address(self):86 storage = self.get_storage('shipping')87 storage['address'] = None88 def get_storage(self, name):89 return self.storage[name]90 def get_total(self, **kwargs):91 zero = Price(0, currency=settings.DEFAULT_CURRENCY)92 total = sum(93 (total_with_delivery94 for delivery, delivery_cost, total_with_delivery95 in self.get_deliveries(**kwargs)),96 zero)97 return total98 def save(self):99 self.request.session[STORAGE_SESSION_KEY] = dict(self.storage)100 def clear_storage(self):101 del self.request.session[STORAGE_SESSION_KEY]102 self.cart.clear()...

Full Screen

Full Screen

storage.py

Source:storage.py Github

copy

Full Screen

...18 def setUp(self):19 self.testuser, created = User.objects.get_or_create(username='testuser1')20 def test_current_step(self):21 request = get_request()22 storage = self.get_storage()('wizard1', request, None)23 my_step = 224 self.assertEqual(storage.current_step, None)25 storage.current_step = my_step26 self.assertEqual(storage.current_step, my_step)27 storage.reset()28 self.assertEqual(storage.current_step, None)29 storage.current_step = my_step30 storage2 = self.get_storage()('wizard2', request, None)31 self.assertEqual(storage2.current_step, None)32 def test_step_data(self):33 request = get_request()34 storage = self.get_storage()('wizard1', request, None)35 step1 = 'start'36 step_data1 = {'field1': 'data1',37 'field2': 'data2',38 'field3': datetime.now(),39 'field4': self.testuser}40 self.assertEqual(storage.get_step_data(step1), None)41 storage.set_step_data(step1, step_data1)42 self.assertEqual(storage.get_step_data(step1), step_data1)43 storage.reset()44 self.assertEqual(storage.get_step_data(step1), None)45 storage.set_step_data(step1, step_data1)46 storage2 = self.get_storage()('wizard2', request, None)47 self.assertEqual(storage2.get_step_data(step1), None)48 def test_extra_context(self):49 request = get_request()50 storage = self.get_storage()('wizard1', request, None)51 extra_context = {'key1': 'data1',52 'key2': 'data2',53 'key3': datetime.now(),54 'key4': self.testuser}55 self.assertEqual(storage.extra_data, {})56 storage.extra_data = extra_context57 self.assertEqual(storage.extra_data, extra_context)58 storage.reset()59 self.assertEqual(storage.extra_data, {})60 storage.extra_data = extra_context61 storage2 = self.get_storage()('wizard2', request, None)62 self.assertEqual(storage2.extra_data, {})63 def test_extra_context_key_persistence(self):64 request = get_request()65 storage = self.get_storage()('wizard1', request, None)66 self.assertFalse('test' in storage.extra_data)67 storage.extra_data['test'] = True68 self.assertTrue('test' in storage.extra_data)69 def test_reset_deletes_tmp_files(self):70 request = get_request()71 storage = self.get_storage()('wizard1', request, temp_storage)72 step = 'start'73 file_ = SimpleUploadedFile('file.txt', b'content')74 storage.set_step_files(step, {'file': file_})75 with storage.get_step_files(step)['file'] as file:76 tmp_name = file.name77 self.assertTrue(storage.file_storage.exists(tmp_name))78 storage.reset()79 storage.update_response(HttpResponse())...

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