| 
									
										
										
										
											2023-09-19 14:44:36 +02:00
										 |  |  | """Module fixture for data quality e2e tests""" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import pytest | 
					
						
							| 
									
										
										
										
											2023-10-25 20:47:51 +02:00
										 |  |  | from playwright.sync_api import Browser, Page, expect | 
					
						
							| 
									
										
										
										
											2023-09-19 14:44:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-25 20:47:51 +02:00
										 |  |  | from .configs.common import go_to_service | 
					
						
							|  |  |  | from .configs.users.admin import Admin | 
					
						
							| 
									
										
										
										
											2023-09-19 14:44:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | TIMEOUT = 60000 | 
					
						
							|  |  |  | BASE_URL = "http://localhost:8585" | 
					
						
							|  |  |  | expect.set_options(timeout=TIMEOUT) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def context(context): | 
					
						
							|  |  |  |     """Set default timeout for playwright context""" | 
					
						
							|  |  |  |     context.set_default_timeout(TIMEOUT) | 
					
						
							|  |  |  |     yield context | 
					
						
							|  |  |  |     context.close() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @pytest.fixture(scope="session") | 
					
						
							|  |  |  | def browser_context_args(browser_context_args): | 
					
						
							|  |  |  |     """override default browser context args""" | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |         **browser_context_args, | 
					
						
							|  |  |  |         "base_url": BASE_URL, | 
					
						
							|  |  |  |         "java_script_enabled": True, | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-25 20:47:51 +02:00
										 |  |  | @pytest.fixture(scope="function") | 
					
						
							|  |  |  | def admin_page_context(page: Page): | 
					
						
							| 
									
										
										
										
											2023-09-19 14:44:36 +02:00
										 |  |  |     page.goto("/") | 
					
						
							|  |  |  |     Admin().login(page) | 
					
						
							| 
									
										
										
										
											2023-10-25 20:47:51 +02:00
										 |  |  |     yield page | 
					
						
							|  |  |  |     page.close() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @pytest.fixture(scope="class") | 
					
						
							|  |  |  | def setUpClass(browser: Browser, request):  # pylint: disable=invalid-name | 
					
						
							|  |  |  |     """set up class for ingestion pipelines""" | 
					
						
							|  |  |  |     context_ = browser.new_context(base_url=BASE_URL) | 
					
						
							|  |  |  |     page = context_.new_page() | 
					
						
							|  |  |  |     page.goto(f"{BASE_URL}/") | 
					
						
							|  |  |  |     Admin().login(page) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connector_obj = request.param["connector_obj"] | 
					
						
							|  |  |  |     request.cls.connector_obj = connector_obj | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # create service and ingest metadata | 
					
						
							|  |  |  |     connector_obj.create_service_ingest_metadata(page) | 
					
						
							|  |  |  |     request.cls.service_name = connector_obj.service_name | 
					
						
							|  |  |  |     page.get_by_text("Ingestions").click() | 
					
						
							|  |  |  |     # Not best practice. Should use `expect`, though playwright does not have a `wait_until` function | 
					
						
							|  |  |  |     # we'll make a call to the API to get the pipeline status and check if it's success | 
					
						
							|  |  |  |     request.cls.metadata_ingestion_status = connector_obj.get_pipeline_status( | 
					
						
							|  |  |  |         f"{connector_obj.service_name}.{connector_obj.metadata_ingestion_pipeline_fqn}" | 
					
						
							| 
									
										
										
										
											2023-09-19 14:44:36 +02:00
										 |  |  |     ) | 
					
						
							| 
									
										
										
										
											2023-10-25 20:47:51 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if connector_obj.supports_profiler_ingestion: | 
					
						
							|  |  |  |         connector_obj.create_profiler_workflow(page) | 
					
						
							|  |  |  |         go_to_service("Databases", page, connector_obj.service_name) | 
					
						
							|  |  |  |         page.get_by_text("Ingestions").click() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Not best practice. Should use `expect`, though playwright does not have a `wait_until` function | 
					
						
							|  |  |  |         # we'll make a call to the API to get the pipeline status and check if it's success | 
					
						
							|  |  |  |         request.cls.profiler_ingestion_status = connector_obj.get_pipeline_status( | 
					
						
							|  |  |  |             f"{connector_obj.service_name}.{connector_obj.profiler_ingestion_pipeline_fqn}" | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     else: | 
					
						
							|  |  |  |         request.cls.profiler_ingestion_status = None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     yield | 
					
						
							|  |  |  |     connector_obj.delete_service(page) | 
					
						
							| 
									
										
										
										
											2023-09-19 14:44:36 +02:00
										 |  |  |     context_.close() |