Sfoglia il codice sorgente

Fix tests for services() returning list[str]; remove stale disabled-flag test

ZiB 4 mesi fa
parent
commit
8494561510

+ 1 - 3
room_cal/config-all.json

@@ -88,7 +88,6 @@
       "account_id": "",
       "hotel_id": "",
       "rate_id": "",
-      "disabled": false,
       "fees": {
         "commission": 0.03,
         "client_fee": 0.1411235955
@@ -103,7 +102,6 @@
       "account_id": "",
       "hotel_id": "",
       "rate_id": "",
-      "disabled": false,
       "fees": {
         "commission": 0.15,
         "client_fee": 0.0
@@ -112,7 +110,7 @@
         "wrong": 0.145,
         "flat_tax": 0
       }
-    },
+    }
   },
   "calendars": [
     {

+ 2 - 2
tests/test_action_chains.py

@@ -128,7 +128,7 @@ async def test_fetch_closed_writes_and_removes_closed_events():
   assert free, "No free dates in the 73–75-day-ago window for fetch_closed test"
 
   target = free[0]
-  service_keys = sorted(s.key for s in _services())
+  service_keys = sorted(_services())
 
   try:
     # API reports target blocked
@@ -218,7 +218,7 @@ async def test_push_prices_calls_api_with_list_prices():
   called_date, called_prices = api.set_prices_calls[0]
   assert called_date == target
 
-  svc_keys = {s.key for s in _services()}
+  svc_keys = set(_services())
   for k in called_prices:
     assert k in svc_keys, f"Unexpected key '{k}' in pushed prices"
     assert called_prices[k] is not None and called_prices[k] > 0

+ 2 - 2
tests/test_apply_rules.py

@@ -91,7 +91,7 @@ async def test_apply_rules_future_block_creates_closed_events():
       svcs = await closed_cal.get(d)
       assert svcs is not None and svcs.services, f"Expected Closed event on {d}"
 
-    svc_keys = sorted(s.key for s in _services())
+    svc_keys = sorted(_services())
     for d in iter_dates(start, end):
       assert sorted((await closed_cal.get(d)).services) == svc_keys
 
@@ -107,7 +107,7 @@ async def test_apply_rules_future_block_removes_stale_closed_events():
   from room_cal.closed import Closed
 
   closed_cal = Closed()
-  svc_keys = [s.key for s in _services()]
+  svc_keys = _services()
 
   near_date = local_today() + timedelta(days=5)
   source = {'domain': 'rules', 'name': 'Rule =>', 'id': 'future_block'}

+ 1 - 1
tests/test_calc.py

@@ -9,7 +9,7 @@ from room_cal.pricing.calc import (
   retail_to_net,
 )
 
-_SERVICES = [s.key for s in _services_list()]
+_SERVICES = _services_list()
 _NET = 100.0
 
 

+ 0 - 30
tests/test_refresh_cookies.py

@@ -66,36 +66,6 @@ def chrome_installed():
     pytest.fail(f'install-browsers exited 0 but no chromium dirs found in {browsers}')
 
 
-def test_refresh_all_flags_match_config():
-  """ENABLED flags in refresh-all.ts must match disabled in config.json, with full coverage."""
-  ts_path = _ts_dir() / 'scripts' / 'refresh-all.ts'
-  src = ts_path.read_text()
-
-  # Parse: ENABLED: Record<string, boolean> = { key: true/false, ... }
-  block = re.search(r'const ENABLED[^=]*=\s*\{([^}]+)\}', src)
-  assert block, 'Could not find ENABLED block in refresh-all.ts'
-  ts_flags: dict[str, bool] = {}
-  for m in re.finditer(r'(\w+)\s*:\s*(true|false)', block.group(1)):
-    ts_flags[m.group(1)] = m.group(2) == 'true'
-
-  cfg_services = get_config().services
-  cfg_keys = set(cfg_services.keys())
-  ts_keys = set(ts_flags.keys())
-
-  missing = cfg_keys - ts_keys
-  assert not missing, f'Services in config.json missing from refresh-all.ts ENABLED: {missing}'
-
-  extra = ts_keys - cfg_keys
-  assert not extra, f'Services in refresh-all.ts ENABLED not in config.json: {extra}'
-
-  mismatches = {
-    k for k in cfg_keys
-    if ts_flags[k] != (not cfg_services[k].disabled)
-  }
-  assert not mismatches, (
-    f'ENABLED flags in refresh-all.ts do not match config.json disabled for: {mismatches}\n'
-    + '\n'.join(f'  {k}: ts={ts_flags[k]} config_disabled={cfg_services[k].disabled}' for k in sorted(mismatches))
-  )
 
 
 def test_install_chrome(chrome_installed):