How to use find_untagged method in tempest

Best Python code snippet using tempest_python

check_uuid.py

Source:check_uuid.py Github

copy

Full Screen

...224 }225 result[module_name]['tests'][test_name] = \226 tests[module_name]['tests'][test_name]227 return result228 def find_untagged(self, tests):229 """Filter all tests without uuid in metadata"""230 def check_uuid_in_meta(module_name, test_name, tests):231 idempotent_id = self._get_idempotent_id(232 tests[module_name]['tests'][test_name])233 return not idempotent_id234 return self._filter_tests(check_uuid_in_meta, tests)235 def report_collisions(self, tests):236 """Reports collisions if there are any. Returns true if237 collisions exist.238 """239 uuids = {}240 def report(module_name, test_name, tests):241 test_uuid = self._get_idempotent_id(242 tests[module_name]['tests'][test_name])243 if not test_uuid:244 return245 if test_uuid in uuids:246 error_str = "%s:%s\n uuid %s collision: %s<->%s\n%s:%s" % (247 tests[module_name]['source_path'],248 tests[module_name]['tests'][test_name].lineno,249 test_uuid,250 test_name,251 uuids[test_uuid]['test_name'],252 uuids[test_uuid]['source_path'],253 uuids[test_uuid]['test_node'].lineno,254 )255 print(error_str)256 print("cannot automatically resolve the collision, please "257 "manually remove the duplicate value on the new test.")258 return True259 else:260 uuids[test_uuid] = {261 'module': module_name,262 'test_name': test_name,263 'test_node': tests[module_name]['tests'][test_name],264 'source_path': tests[module_name]['source_path']265 }266 return bool(self._filter_tests(report, tests))267 def report_untagged(self, tests):268 """Reports untagged tests if there are any. Returns true if269 untagged tests exist.270 """271 def report(module_name, test_name, tests):272 error_str = "%s:%s\nmissing @test.idempotent_id('...')\n%s\n" % (273 tests[module_name]['source_path'],274 tests[module_name]['tests'][test_name].lineno,275 test_name276 )277 print(error_str)278 return True279 return bool(self._filter_tests(report, tests))280 def fix_tests(self, tests):281 """Add uuids to all tests specified in tests and282 fix it in source files283 """284 patcher = SourcePatcher()285 for module_name in tests:286 add_import_once = True287 for test_name in tests[module_name]['tests']:288 if not tests[module_name]['import_valid'] and add_import_once:289 self._add_import_for_test_uuid(290 patcher,291 tests[module_name]['ast'],292 tests[module_name]['source_path']293 )294 add_import_once = False295 self._add_uuid_to_test(296 patcher, tests[module_name]['tests'][test_name],297 tests[module_name]['source_path'])298 patcher.apply_patches()299def run():300 parser = argparse.ArgumentParser()301 parser.add_argument('--package', action='store', dest='package',302 default='tempest', type=str,303 help='Package with tests')304 parser.add_argument('--fix', action='store_true', dest='fix_tests',305 help='Attempt to fix tests without UUIDs')306 args = parser.parse_args()307 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))308 pkg = importlib.import_module(args.package)309 checker = TestChecker(pkg)310 errors = False311 tests = checker.get_tests()312 untagged = checker.find_untagged(tests)313 errors = checker.report_collisions(tests) or errors314 if args.fix_tests and untagged:315 checker.fix_tests(untagged)316 else:317 errors = checker.report_untagged(untagged) or errors318 if errors:319 sys.exit("@test.idempotent_id existence and uniqueness checks failed\n"320 "Run 'tox -v -euuidgen' to automatically fix tests with\n"321 "missing @test.idempotent_id decorators.")322if __name__ == '__main__':...

Full Screen

Full Screen

tags.py

Source:tags.py Github

copy

Full Screen

...20 scoped_db = provider_scoped_db(provider_spec)21 provider = scoped_db.db.query(ProviderAccount).get(22 scoped_db.provider_account_id)23 print(f'Untagged resources for {provider.provider} account {provider.name}')24 uris = find_untagged(scoped_db.db, provider.id)25 if len(uris) > 0:26 print('\t' + '\n\t'.join(uris))27 else:28 print('\tNONE')29def _sanitize(s: str) -> str:30 escaped = s.replace('\n', '\\n').replace('\t', '\\t')31 if len(escaped) > 30:32 return escaped[:27] + '...'33 else:34 return escaped35@cmd.command('report', help='A tool to help understand the usage of tags')36@click.option(37 '-p',38 '--provider',...

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