- Add agents package: controller, runner, store, tools, actions, evals, policy - Wire agents into Devii service, session, registry, CLI, and dispatcher - Extend database schema and config for agent persistence - Add news and telegram bridge updates plus landing UI and docs - Cover agents, news, and telegram flows with unit tests
91 lines
3.2 KiB
Python
91 lines
3.2 KiB
Python
# retoor <retoor@molodetz.nl>
|
|
|
|
from devplacepy.database import get_table, init_db
|
|
|
|
FILTERED_COLUMNS = {
|
|
"messages": ("uid", "sender_uid", "receiver_uid", "content", "read", "created_at", "updated_at"),
|
|
"workspace_quota_rules": ("uid", "owner_kind", "owner_id", "deleted_at"),
|
|
"workspace_editor_prefs": ("uid", "owner_kind", "owner_id", "deleted_at"),
|
|
}
|
|
|
|
|
|
def test_init_db_ensures_every_filtered_column(local_db):
|
|
for table, columns in FILTERED_COLUMNS.items():
|
|
target = get_table(table)
|
|
missing = [column for column in columns if not target.has_column(column)]
|
|
assert not missing, f"{table} is missing {missing}"
|
|
|
|
|
|
def test_a_partial_insert_cannot_reduce_the_messages_schema(local_db):
|
|
table = get_table("messages")
|
|
table.insert(
|
|
{
|
|
"uid": "schema-msg-1",
|
|
"sender_uid": "schema-user-1",
|
|
"receiver_uid": "schema-user-2",
|
|
"content": "partial row, no created_at",
|
|
}
|
|
)
|
|
try:
|
|
init_db()
|
|
assert get_table("messages").has_column("created_at")
|
|
rows = list(
|
|
local_db.query(
|
|
"SELECT uid FROM messages WHERE created_at IS NULL AND uid = :u",
|
|
u="schema-msg-1",
|
|
)
|
|
)
|
|
assert len(rows) == 1
|
|
finally:
|
|
get_table("messages").delete(uid="schema-msg-1")
|
|
|
|
|
|
def test_the_workspace_rule_tables_filter_on_a_column_that_exists(local_db):
|
|
from devplacepy.services.containers.workspace import editor, quota
|
|
|
|
assert quota._rule_for("user", "nobody-at-all") is None
|
|
assert editor.prefs_for("nobody-at-all") is None
|
|
|
|
|
|
def test_retired_aquality_grading_settings_heal_to_gateway(local_db):
|
|
from devplacepy.config import (
|
|
AQUALITY_NEWS_GRADING_MODEL,
|
|
AQUALITY_NEWS_GRADING_URL,
|
|
INTERNAL_GATEWAY_URL,
|
|
NEWS_GRADING_MODEL_DEFAULT,
|
|
)
|
|
from devplacepy.database import get_setting, set_setting
|
|
from devplacepy.database.schema import migrate_ai_gateway_settings
|
|
|
|
prev_url = get_setting("news_ai_url", "")
|
|
prev_model = get_setting("news_ai_model", "")
|
|
try:
|
|
set_setting("news_ai_url", AQUALITY_NEWS_GRADING_URL)
|
|
set_setting("news_ai_model", AQUALITY_NEWS_GRADING_MODEL)
|
|
migrate_ai_gateway_settings()
|
|
assert get_setting("news_ai_url", "") == INTERNAL_GATEWAY_URL
|
|
assert get_setting("news_ai_model", "") == NEWS_GRADING_MODEL_DEFAULT
|
|
finally:
|
|
set_setting("news_ai_url", prev_url)
|
|
set_setting("news_ai_model", prev_model)
|
|
|
|
|
|
def test_custom_grading_settings_survive_migration(local_db):
|
|
from devplacepy.database import get_setting, set_setting
|
|
from devplacepy.database.schema import migrate_ai_gateway_settings
|
|
|
|
prev_url = get_setting("news_ai_url", "")
|
|
prev_model = get_setting("news_ai_model", "")
|
|
try:
|
|
set_setting("news_ai_url", "http://custom.test/v1/chat/completions")
|
|
set_setting("news_ai_model", "custom-model")
|
|
migrate_ai_gateway_settings()
|
|
assert (
|
|
get_setting("news_ai_url", "")
|
|
== "http://custom.test/v1/chat/completions"
|
|
)
|
|
assert get_setting("news_ai_model", "") == "custom-model"
|
|
finally:
|
|
set_setting("news_ai_url", prev_url)
|
|
set_setting("news_ai_model", prev_model)
|