44 lines
1.9 KiB
Python
44 lines
1.9 KiB
Python
import pytest
|
|
import sys
|
|
from pathlib import Path as _Path
|
|
sys.path.append(str(_Path(__file__).parent.parent))
|
|
from application_handler import ApplicationHandler
|
|
|
|
class DummyStateManager:
|
|
email = None
|
|
password = None
|
|
logged_in = False
|
|
def set_autopilot(self, enabled): pass
|
|
def is_autopilot_enabled(self): return False
|
|
|
|
def make_handler():
|
|
# context is not used for _detect_company
|
|
return ApplicationHandler(browser_context=None, state_manager=DummyStateManager())
|
|
|
|
def test_detect_company_domains():
|
|
handler = make_handler()
|
|
# Domain and subdomain cases
|
|
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'
|
|
assert handler._detect_company('https://degewo.de/') == 'degewo'
|
|
assert handler._detect_company('https://gesobau.de/') == 'gesobau'
|
|
assert handler._detect_company('https://stadtundland.de/') == 'stadtundland'
|
|
assert handler._detect_company('https://stadt-und-land.de/') == 'stadtundland'
|
|
assert handler._detect_company('https://wbm.de/') == 'wbm'
|
|
|
|
def test_detect_company_path_fallback():
|
|
handler = make_handler()
|
|
# Path/query fallback
|
|
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'
|
|
assert handler._detect_company('https://foo.bar/gesobau') == 'gesobau'
|
|
assert handler._detect_company('https://foo.bar/stadt-und-land') == 'stadtundland'
|
|
assert handler._detect_company('https://foo.bar/wbm') == 'wbm'
|
|
|
|
def test_detect_company_unknown():
|
|
handler = make_handler()
|
|
assert handler._detect_company('https://example.com/') == 'unknown'
|
|
assert handler._detect_company('') == 'unknown'
|
|
assert handler._detect_company(None) == 'unknown'
|