How to use _test_is_not_valid method in tempest

Best Python code snippet using tempest_python

test_credentials.py

Source:test_credentials.py Github

copy

Full Screen

...78 filled=False)79 def test_is_valid(self):80 creds = self._get_credentials()81 self.assertTrue(creds.is_valid())82 def _test_is_not_valid(self, ignore_key):83 creds = self._get_credentials()84 for attr in self.attributes:85 if attr == ignore_key:86 continue87 temp_attr = getattr(creds, attr)88 delattr(creds, attr)89 self.assertFalse(creds.is_valid(),90 "Credentials should be invalid without %s" % attr)91 setattr(creds, attr, temp_attr)92 def test_is_not_valid(self):93 # NOTE(mtreinish): A KeystoneV2 credential object is valid without94 # a tenant_name. So skip that check. See tempest.auth for the valid95 # credential requirements96 self._test_is_not_valid('tenant_name')97 def test_reset_all_attributes(self):98 creds = self._get_credentials()99 initial_creds = copy.deepcopy(creds)100 set_attr = creds.__dict__.keys()101 missing_attr = set(creds.ATTRIBUTES).difference(set_attr)102 # Set all unset attributes, then reset103 for attr in missing_attr:104 setattr(creds, attr, 'fake' + attr)105 creds.reset()106 # Check reset credentials are same as initial ones107 self.assertEqual(creds, initial_creds)108 def test_reset_single_attribute(self):109 creds = self._get_credentials()110 initial_creds = copy.deepcopy(creds)111 set_attr = creds.__dict__.keys()112 missing_attr = set(creds.ATTRIBUTES).difference(set_attr)113 # Set one unset attributes, then reset114 for attr in missing_attr:115 setattr(creds, attr, 'fake' + attr)116 creds.reset()117 # Check reset credentials are same as initial ones118 self.assertEqual(creds, initial_creds)119class KeystoneV3CredentialsTests(KeystoneV2CredentialsTests):120 attributes = {121 'username': 'fake_username',122 'password': 'fake_password',123 'project_name': 'fake_project_name',124 'user_domain_name': 'fake_domain_name'125 }126 credentials_class = auth.KeystoneV3Credentials127 identity_response = fake_identity._fake_v3_response128 tokenclient_class = v3_client.V3TokenClient129 identity_version = 'v3'130 def test_is_not_valid(self):131 # NOTE(mtreinish) For a Keystone V3 credential object a project name132 # is not required to be valid, so we skip that check. See tempest.auth133 # for the valid credential requirements134 self._test_is_not_valid('project_name')135 def test_synced_attributes(self):136 attributes = self.attributes137 # Create V3 credentials with tenant instead of project, and user_domain138 for attr in ['project_id', 'user_domain_id']:139 attributes[attr] = 'fake_' + attr140 creds = self._get_credentials(attributes)141 self.assertEqual(creds.project_name, creds.tenant_name)142 self.assertEqual(creds.project_id, creds.tenant_id)143 self.assertEqual(creds.user_domain_name, creds.project_domain_name)144 self.assertEqual(creds.user_domain_id, creds.project_domain_id)145 # Replace user_domain with project_domain146 del attributes['user_domain_name']147 del attributes['user_domain_id']148 del attributes['project_name']...

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