update tests
This commit is contained in:
@@ -470,6 +470,34 @@ class RotaBuilder(object):
|
||||
|
||||
setattr(self.constraint_options_model, constraint, value)
|
||||
|
||||
@property
|
||||
def constraint_options(self):
|
||||
"""Backward-compat dict-like proxy for the typed
|
||||
`constraint_options_model`. This keeps older code/tests working
|
||||
while the canonical storage is `constraint_options_model`.
|
||||
"""
|
||||
|
||||
class _Proxy:
|
||||
def __init__(self, model):
|
||||
self._m = model
|
||||
|
||||
def __getitem__(self, key):
|
||||
return getattr(self._m, key)
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
setattr(self._m, key, value)
|
||||
|
||||
def get(self, key, default=None):
|
||||
return getattr(self._m, key, default)
|
||||
|
||||
def items(self):
|
||||
return self._m.model_dump().items()
|
||||
|
||||
def __contains__(self, key):
|
||||
return hasattr(self._m, key)
|
||||
|
||||
return _Proxy(self.constraint_options_model)
|
||||
|
||||
def set_rota_dates(self, start_date: datetime.date, weeks_to_rota: int):
|
||||
self.weeks_to_rota = weeks_to_rota
|
||||
|
||||
@@ -4663,7 +4691,7 @@ class RotaBuilder(object):
|
||||
<summary><h2>Rota settings</h2></summary>
|
||||
<div>
|
||||
<pre>
|
||||
{json.dumps({k: _pydantic_to_dict(v) for k, v in self.constraint_options.items()}, indent=4)}
|
||||
{json.dumps({k: _pydantic_to_dict(v) for k, v in self.constraint_options_model.model_dump().items()}, indent=4)}
|
||||
</pre>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user