From 41e16114a703d87c074369c14212b9d48ee92809 Mon Sep 17 00:00:00 2001 From: jrycw Date: Tue, 19 Nov 2024 12:54:16 +0800 Subject: [PATCH] Add `test__utils_selenium.py` --- tests/test__utils_selenium.py | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/test__utils_selenium.py diff --git a/tests/test__utils_selenium.py b/tests/test__utils_selenium.py new file mode 100644 index 000000000..089d211d1 --- /dev/null +++ b/tests/test__utils_selenium.py @@ -0,0 +1,43 @@ +import pytest +from selenium import webdriver + +from great_tables._utils_selenium import ( + _get_web_driver, + no_op_callable, + _ChromeWebDriver, + _SafariWebDriver, + _FirefoxWebDriver, + _EdgeWebDriver, +) + + +def test_no_op_callable(): + fake_input = object() + f = no_op_callable(fake_input) + assert f(1, x="x") is fake_input + + +def test_test_get_remote_web_driver(): + with webdriver.Chrome() as web_driver: + wdriver = _get_web_driver(web_driver) + assert wdriver() is web_driver + + +@pytest.mark.parametrize( + "web_driver,Driver", + [ + ("chrome", _ChromeWebDriver), + ("safari", _SafariWebDriver), + ("firefox", _FirefoxWebDriver), + ("edge", _EdgeWebDriver), + ], +) +def test_get_web_driver(web_driver, Driver): + assert _get_web_driver(web_driver) is Driver + + +def test_get_web_driver_raise(): + fake_web_driver = "fake_web_driver" + with pytest.raises(ValueError) as exc_info: + _get_web_driver(fake_web_driver) + assert exc_info.value.args[0] == f"Unsupported web driver: {fake_web_driver}"