style(recommender): format demographic integration test
ci / recommender / recommender (push) Successful in 37s
release / release (версия и заметки) (push) Successful in 5s
release / prune (старые файлы и прогоны) (push) Successful in 5s
ci / db / db (push) Successful in 54s
release / android (APK в релиз) (push) Successful in 3m54s
release / desktop (Linux и Windows в релиз) (push) Successful in 12m38s

This commit is contained in:
mrleo1nid committed 2026-10-22 14:25:11 +03:00
1 parent fff91c446b
commit 02307802bc
1 file changed
+12 -3
@@ -186,7 +186,10 @@ def test_impression_features_roundtrip(world: dict[str, Any]) -> None:
def test_demographic_prior_advances_age_and_preserves_own_feedback(world: dict[str, Any]) -> None: def test_demographic_prior_advances_age_and_preserves_own_feedback(world: dict[str, Any]) -> None:
user = uid() user = uid()
with psycopg.connect(DSN, autocommit=True) as conn: with psycopg.connect(DSN, autocommit=True) as conn:
conn.execute("INSERT INTO users (id, username, password_hash) VALUES (%s, %s, 'x')", (user, f"cohort-{user[:6]}")) conn.execute(
"INSERT INTO users (id, username, password_hash) VALUES (%s, %s, 'x')",
(user, f"cohort-{user[:6]}"),
)
# Target selected 13–19 twenty years ago; matching listeners are now 30–39. # Target selected 13–19 twenty years ago; matching listeners are now 30–39.
conn.execute( conn.execute(
"INSERT INTO user_profiles_rec (user_id, onboarding) VALUES (%s, " "INSERT INTO user_profiles_rec (user_id, onboarding) VALUES (%s, "
@@ -204,7 +207,13 @@ def test_demographic_prior_advances_age_and_preserves_own_feedback(world: dict[s
track = world["tracks"][0] # two matching listeners liked it track = world["tracks"][0] # two matching listeners liked it
assert 0 < profile.scores[track] <= 0.25 assert 0 < profile.scores[track] <= 0.25
assert not profile.played assert not profile.played
conn.execute("INSERT INTO track_reactions (user_id, track_id, reaction) VALUES (%s, %s, 'dislike')", (user, track)) conn.execute(
"INSERT INTO track_reactions (user_id, track_id, reaction) VALUES (%s, %s, 'dislike')",
(user, track),
)
assert track not in load_profile(conn, user).scores assert track not in load_profile(conn, user).scores
conn.execute("UPDATE user_profiles_rec SET onboarding = %s WHERE user_id = %s", (json.dumps({"gender": "female"}), user)) conn.execute(
"UPDATE user_profiles_rec SET onboarding = %s WHERE user_id = %s",
(json.dumps({"gender": "female"}), user),
)
assert not load_profile(conn, user).scores, "no invented preferences when the cohort has no evidence" assert not load_profile(conn, user).scores, "no invented preferences when the cohort has no evidence"