mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-15 14:16:05 +00:00
feat: visibility settings
This commit is contained in:
1 parent
f31910569f
commit
160736f075
18 files changed
+359
-101
No files matched your search
@@ -11,34 +11,34 @@ from application.api.answer.services.persistence_policy import (
|
||||
|
||||
@pytest.mark.unit
|
||||
class TestResolvePersistence:
|
||||
def test_first_party_default_lists(self):
|
||||
persist, visibility = resolve_persistence(display_flag=None)
|
||||
assert persist is True
|
||||
assert visibility == VISIBILITY_LISTED
|
||||
|
||||
def test_api_key_caller_defaults_hidden(self):
|
||||
persist, visibility = resolve_persistence(display_flag=None, api_key="k-1")
|
||||
def test_default_is_hidden(self):
|
||||
persist, visibility = resolve_persistence()
|
||||
assert persist is True
|
||||
assert visibility == VISIBILITY_HIDDEN
|
||||
|
||||
def test_shared_usage_defaults_hidden(self):
|
||||
_, visibility = resolve_persistence(display_flag=None, is_shared_usage=True)
|
||||
assert visibility == VISIBILITY_HIDDEN
|
||||
|
||||
def test_explicit_display_true_lists_api_key_caller(self):
|
||||
_, visibility = resolve_persistence(display_flag=True, api_key="k-1")
|
||||
def test_explicit_listed_lists(self):
|
||||
persist, visibility = resolve_persistence(visibility_flag=VISIBILITY_LISTED)
|
||||
assert persist is True
|
||||
assert visibility == VISIBILITY_LISTED
|
||||
|
||||
def test_explicit_display_false_hides_first_party(self):
|
||||
persist, visibility = resolve_persistence(display_flag=False)
|
||||
# Still persisted, just not shown in the sidebar.
|
||||
assert persist is True
|
||||
def test_explicit_hidden_stays_hidden(self):
|
||||
_, visibility = resolve_persistence(visibility_flag=VISIBILITY_HIDDEN)
|
||||
assert visibility == VISIBILITY_HIDDEN
|
||||
|
||||
def test_unknown_visibility_value_falls_back_to_hidden(self):
|
||||
_, visibility = resolve_persistence(visibility_flag="sidebar-please")
|
||||
assert visibility == VISIBILITY_HIDDEN
|
||||
|
||||
def test_non_string_visibility_value_falls_back_to_hidden(self):
|
||||
# Clients sending booleans (e.g. a stray ``visibility: true``) must
|
||||
# not accidentally list — only the exact string "listed" opts in.
|
||||
_, visibility = resolve_persistence(visibility_flag=True)
|
||||
assert visibility == VISIBILITY_HIDDEN
|
||||
|
||||
def test_persist_opt_out(self):
|
||||
persist, _ = resolve_persistence(display_flag=None, persist_flag=False)
|
||||
persist, _ = resolve_persistence(persist_flag=False)
|
||||
assert persist is False
|
||||
|
||||
def test_persist_defaults_true_for_hidden_api_caller(self):
|
||||
persist, _ = resolve_persistence(display_flag=False, api_key="k-1")
|
||||
def test_persist_defaults_true_when_listed(self):
|
||||
persist, _ = resolve_persistence(visibility_flag=VISIBILITY_LISTED)
|
||||
assert persist is True
|
||||
Reference in new issue
Block a user