From 9208cf7ec347341f42b0383adecc683b655526a3 Mon Sep 17 00:00:00 2001 From: Ali Hamood Date: Tue, 16 Dec 2025 08:53:20 -0800 Subject: [PATCH 1/2] Fixed selenium web driver api issues. executable_path was removed in 4.x. Fixed SQLAlchemy double registration issue. --- solr-admin-app/tests/conftest.py | 9 ++++++--- .../tests/external/test_not_authorized_user.py | 4 +++- solr-admin-app/tests/internal/services/test_stem.py | 5 +++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/solr-admin-app/tests/conftest.py b/solr-admin-app/tests/conftest.py index 09bd1f9fd..98d59efa6 100644 --- a/solr-admin-app/tests/conftest.py +++ b/solr-admin-app/tests/conftest.py @@ -4,6 +4,7 @@ import pytest from selenium.webdriver.firefox.webdriver import WebDriver from selenium.webdriver.firefox.options import Options +from selenium.webdriver.firefox.service import Service from sqlalchemy import engine_from_config from tests.external.support.driver.server_driver import ServerDriver @@ -25,7 +26,8 @@ def get_browser(): options = Options() options.headless = True - browser = WebDriver(options=options, executable_path=(gecko_driver())) + service = Service(executable_path=gecko_driver()) + browser = WebDriver(options=options, service=service) return browser @@ -81,8 +83,8 @@ def base_url(port): @pytest.fixture(scope="function") def clean_db(): - from flask_sqlalchemy import SQLAlchemy from solr_admin import create_application + from solr_admin import models from solr_admin.models.synonym import Synonym from solr_admin.models.synonym_audit import SynonymAudit @@ -103,7 +105,8 @@ def clean_db(): Keycloak._oidc = FakeOidc() app, admin = create_application(run_mode='testing') - db = SQLAlchemy(app) + # Use the existing db instance that was initialized in create_application + db = models.db synonyms_db = engine_from_config({'sqlalchemy.url': app.config['SQLALCHEMY_BINDS']['synonyms']}) #Synonym.metadata.drop_all(bind=synonyms_db) diff --git a/solr-admin-app/tests/external/test_not_authorized_user.py b/solr-admin-app/tests/external/test_not_authorized_user.py index 3ae87e83c..80fc482a8 100644 --- a/solr-admin-app/tests/external/test_not_authorized_user.py +++ b/solr-admin-app/tests/external/test_not_authorized_user.py @@ -2,6 +2,7 @@ from hamcrest import * from selenium.webdriver.firefox.webdriver import WebDriver from selenium.webdriver.firefox.options import Options +from selenium.webdriver.firefox.service import Service from tests.conftest import get_browser, connect_with, gecko_driver import os @@ -35,7 +36,8 @@ def new_browser(new_server, second_base_url): def get_browser(): options = Options() options.headless = True - browser = WebDriver(options=options, executable_path=(gecko_driver())) + service = Service(executable_path=gecko_driver()) + browser = WebDriver(options=options, service=service) return browser diff --git a/solr-admin-app/tests/internal/services/test_stem.py b/solr-admin-app/tests/internal/services/test_stem.py index 468c00132..d101b0eed 100644 --- a/solr-admin-app/tests/internal/services/test_stem.py +++ b/solr-admin-app/tests/internal/services/test_stem.py @@ -1,14 +1,17 @@ import os +import pytest from hamcrest import * from solr_admin.services.get_stems import get_stems, get_stems_url from urllib import request +@pytest.mark.skipif(not os.getenv('SOLR_URL'), reason="SOLR_URL environment variable not set") def test_solr_configuration(): assert_that(os.getenv('SOLR_URL'), not_none()) +@pytest.mark.skipif(not os.getenv('SOLR_URL'), reason="SOLR_URL environment variable not set") def test_solr_available(): solr_url = os.getenv('SOLR_URL') url = solr_url + '/solr/possible.conflicts/admin/ping' @@ -17,6 +20,7 @@ def test_solr_available(): assert r.code == 200 +@pytest.mark.skipif(not os.getenv('SOLR_URL'), reason="SOLR_URL environment variable not set") def test_explore_stem_url(): solr_url = os.getenv('SOLR_URL') synonym_list = 'construction, constructing, development' @@ -25,6 +29,7 @@ def test_explore_stem_url(): assert_that(url, equal_to(solr_url + '/solr/possible.conflicts/analysis/field?analysis.fieldvalue=construction,%20constructing,%20development&analysis.fieldname=name&wt=json&indent=true')) +@pytest.mark.skipif(not os.getenv('SOLR_URL'), reason="SOLR_URL environment variable not set") def test_stem_several_worlds(): synonym_list = 'construction, constructing, development' stems = get_stems(synonym_list) From 3e1fb0387d8a17a6b4877a18fd24237e5f440abb Mon Sep 17 00:00:00 2001 From: Ali Hamood Date: Tue, 16 Dec 2025 09:10:31 -0800 Subject: [PATCH 2/2] Removed the skip test directive. SOLR_URL must be set or CI should fail. --- solr-admin-app/tests/internal/services/test_stem.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/solr-admin-app/tests/internal/services/test_stem.py b/solr-admin-app/tests/internal/services/test_stem.py index d101b0eed..d435536a3 100644 --- a/solr-admin-app/tests/internal/services/test_stem.py +++ b/solr-admin-app/tests/internal/services/test_stem.py @@ -6,12 +6,10 @@ from urllib import request -@pytest.mark.skipif(not os.getenv('SOLR_URL'), reason="SOLR_URL environment variable not set") def test_solr_configuration(): assert_that(os.getenv('SOLR_URL'), not_none()) -@pytest.mark.skipif(not os.getenv('SOLR_URL'), reason="SOLR_URL environment variable not set") def test_solr_available(): solr_url = os.getenv('SOLR_URL') url = solr_url + '/solr/possible.conflicts/admin/ping' @@ -20,7 +18,6 @@ def test_solr_available(): assert r.code == 200 -@pytest.mark.skipif(not os.getenv('SOLR_URL'), reason="SOLR_URL environment variable not set") def test_explore_stem_url(): solr_url = os.getenv('SOLR_URL') synonym_list = 'construction, constructing, development' @@ -29,7 +26,6 @@ def test_explore_stem_url(): assert_that(url, equal_to(solr_url + '/solr/possible.conflicts/analysis/field?analysis.fieldvalue=construction,%20constructing,%20development&analysis.fieldname=name&wt=json&indent=true')) -@pytest.mark.skipif(not os.getenv('SOLR_URL'), reason="SOLR_URL environment variable not set") def test_stem_several_worlds(): synonym_list = 'construction, constructing, development' stems = get_stems(synonym_list)