How to use get_configuration method in lisa

Best Python code snippet using lisa_python

test_ingestion_config.py

Source: test_ingestion_config.py Github

copy

Full Screen

1#!/​usr/​bin/​env python32"""3This file includes test scenarios and test cases for code regarding ingestion.4Pytest is the preferred test framework.5"""6from code.test.utils.utils import (assert_object_in_yaml,7 assert_object_is_correct_type)8pytest_plugins = ["code.test.pytest_fixtures"]9configuration_objects = [('url', str),10 ('repo_url', str),11 ('sink', str),12 ('user', str),13 ('repo', str),14 ('batch_size', int),15 ('file_size', int),16 ('save_tree', bool),17 ('use_cached', bool),18 ('file_path', str),19 ('download_method', str),20 ('use_api', bool)]21task = 'ingest'22def test_configuration_contains_ingestion(get_configuration) -> None:23 """24 Tests whether the configuration contains an entry for task 1.25 :param get_configuration: The configuration yaml file.26 :return: None27 """28 assert get_configuration.ingestion is not None, "'task1 is not in configuration file"29 for object_name, type_def in configuration_objects:30 assert_object_in_yaml(object_name, get_configuration.ingestion, "ingest")31 assert_object_is_correct_type(object_name, get_configuration.ingestion, type_def)32def test_configuration_fails_on_wrong_object_name(get_configuration) -> None:33 """34 Tests whether the configuration contains an entry for task 1.35 :param get_configuration: The configuration yaml file.36 :return: None37 """38 assert get_configuration.ingestion is not None, "'task1 is not in configuration file"39 configuration_objects.append(("not_an_object", str))40 try:41 for object_name, type_def in configuration_objects:42 assert_object_in_yaml(object_name, get_configuration.ingestion, "ingest")43 assert_object_is_correct_type(object_name, get_configuration.ingestion, type_def)44 except AssertionError:45 return46 raise AssertionError("Test failed")47def test_configuration_fails_on_wrong_object_type(get_configuration) -> None:48 """49 Tests whether the configuration contains an entry for task 1.50 :param get_configuration: The configuration yaml file.51 :return: None52 """53 assert get_configuration.ingestion is not None, "'task1 is not in configuration file"54 configuration_objects[-1] = ("use_api", str)55 try:56 for object_name, type_def in configuration_objects:57 assert_object_in_yaml(object_name, get_configuration.ingestion, "ingest")58 assert_object_is_correct_type(object_name, get_configuration.ingestion, type_def)59 except AssertionError:60 return61 raise AssertionError("Test failed")62def test_batch_tree_contains_batches(get_cached_batch_tree) -> None:63 keys = list(get_cached_batch_tree.keys())64 batches = list(map(lambda x: x.split('_')[0], keys))65 numbers = list(map(lambda x: x.split('_')[1], keys))66 assert all(number.isdigit() for number in numbers)...

Full Screen

Full Screen

test_constants.py

Source: test_constants.py Github

copy

Full Screen

...5 def setUp(self):6 self.constants = constants7 self.config = config8 def test_constants(self):9 self.assertEqual(self.constants.PUBLISH_OPTIONS, self.config.get_configuration('PUBLISH_OPTIONS'))10 self.assertEqual(self.constants.OBJAVI_URL, self.config.get_configuration('OBJAVI_URL'))11 self.assertEqual(self.constants.ESPRI_URL, self.config.get_configuration('ESPRI_URL'))12 self.assertNotEqual(self.constants.THIS_BOOKI_SERVER, self.config.get_configuration('THIS_BOOKI_SERVER'))13 self.assertEqual(self.constants.CREATE_BOOK_VISIBLE, self.config.get_configuration('CREATE_BOOK_VISIBLE'))14 self.assertEqual(self.constants.CREATE_BOOK_LICENSE, self.config.get_configuration('CREATE_BOOK_LICENSE'))15 self.assertEqual(self.constants.FREE_REGISTRATION, self.config.get_configuration('FREE_REGISTRATION'))16 self.assertEqual(self.constants.ADMIN_CREATE_BOOKS, self.config.get_configuration('ADMIN_CREATE_BOOKS'))17 self.assertEqual(self.constants.ADMIN_IMPORT_BOOKS, self.config.get_configuration('ADMIN_IMPORT_BOOKS'))18 self.assertEqual(self.constants.BOOKTYPE_MAX_USERS, self.config.get_configuration('BOOKTYPE_MAX_USERS'))19 self.assertEqual(self.constants.BOOKTYPE_MAX_BOOKS, self.config.get_configuration('BOOKTYPE_MAX_BOOKS'))20 self.assertEqual(self.constants.BOOKTYPE_CSS_BOOK, self.config.get_configuration('BOOKTYPE_CSS_BOOK'))21 self.assertEqual(self.constants.BOOKTYPE_CSS_BOOKJS, self.config.get_configuration('BOOKTYPE_CSS_BOOKJS'))22 self.assertEqual(self.constants.BOOKTYPE_CSS_EBOOK, self.config.get_configuration('BOOKTYPE_CSS_EBOOK'))23 self.assertEqual(self.constants.BOOKTYPE_CSS_PDF, self.config.get_configuration('BOOKTYPE_CSS_PDF'))...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

How To Handle Multiple Windows In Selenium Python

Automating testing is a crucial step in the development pipeline of a software product. In an agile development environment, where there is continuous development, deployment, and maintenance of software products, automation testing ensures that the end software products delivered are error-free.

Joomla Testing Guide: How To Test Joomla Websites

Before we discuss the Joomla testing, let us understand the fundamentals of Joomla and how this content management system allows you to create and maintain web-based applications or websites without having to write and implement complex coding requirements.

Starting & growing a QA Testing career

The QA testing career includes following an often long, winding road filled with fun, chaos, challenges, and complexity. Financially, the spectrum is broad and influenced by location, company type, company size, and the QA tester’s experience level. QA testing is a profitable, enjoyable, and thriving career choice.

The Art of Testing the Untestable

It’s strange to hear someone declare, “This can’t be tested.” In reply, I contend that everything can be tested. However, one must be pleased with the outcome of testing, which might include failure, financial loss, or personal injury. Could anything be tested when a claim is made with this understanding?

How To Create Custom Menus with CSS Select

When it comes to UI components, there are two versatile methods that we can use to build it for your website: either we can use prebuilt components from a well-known library or framework, or we can develop our UI components from scratch.

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