feat: add training_export_opt_in field to UserProfile

This commit is contained in:
pyr0ball 2026-05-02 23:32:34 -07:00
parent 148aaf00cb
commit 3b52844382
2 changed files with 22 additions and 0 deletions

View file

@ -29,6 +29,7 @@ _DEFAULTS = {
"tier": "free", "tier": "free",
"dev_tier_override": None, "dev_tier_override": None,
"wizard_complete": False, "wizard_complete": False,
"training_export_opt_in": False,
"wizard_step": 0, "wizard_step": 0,
"dismissed_banners": [], "dismissed_banners": [],
"ui_preference": "streamlit", "ui_preference": "streamlit",
@ -77,6 +78,7 @@ class UserProfile:
self.tier: str = data.get("tier", "free") self.tier: str = data.get("tier", "free")
self.dev_tier_override: str | None = data.get("dev_tier_override") or None self.dev_tier_override: str | None = data.get("dev_tier_override") or None
self.wizard_complete: bool = bool(data.get("wizard_complete", False)) self.wizard_complete: bool = bool(data.get("wizard_complete", False))
self.training_export_opt_in: bool = bool(data.get("training_export_opt_in", False))
self.wizard_step: int = int(data.get("wizard_step", 0)) self.wizard_step: int = int(data.get("wizard_step", 0))
self.dismissed_banners: list[str] = list(data.get("dismissed_banners", [])) self.dismissed_banners: list[str] = list(data.get("dismissed_banners", []))
raw_pref = data.get("ui_preference", "streamlit") raw_pref = data.get("ui_preference", "streamlit")
@ -104,6 +106,7 @@ class UserProfile:
"tier": self.tier, "tier": self.tier,
"dev_tier_override": self.dev_tier_override, "dev_tier_override": self.dev_tier_override,
"wizard_complete": self.wizard_complete, "wizard_complete": self.wizard_complete,
"training_export_opt_in": self.training_export_opt_in,
"wizard_step": self.wizard_step, "wizard_step": self.wizard_step,
"dismissed_banners": self.dismissed_banners, "dismissed_banners": self.dismissed_banners,
"ui_preference": self.ui_preference, "ui_preference": self.ui_preference,

View file

@ -120,3 +120,22 @@ def test_strip_greeting_returns_original_when_no_body(tmp_path):
# A letter that is only a salutation with no body should return the original text # A letter that is only a salutation with no body should return the original text
result = _strip_greeting("Dear Hiring Manager,") result = _strip_greeting("Dear Hiring Manager,")
assert result == "Dear Hiring Manager," assert result == "Dear Hiring Manager,"
def test_user_profile_training_opt_in_defaults_false(tmp_path):
from scripts.user_profile import UserProfile
yaml_path = tmp_path / "user.yaml"
yaml_path.write_text("name: Test\nemail: test@example.com\n")
profile = UserProfile(yaml_path)
assert profile.training_export_opt_in is False
def test_user_profile_training_opt_in_roundtrip(tmp_path):
from scripts.user_profile import UserProfile
yaml_path = tmp_path / "user.yaml"
yaml_path.write_text("name: Test\nemail: test@example.com\n")
profile = UserProfile(yaml_path)
profile.training_export_opt_in = True
profile.save()
reloaded = UserProfile(yaml_path)
assert reloaded.training_export_opt_in is True