From 9cab4a8651c49ffdb64db6b95044ec6453cbf8d0 Mon Sep 17 00:00:00 2001 From: Dinis Cruz Date: Fri, 4 Oct 2024 14:50:46 +0100 Subject: [PATCH] added helper to ensure browser is installed before running integration tests that need it --- ...right__Serverless.py => test__i__Playwright__Browser.py} | 0 .../fast_api/routes/test__u__Routes__Browser.py} | 4 +++- tests/integration/fast_api_objs_for_tests.py | 6 ++++++ .../test__i__Flow__Playwright__Get_Page_Html.py} | 6 +++++- .../test__i__Flow__Playwright__Get_Page_Screenshot.py} | 4 +++- 5 files changed, 17 insertions(+), 3 deletions(-) rename tests/integration/fast_api/routes/{test__i__Playwright__Serverless.py => test__i__Playwright__Browser.py} (100%) rename tests/{unit/fast_api/routes/test_Routes__Browser.py => integration/fast_api/routes/test__u__Routes__Browser.py} (69%) rename tests/{unit/flows/browser_based/test_Flow__Playwright__Get_Page_Html.py => integration/flows/browser_based/test__i__Flow__Playwright__Get_Page_Html.py} (76%) rename tests/{unit/flows/browser_based/test_Flow__Playwright__Get_Page_Screenshot.py => integration/flows/browser_based/test__i__Flow__Playwright__Get_Page_Screenshot.py} (83%) diff --git a/tests/integration/fast_api/routes/test__i__Playwright__Serverless.py b/tests/integration/fast_api/routes/test__i__Playwright__Browser.py similarity index 100% rename from tests/integration/fast_api/routes/test__i__Playwright__Serverless.py rename to tests/integration/fast_api/routes/test__i__Playwright__Browser.py diff --git a/tests/unit/fast_api/routes/test_Routes__Browser.py b/tests/integration/fast_api/routes/test__u__Routes__Browser.py similarity index 69% rename from tests/unit/fast_api/routes/test_Routes__Browser.py rename to tests/integration/fast_api/routes/test__u__Routes__Browser.py index ed4325d..5706ad0 100644 --- a/tests/unit/fast_api/routes/test_Routes__Browser.py +++ b/tests/integration/fast_api/routes/test__u__Routes__Browser.py @@ -1,12 +1,14 @@ from unittest import TestCase +from integration.fast_api_objs_for_tests import ensure_browser_is_installed from osbot_serverless_flows.fast_api.routes.Routes__Browser import Routes__Browser -class test_Routes_Browser(TestCase): +class test__u__Routes_Browser(TestCase): @classmethod def setUpClass(cls): + ensure_browser_is_installed() cls.routes_browser = Routes__Browser() def test_url_html(self): diff --git a/tests/integration/fast_api_objs_for_tests.py b/tests/integration/fast_api_objs_for_tests.py index c8116bc..6327376 100644 --- a/tests/integration/fast_api_objs_for_tests.py +++ b/tests/integration/fast_api_objs_for_tests.py @@ -7,3 +7,9 @@ client__serverless_flows = fast_api__serverless_flows.client() assert duration.seconds < 1 # make sure the setup time is less than 1 second + + +def ensure_browser_is_installed(): + from osbot_serverless_flows.playwright.Playwright__Serverless import Playwright__Serverless + playwright_browser = Playwright__Serverless() + playwright_browser.browser__install() \ No newline at end of file diff --git a/tests/unit/flows/browser_based/test_Flow__Playwright__Get_Page_Html.py b/tests/integration/flows/browser_based/test__i__Flow__Playwright__Get_Page_Html.py similarity index 76% rename from tests/unit/flows/browser_based/test_Flow__Playwright__Get_Page_Html.py rename to tests/integration/flows/browser_based/test__i__Flow__Playwright__Get_Page_Html.py index 9a5f5ee..8f4709c 100644 --- a/tests/unit/flows/browser_based/test_Flow__Playwright__Get_Page_Html.py +++ b/tests/integration/flows/browser_based/test__i__Flow__Playwright__Get_Page_Html.py @@ -1,13 +1,17 @@ from unittest import TestCase + +from integration.fast_api_objs_for_tests import ensure_browser_is_installed from osbot_serverless_flows.flows.browser_based.Flow__Playwright__Get_Page_Html import Flow__Playwright__Get_Page_Html -class test_Flow__Playwright__Get_Page_Html(TestCase): +class test__i__Flow__Playwright__Get_Page_Html(TestCase): @classmethod def setUpClass(cls) -> None: + ensure_browser_is_installed() cls.flow__get_page_html = Flow__Playwright__Get_Page_Html() + def test_run(self): flow_data = self.flow__get_page_html.run() page_content = flow_data.get('page_content') diff --git a/tests/unit/flows/browser_based/test_Flow__Playwright__Get_Page_Screenshot.py b/tests/integration/flows/browser_based/test__i__Flow__Playwright__Get_Page_Screenshot.py similarity index 83% rename from tests/unit/flows/browser_based/test_Flow__Playwright__Get_Page_Screenshot.py rename to tests/integration/flows/browser_based/test__i__Flow__Playwright__Get_Page_Screenshot.py index bc42d56..69780b8 100644 --- a/tests/unit/flows/browser_based/test_Flow__Playwright__Get_Page_Screenshot.py +++ b/tests/integration/flows/browser_based/test__i__Flow__Playwright__Get_Page_Screenshot.py @@ -1,14 +1,16 @@ from unittest import TestCase +from integration.fast_api_objs_for_tests import ensure_browser_is_installed from osbot_utils.utils.Misc import base64_to_bytes from osbot_serverless_flows.flows.browser_based.Flow__Playwright__Get_Page_Screenshot import Flow__Playwright__Get_Page_Screenshot -class test_Flow__Playwright__Get_Page_Screenshot(TestCase): +class test__i__Flow__Playwright__Get_Page_Screenshot(TestCase): @classmethod def setUpClass(cls) -> None: + ensure_browser_is_installed() cls.flow__get_page_screenshot = Flow__Playwright__Get_Page_Screenshot() def test_run(self):