and also ensures we're looking for proper dates and not strings like
"yesterday" by enforcing the valid_date translation.
"""
- assert isinstance(id_, str)
possibly_translated_date = valid_date(id_)
day = super().by_id(db_conn, possibly_translated_date)
if day.id_ in Todo.days_to_update:
cache = cls.get_cache()
if id_ in cache:
obj = cache[id_]
- assert isinstance(obj, cls)
return obj
return None
"""
items: dict[BaseModelId, BaseModelInstance] = {}
for k, v in cls.get_cache().items():
- assert isinstance(v, cls)
items[k] = v
already_recorded = items.keys()
for id_ in db_conn.column_all(cls.table_name, 'id'):
def clear_caches() -> None:
for cls in (Day, Todo, Condition, Process, ProcessStep):
- assert hasattr(cls, 'empty_cache')
cls.empty_cache()
def decorator(f: Callable[..., str | None]
assert process.id_ is not None
for name in ('conditions', 'blockers', 'enables', 'disables'):
table = f'process_{name}'
- assert isinstance(process.id_, int)
for c_id in db_conn.column_where(table, 'condition',
'process', process.id_):
target = getattr(process, name)
top_owner = external_owner or self
for step in [s for s in self.explicit_steps
if s.parent_step_id is None]:
- assert isinstance(step.id_, int)
new_node = make_node(step, step in top_owner.suppressed_steps)
step_nodes += [new_node]
for step_node in step_nodes:
for step in step_process.explicit_steps:
walk_steps(step)
- assert isinstance(self.id_, int)
# NB: separate the collection of steps to save/remove from the action
# because the latter may modify the collection / self.explicit_steps
to_remove = []
todo.parents += [cls.by_id(db_conn, t_id)]
for name in ('conditions', 'blockers', 'enables', 'disables'):
table = f'todo_{name}'
- assert isinstance(todo.id_, int)
for cond_id in db_conn.column_where(table, 'condition',
'todo', todo.id_):
target = getattr(todo, name)
hashes_content = [hash(x) for x in content]
db_found: list[Any] = []
for item in content:
- assert isinstance(item.id_, type(self.default_ids[0]))
db_found += self._load_from_db(item.id_)
hashes_db_found = [hash(x) for x in db_found]
self.assertEqual(sorted(hashes_content), sorted(hashes_db_found))
id_ = self.default_ids[0]
obj = self._make_from_defaults(id_)
obj.save(self.db_conn)
- assert isinstance(obj.id_, type(id_))
for row in self.db_conn.row_where(self.checked_class.table_name,
'id', obj.id_):
# check .from_table_row reproduces state saved, no matter if obj