Best Python code snippet using tempest_python
test_roles.py
Source:test_roles.py
...350 # we filter every other implied role to only take into account the ones351 # relates to this test.352 relevant_roles = (self.roles[0]['id'], self.roles[1]['id'],353 self.roles[2]['id'], self.role['id'])354 def is_implied_role_relevant(rule):355 return any(r for r in rule['implies'] if r['id'] in relevant_roles)356 relevant_rules = filter(is_implied_role_relevant, rules)357 # Sort the rules by the number of inferences, since there should be 1358 # inference between "roles[2]" and "role" and 2 inferences for359 # "roles[0]": between "roles[1]" and "roles[2]".360 sorted_rules = sorted(relevant_rules, key=lambda r: len(r['implies']))361 self.assertEqual(2, len(sorted_rules))362 # Check that only 1 inference rule exists between "roles[2]" and "role"363 self.assertEqual(1, len(sorted_rules[0]['implies']))364 # Check that 2 inference rules exist for "roles[0]": one between365 # "roles[1]" and one between "roles[2]".366 self.assertEqual(2, len(sorted_rules[1]['implies']))367 # Check that "roles[2]" is the "prior_role" and that "role" is the368 # "implies" role....
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!!