Best Python code snippet using lisa_python
test_disk_feature.py
Source:test_disk_feature.py
...9 # no disk in req, the cap get from lowest cost StandardHDDLRS. iops and10 # disk size11 req = features.AzureDiskOptionSettings()12 cap = self._get_default_cap()13 self._assert_disk(14 req,15 cap,16 data_disk_count=0,17 )18 def test_disk_type_overlap(self) -> None:19 # req and cap both have DiskPremiumSSDLRS, so it's selected20 req = features.AzureDiskOptionSettings(21 disk_type=search_space.SetSpace[schema.DiskType](22 items=[schema.DiskType.PremiumSSDLRS, schema.DiskType.StandardSSDLRS]23 )24 )25 cap = self._get_default_cap()26 self._assert_disk(27 req,28 cap,29 data_disk_count=0,30 disk_type=schema.DiskType.PremiumSSDLRS,31 data_disk_iops=120,32 data_disk_size=4,33 )34 def test_disk_type_no_common(self) -> None:35 # req and cap has no common disk type36 req = features.AzureDiskOptionSettings(37 disk_type=search_space.SetSpace[schema.DiskType](38 items=[schema.DiskType.StandardSSDLRS]39 )40 )41 cap = self._get_default_cap()42 reason = req.check(cap)43 self.assertFalse(reason.result)44 with self.assertRaises(LisaException) as cm:45 req.generate_min_capability(cap)46 self.assertIsInstance(cm.exception, LisaException)47 self.assertIn("capability doesn't support requirement", str(cm.exception))48 def test_disk_one_default_data_disk(self) -> None:49 # 1 data disk in req, no value, the cap get from lowest cost50 # StandardHDDLRS, iops and disk size51 req = features.AzureDiskOptionSettings(52 data_disk_count=1,53 )54 cap = self._get_default_cap()55 self._assert_disk(56 req,57 cap,58 )59 def test_disk_specify_caching_type(self) -> None:60 # the caching type is defined by req, not cap61 req = features.AzureDiskOptionSettings(62 data_disk_caching_type=constants.DATADISK_CACHING_TYPE_READYWRITE,63 data_disk_count=1,64 )65 cap = self._get_default_cap()66 self._assert_disk(67 req,68 cap,69 data_disk_caching_type=constants.DATADISK_CACHING_TYPE_READYWRITE,70 )71 def test_disk_specify_iops_min_to_biggest(self) -> None:72 # given a min iops value, which can may only the biggest value.73 req = features.AzureDiskOptionSettings(74 data_disk_count=1,75 data_disk_iops=search_space.IntRange(min=1800),76 )77 cap = self._get_default_cap()78 self._assert_disk(req, cap, data_disk_iops=2000, data_disk_size=16384)79 def test_disk_specify_iops_a_range(self) -> None:80 # given a range of iops, match min one in range81 req = features.AzureDiskOptionSettings(82 data_disk_count=1,83 disk_type=schema.DiskType.PremiumSSDLRS,84 data_disk_iops=search_space.IntRange(min=1800, max=8000),85 )86 cap = self._get_default_cap()87 self._assert_disk(88 req,89 cap,90 disk_type=schema.DiskType.PremiumSSDLRS,91 data_disk_iops=2300,92 data_disk_size=512,93 )94 def test_disk_specify_iops_range_both_req_cap(self) -> None:95 # given a range of iops on req and cap, match min one in range96 req = features.AzureDiskOptionSettings(97 data_disk_count=1,98 disk_type=schema.DiskType.PremiumSSDLRS,99 data_disk_iops=search_space.IntRange(min=1800, max=8000),100 )101 cap = self._get_default_cap()102 cap.data_disk_iops = search_space.IntRange(min=4000, max=800000)103 self._assert_disk(104 req,105 cap,106 disk_type=schema.DiskType.PremiumSSDLRS,107 data_disk_iops=5000,108 data_disk_size=1024,109 )110 def test_disk_specify_iops_use_premium(self) -> None:111 # given premium disk type112 req = features.AzureDiskOptionSettings(113 disk_type=search_space.SetSpace[schema.DiskType](114 items=[schema.DiskType.PremiumSSDLRS]115 ),116 data_disk_count=1,117 data_disk_iops=search_space.IntRange(min=1800),118 )119 cap = self._get_default_cap()120 self._assert_disk(121 req,122 cap,123 disk_type=schema.DiskType.PremiumSSDLRS,124 data_disk_iops=2300,125 data_disk_size=512,126 )127 def test_disk_specify_disk_size_min_to_biggest(self) -> None:128 # given min value to disk size, match the max one129 req = features.AzureDiskOptionSettings(130 data_disk_count=1,131 data_disk_size=search_space.IntRange(min=9000),132 )133 cap = self._get_default_cap()134 self._assert_disk(135 req,136 cap,137 data_disk_iops=2000,138 data_disk_size=16384,139 )140 def test_disk_specify_disk_size_a_range(self) -> None:141 # given a range to disk size, match the min one in range142 req = features.AzureDiskOptionSettings(143 disk_type=search_space.SetSpace[schema.DiskType](144 items=[schema.DiskType.PremiumSSDLRS]145 ),146 data_disk_count=1,147 data_disk_size=search_space.IntRange(min=1500, max=30000),148 )149 cap = self._get_default_cap()150 self._assert_disk(151 req,152 cap,153 disk_type=schema.DiskType.PremiumSSDLRS,154 data_disk_iops=7500,155 data_disk_size=2048,156 )157 def _assert_disk(158 self,159 req: features.AzureDiskOptionSettings,160 cap: features.AzureDiskOptionSettings,161 disk_type: schema.DiskType = schema.DiskType.StandardHDDLRS,162 data_disk_count: int = 1,163 data_disk_caching_type: str = constants.DATADISK_CACHING_TYPE_NONE,164 data_disk_iops: int = 500,165 data_disk_size: int = 32,166 ) -> None:167 reason = req.check(cap)168 self.assertTrue(reason.result, f"check reasons: {reason.reasons}")169 min_value: features.AzureDiskOptionSettings = req.generate_min_capability(cap)170 self.assertEqual(disk_type, min_value.disk_type)171 self.assertEqual(data_disk_count, min_value.data_disk_count)...
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!!