mostly working shape?

This commit is contained in:
Aron Petau 2025-12-31 16:06:42 +01:00
parent 3057cda8d3
commit 540a3cc884
10 changed files with 462 additions and 183 deletions

View file

@ -16,12 +16,18 @@ def temp_applications_file(tmp_path):
@pytest.fixture
def application_handler(temp_applications_file, monkeypatch):
"""Fixture to create an ApplicationHandler instance with a temporary applications file."""
class DummyContext: pass
class DummyStateManager: pass
monkeypatch.setattr("application_handler.APPLICATIONS_FILE", temp_applications_file)
return ApplicationHandler(browser_context=None, state_manager=None)
return ApplicationHandler(browser_context=DummyContext(), state_manager=DummyStateManager(), applications_file=temp_applications_file)
import types
class DummyContext: pass
class DummyStateManager: pass
def test_detect_company_domains():
handler = ApplicationHandler(browser_context=None, state_manager=None)
handler = ApplicationHandler(browser_context=DummyContext(), state_manager=DummyStateManager())
assert handler._detect_company('https://howoge.de/abc') == 'howoge'
assert handler._detect_company('https://www.howoge.de/abc') == 'howoge'
assert handler._detect_company('https://portal.gewobag.de/') == 'gewobag'
@ -32,7 +38,7 @@ def test_detect_company_domains():
assert handler._detect_company('https://wbm.de/') == 'wbm'
def test_detect_company_path_fallback():
handler = ApplicationHandler(browser_context=None, state_manager=None)
handler = ApplicationHandler(browser_context=DummyContext(), state_manager=DummyStateManager())
assert handler._detect_company('https://example.com/howoge/abc') == 'howoge'
assert handler._detect_company('https://foo.bar/gewobag') == 'gewobag'
assert handler._detect_company('https://foo.bar/degewo') == 'degewo'
@ -41,7 +47,7 @@ def test_detect_company_path_fallback():
assert handler._detect_company('https://foo.bar/wbm') == 'wbm'
def test_detect_company_unknown():
handler = ApplicationHandler(browser_context=None, state_manager=None)
handler = ApplicationHandler(browser_context=DummyContext(), state_manager=DummyStateManager())
assert handler._detect_company('https://example.com/') == 'unknown'
assert handler._detect_company('') == 'unknown'
assert handler._detect_company(None) == 'unknown'