How to use is_capable method in avocado

Best Python code snippet using avocado_python

test_store_capabilities.py

Source:test_store_capabilities.py Github

copy

Full Screen

...34 self.assertEqual('op_checker', self.store.get.__name__)35 self.assertEqual('op_checker', self.store.delete.__name__)36class TestStoreCapabilities(base.StoreBaseTest):37 def _verify_store_capabilities(self, store):38 # This function tested is_capable() as well.39 self.assertTrue(store.is_capable(caps.BitMasks.READ_RANDOM))40 self.assertTrue(store.is_capable(caps.BitMasks.DRIVER_REUSABLE))41 self.assertFalse(store.is_capable(caps.BitMasks.WRITE_ACCESS))42 def test_static_capabilities_setup(self):43 self._verify_store_capabilities(FakeStoreWithStaticCapabilities())44 def test_dynamic_capabilities_setup(self):45 self._verify_store_capabilities(FakeStoreWithDynamicCapabilities())46 def test_mixed_capabilities_setup(self):47 self._verify_store_capabilities(FakeStoreWithMixedCapabilities())48 def test_set_unset_capabilities(self):49 store = FakeStoreWithStaticCapabilities()50 self.assertFalse(store.is_capable(caps.BitMasks.WRITE_ACCESS))51 # Set and unset single capability on one time52 store.set_capabilities(caps.BitMasks.WRITE_ACCESS)53 self.assertTrue(store.is_capable(caps.BitMasks.WRITE_ACCESS))54 store.unset_capabilities(caps.BitMasks.WRITE_ACCESS)55 self.assertFalse(store.is_capable(caps.BitMasks.WRITE_ACCESS))56 # Set and unset multiple capabilities on one time57 cap_list = [caps.BitMasks.WRITE_ACCESS, caps.BitMasks.WRITE_OFFSET]58 store.set_capabilities(*cap_list)59 self.assertTrue(store.is_capable(*cap_list))60 store.unset_capabilities(*cap_list)61 self.assertFalse(store.is_capable(*cap_list))62 def test_store_capabilities_property(self):63 store1 = FakeStoreWithDynamicCapabilities()64 self.assertTrue(hasattr(store1, 'capabilities'))65 store2 = FakeStoreWithMixedCapabilities()66 self.assertEqual(store1.capabilities, store2.capabilities)67 def test_cascaded_unset_capabilities(self):68 # Test read capability69 store = FakeStoreWithMixedCapabilities()70 self._verify_store_capabilities(store)71 store.unset_capabilities(caps.BitMasks.READ_ACCESS)72 cap_list = [caps.BitMasks.READ_ACCESS, caps.BitMasks.READ_OFFSET,73 caps.BitMasks.READ_CHUNK, caps.BitMasks.READ_RANDOM]74 for cap in cap_list:75 # To make sure all of them are unsetted.76 self.assertFalse(store.is_capable(cap))77 self.assertTrue(store.is_capable(caps.BitMasks.DRIVER_REUSABLE))78 # Test write capability79 store = FakeStoreWithDynamicCapabilities(caps.BitMasks.WRITE_RANDOM,80 caps.BitMasks.DRIVER_REUSABLE)81 self.assertTrue(store.is_capable(caps.BitMasks.WRITE_RANDOM))82 self.assertTrue(store.is_capable(caps.BitMasks.DRIVER_REUSABLE))83 store.unset_capabilities(caps.BitMasks.WRITE_ACCESS)84 cap_list = [caps.BitMasks.WRITE_ACCESS, caps.BitMasks.WRITE_OFFSET,85 caps.BitMasks.WRITE_CHUNK, caps.BitMasks.WRITE_RANDOM]86 for cap in cap_list:87 # To make sure all of them are unsetted.88 self.assertFalse(store.is_capable(cap))89 self.assertTrue(store.is_capable(caps.BitMasks.DRIVER_REUSABLE))90class TestStoreCapabilityConstants(base.StoreBaseTest):91 def test_one_single_capability_own_one_bit(self):92 cap_list = [93 caps.BitMasks.READ_ACCESS,94 caps.BitMasks.WRITE_ACCESS,95 caps.BitMasks.DRIVER_REUSABLE,96 ]97 for cap in cap_list:98 self.assertEqual(1, bin(cap).count('1'))99 def test_combined_capability_bits(self):100 check = caps.StoreCapability.contains101 check(caps.BitMasks.READ_OFFSET, caps.BitMasks.READ_ACCESS)102 check(caps.BitMasks.READ_CHUNK, caps.BitMasks.READ_ACCESS)103 check(caps.BitMasks.READ_RANDOM, caps.BitMasks.READ_CHUNK)...

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 avocado 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