fix(жалобы): похвала, миграция и разбор
This commit is contained in:
@@ -51,3 +51,41 @@ def test_old_null_category_still_counts(env):
|
||||
row = db.get_feedback(1)[0]
|
||||
assert row["category"] is None and row["status"] == "new"
|
||||
assert db.count_feedback_new() == 1
|
||||
|
||||
|
||||
def test_praise_does_not_raise_red_alert(env):
|
||||
db, client, h, attention = env
|
||||
db.save_feedback("joe@x", "t1", "спасибо", "a", category="praise", source="chat")
|
||||
assert db.count_feedback_new() == 0
|
||||
keys = {i["key"] for i in attention.collect({}, {"accounts_total_rub": 0})["items"]}
|
||||
assert "feedback:new" not in keys
|
||||
|
||||
|
||||
def test_old_schema_migrates(tmp_path, monkeypatch):
|
||||
import sqlite3
|
||||
p = tmp_path / "old.db"
|
||||
c = sqlite3.connect(p)
|
||||
c.executescript("CREATE TABLE feedback (id INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||
"timestamp REAL NOT NULL, username TEXT NOT NULL, tab_id TEXT, "
|
||||
"comment TEXT, answer TEXT);"
|
||||
"INSERT INTO feedback (timestamp,username,comment,answer) "
|
||||
"VALUES (1,'a','старая','ans');")
|
||||
c.commit(); c.close()
|
||||
monkeypatch.setenv("DB_PATH", str(p))
|
||||
monkeypatch.setenv("SESSION_SECRET", "s")
|
||||
import db
|
||||
importlib.reload(db)
|
||||
db.init_db()
|
||||
row = db.get_feedback(1)[0]
|
||||
assert row["category"] is None and row["status"] == "new"
|
||||
assert db.count_feedback_new() == 1
|
||||
|
||||
|
||||
def test_status_closes_alert(env):
|
||||
db, client, h, attention = env
|
||||
db.save_feedback("joe@x", "t1", "x", "a", category="failure", source="chat")
|
||||
fid = db.get_feedback(1)[0]["id"]
|
||||
assert db.set_feedback_status(fid, "resolved") is True
|
||||
assert db.count_feedback_new() == 0
|
||||
with pytest.raises(ValueError):
|
||||
db.set_feedback_status(fid, "bad")
|
||||
|
||||
Reference in New Issue
Block a user