Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /GRID-INTELLIGENCE_GRID /tests /unit /search /guardrail /conftest.py
| """Fixtures for guardrail tests.""" | |
| from __future__ import annotations | |
| import pytest | |
| from search.guardrail.tools.base import GuardrailContext | |
| from search.models import RequestContext | |
| def request_context() -> RequestContext: | |
| return RequestContext( | |
| identity="user-123", | |
| index_name="products", | |
| query_text="headphones", | |
| page=1, | |
| size=10, | |
| ip_address="127.0.0.1", | |
| ) | |
| def guardrail_context(request_context, test_config) -> GuardrailContext: | |
| return GuardrailContext(request=request_context, config=test_config) | |
| def guardrail_config_auth_optional(test_config): | |
| """Config with auth not required (for tests that want to bypass auth).""" | |
| from search.config import SearchConfig | |
| cfg = SearchConfig( | |
| embedding_provider=test_config.embedding_provider, | |
| vector_store_backend=test_config.vector_store_backend, | |
| cross_encoder_enabled=test_config.cross_encoder_enabled, | |
| guardrail_auth_required=False, | |
| ) | |
| return cfg | |
| def guardrail_context_no_identity(test_config) -> GuardrailContext: | |
| from search.config import SearchConfig | |
| cfg = SearchConfig( | |
| embedding_provider=test_config.embedding_provider, | |
| vector_store_backend=test_config.vector_store_backend, | |
| cross_encoder_enabled=test_config.cross_encoder_enabled, | |
| guardrail_auth_required=True, | |
| ) | |
| ctx = RequestContext( | |
| identity=None, | |
| index_name="products", | |
| query_text="headphones", | |
| page=1, | |
| size=10, | |
| ) | |
| return GuardrailContext(request=ctx, config=cfg) | |
Xet Storage Details
- Size:
- 1.65 kB
- Xet hash:
- b9cd252de36a814c022fe54a3118626f1f94dc30d88cb36466639e7284c84d0e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.