feat: add optional dashboard config fields
Made-with: Cursor
This commit is contained in:
@@ -12,3 +12,11 @@ class Settings(BaseSettings):
|
||||
soundcloud_user: str = "nicktherat"
|
||||
show_day: int = 2
|
||||
show_hour: int = 22
|
||||
|
||||
web_user: str | None = None
|
||||
web_password: str | None = None
|
||||
secret_key: str | None = None
|
||||
|
||||
@property
|
||||
def dashboard_enabled(self) -> bool:
|
||||
return all([self.web_user, self.web_password, self.secret_key])
|
||||
|
||||
@@ -28,3 +28,27 @@ def test_settings_admin_token_required():
|
||||
import pytest
|
||||
with pytest.raises(Exception):
|
||||
Settings()
|
||||
|
||||
|
||||
def test_dashboard_config_absent(monkeypatch):
|
||||
monkeypatch.setenv("NTR_ADMIN_TOKEN", "tok")
|
||||
monkeypatch.delenv("NTR_WEB_USER", raising=False)
|
||||
monkeypatch.delenv("NTR_WEB_PASSWORD", raising=False)
|
||||
monkeypatch.delenv("NTR_SECRET_KEY", raising=False)
|
||||
s = Settings()
|
||||
assert s.web_user is None
|
||||
assert s.web_password is None
|
||||
assert s.secret_key is None
|
||||
assert s.dashboard_enabled is False
|
||||
|
||||
|
||||
def test_dashboard_config_present(monkeypatch):
|
||||
monkeypatch.setenv("NTR_ADMIN_TOKEN", "tok")
|
||||
monkeypatch.setenv("NTR_WEB_USER", "nick")
|
||||
monkeypatch.setenv("NTR_WEB_PASSWORD", "secret")
|
||||
monkeypatch.setenv("NTR_SECRET_KEY", "signme")
|
||||
s = Settings()
|
||||
assert s.web_user == "nick"
|
||||
assert s.web_password == "secret"
|
||||
assert s.secret_key == "signme"
|
||||
assert s.dashboard_enabled is True
|
||||
|
||||
Reference in New Issue
Block a user