Best Python code snippet using tempest_python
keypairspage.py
Source:keypairspage.py
...24 return forms.FormRegion(25 self.driver, self.conf,26 field_mappings=self.CREATE_KEY_PAIR_FORM_FIELDS)27 @tables.bind_row_action('delete', primary=True)28 def delete_keypair(self, delete_button, row):29 delete_button.click()30 return forms.BaseFormRegion(self.driver, self.conf)31class KeypairsPage(basepage.BaseNavigationPage):32 KEY_PAIRS_TABLE_ACTIONS = ("create", "import", "delete")33 KEY_PAIRS_TABLE_ROW_ACTION = "delete"34 KEY_PAIRS_TABLE_NAME_COLUMN = 'name'35 def __init__(self, driver, conf):36 super(KeypairsPage, self).__init__(driver, conf)37 self._page_title = "Access & Security"38 def _get_row_with_keypair_name(self, name):39 return self.keypairs_table.get_row(self.KEY_PAIRS_TABLE_NAME_COLUMN,40 name)41 @property42 def keypairs_table(self):43 return KeypairsTable(self.driver, self.conf)44 @property45 def delete_keypair_form(self):46 return forms.BaseFormRegion(self.driver, self.conf, None)47 def is_keypair_present(self, name):48 return bool(self._get_row_with_keypair_name(name))49 def create_keypair(self, keypair_name):50 create_keypair_form = self.keypairs_table.create_keypair()51 create_keypair_form.name.text = keypair_name52 create_keypair_form.submit()53 def delete_keypair(self, name):54 row = self._get_row_with_keypair_name(name)55 delete_keypair_form = self.keypairs_table.delete_keypair(row)...
test_keypairs.py
Source:test_keypairs.py
...28 self.assertIsNotNone(keypair['fingerprint'])29 self.assertEqual(keypair['type'], 'ssh')30 keypairs = self.user_cloud.list_keypairs()31 self.assertIn(name, [k['name'] for k in keypairs])32 self.user_cloud.delete_keypair(name)33 keypairs = self.user_cloud.list_keypairs()34 self.assertNotIn(name, [k['name'] for k in keypairs])35 def test_create_and_delete_with_key(self):36 '''Test creating and deleting keypairs functionality'''37 name = self.getUniqueString('keypair')38 self.addCleanup(self.user_cloud.delete_keypair, name)39 keypair = self.user_cloud.create_keypair(40 name=name, public_key=fakes.FAKE_PUBLIC_KEY)41 self.assertEqual(keypair['name'], name)42 self.assertIsNotNone(keypair['public_key'])43 self.assertIsNone(keypair['private_key'])44 self.assertIsNotNone(keypair['fingerprint'])45 self.assertEqual(keypair['type'], 'ssh')46 keypairs = self.user_cloud.list_keypairs()47 self.assertIn(name, [k['name'] for k in keypairs])48 self.user_cloud.delete_keypair(name)49 keypairs = self.user_cloud.list_keypairs()...
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!!