repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
onyx | backend/tests/unit/onyx/connectors/cross_connector_utils/test_rate_limit.py | .py | import time
from typing import Any, cast
import pytest
import requests
from onyx.connectors.cross_connector_utils.rate_limit_wrapper import (
rate_limit_builder,
wrap_request_to_handle_ratelimiting,
)
def test_rate_limit_basic() -> None:
call_cnt = 0
@rate_limit_builder(max_calls=2, period=5)
d... | 67 | 1,803 |
onyx | backend/tests/unit/onyx/connectors/cross_connector_utils/test_section_text_cap.py | .py | """Per-file extracted-text cap for connector conversions: sources that can't be
size-checked before fetch (e.g. Google-native files carry no `size` metadata)
must still have the text they retain per file bounded."""
from unittest.mock import patch
from onyx.connectors.cross_connector_utils.section_utils import cap_se... | 67 | 2,460 |
onyx | backend/tests/unit/onyx/connectors/cross_connector_utils/test_html_utils.py | .py | import pathlib
import pytest
import onyx.file_processing.html_utils as html_utils
from onyx.file_processing.enums import HtmlBasedConnectorTransformLinksStrategy
from onyx.file_processing.html_utils import parse_html_page_basic
def test_parse_table() -> None:
dir_path = pathlib.Path(__file__).parent.resolve()
... | 50 | 1,445 |
onyx | backend/tests/unit/onyx/connectors/cross_connector_utils/test_miscellaneous_utils.py | .py | import datetime
import pytest
from onyx.connectors.cross_connector_utils.miscellaneous_utils import time_str_to_utc
def test_time_str_to_utc() -> None:
str_to_dt = {
"Tue, 5 Oct 2021 09:38:25 GMT": datetime.datetime(
2021, 10, 5, 9, 38, 25, tzinfo=datetime.timezone.utc
),
"Sa... | 54 | 1,964 |
onyx | backend/tests/unit/onyx/connectors/sharepoint/test_slim_and_validation.py | .py | """Unit tests for SharepointConnector site-page slim resilience and
validate_connector_settings RoleAssignments permission probe."""
from __future__ import annotations
from unittest.mock import MagicMock, patch
import pytest
from onyx.connectors.exceptions import ConnectorValidationError
from onyx.connectors.models... | 447 | 16,449 |
onyx | backend/tests/unit/onyx/connectors/sharepoint/test_url_parsing.py | .py | from __future__ import annotations
from onyx.connectors.sharepoint.connector import SharepointConnector
def test_extract_site_and_drive_info_from_share_link() -> None:
url = "https://tenant.sharepoint.com/:f:/r/sites/SampleSite/Shared%20Documents/Sample%20Folder"
site_descriptors = SharepointConnector._extr... | 30 | 1,122 |
onyx | backend/tests/unit/onyx/connectors/sharepoint/test_fetch_site_pages.py | .py | """Unit tests for SharepointConnector._fetch_site_pages error handling.
Covers 404 handling (classic sites / no modern pages) and 400
canvasLayout fallback (corrupt pages causing $expand=canvasLayout to
fail on the LIST endpoint), plus the per-site failure classifier and
propagation of `site.execute_query()` 404s out ... | 449 | 17,346 |
onyx | backend/tests/unit/onyx/connectors/sharepoint/test_load_credentials.py | .py | """Unit tests for SharepointConnector.load_credentials sp_tenant_domain resolution."""
from __future__ import annotations
import base64
from unittest.mock import MagicMock, patch
from onyx.connectors.sharepoint.connector import SharepointConnector
SITE_URL = "https://mytenant.sharepoint.com/sites/MySite"
EXPECTED_T... | 101 | 3,888 |
onyx | backend/tests/unit/onyx/connectors/sharepoint/test_hierarchy_helpers.py | .py | """Unit tests for SharePoint connector hierarchy helper functions."""
from __future__ import annotations
from unittest.mock import MagicMock, patch
from onyx.access.models import ExternalAccess
from onyx.connectors.sharepoint.connector import (
SharepointConnector,
SharepointConnectorCheckpoint,
SiteDesc... | 179 | 6,141 |
onyx | backend/tests/unit/onyx/connectors/sharepoint/test_delta_checkpointing.py | .py | """Tests for per-page delta checkpointing in the SharePoint connector (P1-1).
Validates that:
- Delta drives process one page per _load_from_checkpoint call
- Checkpoints persist the delta next_link for resumption
- Crash + resume skips already-processed pages
- BFS (folder-scoped) drives process all items in one call... | 688 | 25,578 |
onyx | backend/tests/unit/onyx/connectors/sharepoint/test_load_checkpoint_resilience.py | .py | """Tests for resilience wrappers added to SharepointConnector._load_from_checkpoint.
Covers three failure modes that previously aborted the whole attempt:
- G1: BFS-mode generator (`_iter_drive_items_paged`) raising mid-iteration.
- G2: `_fetch_site_pages` raising a non-Graph 4xx in Phase 5.
- G3: A single site page f... | 476 | 17,643 |
onyx | backend/tests/unit/onyx/connectors/sharepoint/test_streaming_download_retry.py | .py | """Unit tests for streaming-download retry behavior in the SharePoint connector.
SharePoint and the Microsoft Graph API occasionally drop the TCP connection
mid-body (surfaces as ``ChunkedEncodingError: IncompleteRead``). The download
helpers must transparently retry these transport-level failures with a fresh
HTTP re... | 317 | 12,204 |
onyx | backend/tests/unit/onyx/connectors/sharepoint/test_graph_api_get_json_retry.py | .py | """Unit tests for SharepointConnector._graph_api_get_json retry behavior.
Covers the empty/non-JSON 2xx body case: Microsoft Graph intermittently returns
a body-less response under load (gateway-shed throttling, backend list-view
timeouts on large libraries, mid-response connection drops). The bare
response.json() use... | 102 | 3,723 |
onyx | backend/tests/unit/onyx/connectors/sharepoint/test_drive_matching.py | .py | from __future__ import annotations
from collections import deque
from collections.abc import Generator, Sequence
from datetime import datetime, timezone
from typing import Any
import pytest
from onyx.connectors.models import Document, DocumentSource, TextSection
from onyx.connectors.sharepoint.connector import (
... | 593 | 19,939 |
onyx | backend/tests/unit/onyx/connectors/sharepoint/test_rest_client_context_caching.py | .py | """Unit tests for SharepointConnector._create_rest_client_context caching."""
from __future__ import annotations
from unittest.mock import MagicMock, patch
from onyx.connectors.sharepoint.connector import (
_REST_CTX_MAX_AGE_S,
SharepointConnector,
)
SITE_A = "https://tenant.sharepoint.com/sites/SiteA"
SITE... | 138 | 4,977 |
onyx | backend/tests/unit/onyx/connectors/sharepoint/test_denylist.py | .py | from __future__ import annotations
import pytest
from onyx.connectors.sharepoint.connector import (
DriveItemData,
SharepointConnector,
SiteDescriptor,
_build_item_relative_path,
_is_path_excluded,
_is_site_excluded,
)
class TestIsSiteExcluded:
def test_exact_match(self) -> None:
... | 218 | 7,348 |
onyx | backend/tests/unit/onyx/connectors/lumapps/test_lumapps_utils.py | .py | """Unit tests for the LumApps connector's pure helpers (no API / services)."""
from onyx.connectors.lumapps.utils import (
extract_body_text,
pick_lang,
resolve_metadata_labels,
slugify_family_key,
)
def test_slugify_family_key() -> None:
assert slugify_family_key("News type") == "news_type"
... | 95 | 3,469 |
onyx | backend/tests/unit/onyx/connectors/lumapps/test_lumapps_connector.py | .py | from datetime import datetime, timezone
from typing import Any
from unittest.mock import MagicMock
import pytest
from onyx.connectors.exceptions import ConnectorValidationError
from onyx.connectors.lumapps.connector import LumAppsConnector, _parse_dt
from onyx.connectors.models import Document, SlimDocument
def _ma... | 146 | 4,946 |
onyx | backend/tests/unit/onyx/connectors/lumapps/test_lumapps_client.py | .py | """Unit tests for the LumApps client's retry/auth behavior (mocked HTTP)."""
import time
from typing import Any
from unittest.mock import MagicMock
import pytest
import requests
from onyx.connectors.lumapps.client import LumAppsClientError, OnyxLumApps
def _client_with_token() -> tuple[OnyxLumApps, MagicMock]:
... | 195 | 6,974 |
onyx | backend/tests/unit/onyx/connectors/jira/test_jira_error_handling.py | .py | """Tests for Jira connector error handling during indexing."""
import time
from unittest.mock import MagicMock
import pytest
from jira import JIRA, JIRAError
from onyx.connectors.exceptions import (
ConnectorValidationError,
CredentialExpiredError,
InsufficientPermissionsError,
)
from onyx.connectors.jir... | 187 | 7,007 |
onyx | backend/tests/unit/onyx/connectors/jira/test_jira_bulk_fetch.py | .py | from typing import Any
from unittest.mock import MagicMock
import pytest
import requests
from jira import JIRA
from jira.resources import Issue
from onyx.connectors.jira.connector import _JIRA_BULK_FETCH_LIMIT, bulk_fetch_issues
def _make_raw_issue(issue_id: str) -> dict[str, Any]:
return {
"id": issue_... | 174 | 5,768 |
onyx | backend/tests/unit/onyx/connectors/jira/test_jira_slim_retrieval.py | .py | from typing import Any
from unittest.mock import MagicMock, patch
from jira.resources import Issue
from onyx.access.models import ExternalAccess
from onyx.connectors.jira.connector import JiraConnector, JiraConnectorCheckpoint
from onyx.connectors.models import SlimDocument
def _make_issue(key: str, project_key: st... | 123 | 4,229 |
onyx | backend/tests/unit/onyx/connectors/jira/test_jira_checkpointing.py | .py | import time
from collections.abc import Callable, Generator
from datetime import datetime, timezone
from typing import Any, cast
from unittest.mock import MagicMock, patch
import pytest
from jira import JIRA, JIRAError
from jira.resources import Issue
from onyx.configs.constants import DocumentSource
from onyx.connec... | 442 | 17,386 |
onyx | backend/tests/unit/onyx/connectors/jira/test_jira_permission_sync.py | .py | from datetime import datetime, timezone
from unittest.mock import MagicMock, patch
import pytest
from ee.onyx.external_permissions.jira.doc_sync import jira_doc_sync
from onyx.connectors.jira.connector import JiraConnector
from onyx.connectors.jira.utils import JIRA_SERVER_API_VERSION
from onyx.db.models import Conne... | 141 | 5,152 |
onyx | backend/tests/unit/onyx/connectors/jira/test_jira_large_ticket_handling.py | .py | from collections.abc import Generator
from typing import Any
from unittest.mock import MagicMock, patch
import pytest
from jira.resources import Issue
from pytest_mock import MockFixture
from onyx.connectors.jira.connector import _perform_jql_search, process_jira_issue
@pytest.fixture
def mock_jira_client() -> Magi... | 166 | 5,538 |
onyx | backend/tests/unit/onyx/connectors/jira/conftest.py | .py | from collections.abc import Generator
from unittest.mock import MagicMock, patch
import pytest
from jira import JIRA
from onyx.connectors.jira.connector import JiraConnector
@pytest.fixture
def jira_base_url() -> str:
return "https://jira.example.com"
@pytest.fixture
def project_key() -> str:
return "TEST... | 57 | 1,461 |
onyx | backend/tests/unit/onyx/connectors/box/test_box_access.py | .py | from datetime import datetime, timezone
from typing import cast
import pytest
from box_sdk_gen import BoxClient
from box_sdk_gen.schemas.collaboration import (
Collaboration,
CollaborationRoleField,
CollaborationStatusField,
)
from box_sdk_gen.schemas.file_full import FileFull
from box_sdk_gen.schemas.fold... | 316 | 10,748 |
onyx | backend/tests/unit/onyx/connectors/box/fake_box_client.py | .py | """Duck-typed stand-in for box_sdk_gen's BoxClient, covering the managers the
Box connector touches. Backed by real box_sdk_gen schema objects so the
connector exercises the same attribute access paths as against the live API."""
from io import BytesIO
from box_sdk_gen.box.errors import BoxAPIError, RequestInfo, Resp... | 245 | 8,904 |
onyx | backend/tests/unit/onyx/connectors/box/test_box_connector.py | .py | from datetime import datetime, timezone
from typing import cast
from unittest.mock import MagicMock
import pytest
from box_sdk_gen import BoxCCGAuth, BoxClient
from box_sdk_gen.schemas.file_full import FileFull
from box_sdk_gen.schemas.folder_full import FolderFull
from box_sdk_gen.schemas.folder_mini import FolderMin... | 731 | 26,817 |
onyx | backend/tests/unit/onyx/connectors/box/conftest.py | .py | from collections.abc import Generator
from unittest.mock import MagicMock, patch
import pytest
@pytest.fixture(autouse=True)
def mock_get_unstructured_api_key() -> Generator[MagicMock, None, None]:
with patch(
"onyx.file_processing.extract_file_text.get_unstructured_api_key",
return_value=None,
... | 14 | 353 |
onyx | backend/tests/unit/onyx/connectors/hubspot/test_hubspot_inline_associations.py | .py | from __future__ import annotations
from datetime import datetime, timezone
from typing import Any
from unittest.mock import MagicMock, patch
from onyx.connectors.hubspot.connector import HubSpotConnector
def _make_connector() -> HubSpotConnector:
c = HubSpotConnector()
c._access_token = "token"
c._porta... | 331 | 12,082 |
onyx | backend/tests/unit/onyx/connectors/slack/test_message_filtering.py | .py | import pytest
from onyx.connectors.slack.connector import (
SlackConnector,
SlackMessageFilterReason,
_bot_inclusive_msg_filter,
default_msg_filter,
)
from onyx.connectors.slack.models import MessageType
# -- default_msg_filter tests --
@pytest.mark.parametrize(
"message,expected_reason",
[
... | 153 | 4,723 |
onyx | backend/tests/unit/onyx/connectors/slack/test_enterprise_grid.py | .py | """Unit tests for Slack Enterprise Grid helpers.
These tests exercise the Grid-specific code paths added to the Slack connector
using a mocked Slack ``WebClient``. They do not hit the real Slack API.
"""
from typing import Any, cast
from unittest.mock import MagicMock, patch
import pytest
from slack_sdk.errors impor... | 314 | 12,114 |
onyx | backend/tests/unit/onyx/connectors/slack/test_slack_filter_channels.py | .py | """Channel include/exclude filtering for the Slack connector: excludes apply
after includes, support exact-name and full-match regex modes, and never fail
on names absent from the workspace."""
from typing import Any, cast
import pytest
from onyx.connectors.exceptions import ConnectorValidationError
from onyx.connec... | 135 | 3,627 |
onyx | backend/tests/unit/onyx/connectors/slack/test_slack_source_operations.py | .py | """Pins the Slack source-operations gateway: inventory, variants, clients.
The operation table is the living enumeration of every Slack remote interaction;
these tests keep it and the client-construction unification honest.
"""
from typing import Any, cast
from unittest.mock import MagicMock
import pytest
from onyx... | 224 | 7,636 |
onyx | backend/tests/unit/onyx/connectors/slack/test_lazy_workspace_metadata.py | .py | """Unit tests for lazy resolution of Slack workspace metadata.
Workspace URL and Enterprise Grid topology are resolved when an indexing entry
point primes them, not when credentials are set. The coordinated client
serializes on a Redis lock shared with running indexing jobs, so resolving
eagerly lets a rate-limited in... | 273 | 10,678 |
onyx | backend/tests/unit/onyx/connectors/slack/test_slack_capability_checks.py | .py | """Behavior tests for the Slack capability checks.
Checks compose gateway operations, so every test runs a check against an
autospecced ``SlackSourceOperations`` whose operations return the gateway's
typed page models; probe reach (which operations each check exercises) is
enforced separately by the auto-discovering c... | 928 | 32,812 |
onyx | backend/tests/unit/onyx/connectors/salesforce/test_salesforce_sqlite.py | .py | import csv
import json
import os
import shutil
import tempfile
import time
from collections import defaultdict
from datetime import datetime, timezone
from pathlib import Path
from typing import cast
import pytest
from onyx.configs.constants import DocumentSource
from onyx.connectors.cross_connector_utils.miscellaneo... | 1,221 | 43,413 |
onyx | backend/tests/unit/onyx/connectors/salesforce/test_yield_doc_batches.py | .py | """Unit tests for _yield_doc_batches and metadata type conversion in SalesforceConnector."""
from typing import Any
from unittest.mock import MagicMock, patch
import pytest
from onyx.configs.constants import DocumentSource
from onyx.connectors.models import Document
from onyx.connectors.salesforce.connector import (... | 510 | 17,955 |
onyx | backend/tests/unit/onyx/connectors/salesforce/test_salesforce_utils.py | .py | import pytest
from onyx.connectors.salesforce.utils import (
is_valid_sf_identifier,
validate_sf_identifier,
)
class TestSfIdentifier:
@pytest.mark.parametrize(
"name",
[
"Account",
"Contact",
"User",
"MyCustomObject__c",
"ns__My... | 47 | 1,172 |
onyx | backend/tests/unit/onyx/connectors/salesforce/test_salesforce_custom_config.py | .py | #!/usr/bin/env python3
"""
Test script for the new custom query configuration functionality in SalesforceConnector.
This demonstrates how to use the new custom_query_config parameter to specify
exactly which fields and associations (child objects) to retrieve for each object type.
"""
import json
from typing import A... | 131 | 4,221 |
onyx | backend/tests/unit/onyx/connectors/freshdesk/test_freshdesk_pagination.py | .py | """Unit tests for the Freshdesk connector's pagination window-rolling.
Freshdesk's ``/api/v2/tickets`` endpoint hard-caps pagination at 300 pages
and returns 400 for ``page >= 301``. To get past that on accounts with
more than ``per_page * 300`` matching tickets, the connector restarts at
page 1 with ``updated_since``... | 111 | 4,090 |
onyx | backend/tests/unit/onyx/connectors/freshdesk/test_freshdesk_due_by.py | .py | """Unit tests for Freshdesk connector handling of nullable timestamp fields.
Reproduces the production traceback:
File "/app/onyx/connectors/freshdesk/connector.py", line 131
due_by = datetime.fromisoformat(ticket["due_by"].replace("Z", "+00:00"))
AttributeError: 'NoneType' object has no attribute 're... | 66 | 2,455 |
onyx | backend/tests/unit/onyx/connectors/linear/test_linear_load_credentials.py | .py | """Unit tests for LinearConnector OAuth token refresh logic."""
from __future__ import annotations
import time
from typing import Any
from unittest.mock import MagicMock, patch
import pytest
from onyx.connectors.linear.connector import LinearConnector
from onyx.connectors.models import ConnectorMissingCredentialErr... | 205 | 7,338 |
onyx | backend/tests/unit/onyx/connectors/github/test_github_slim_connector.py | .py | """
Tests verifying that GithubConnector implements SlimConnector and SlimConnectorWithPermSync
correctly, and that pruning uses the cheap slim path (no lazy loading).
"""
from collections.abc import Generator
from unittest.mock import MagicMock, PropertyMock, patch
import pytest
from onyx.access.models import Exter... | 170 | 6,479 |
onyx | backend/tests/unit/onyx/connectors/github/test_github_files.py | .py | import time
from collections.abc import Callable
from datetime import datetime, timezone
from unittest.mock import MagicMock, patch
import pytest
from github import Github
from github.GithubException import GithubException, UnknownObjectException
from github.RateLimit import RateLimit
from github.Requester import Requ... | 549 | 20,039 |
onyx | backend/tests/unit/onyx/connectors/github/test_github_checkpointing.py | .py | import time
from collections.abc import Callable, Generator
from datetime import datetime, timezone
from typing import cast
from unittest.mock import MagicMock, patch
import pytest
from github import Github, RateLimitExceededException
from github.GithubException import GithubException
from github.Issue import Issue
fr... | 953 | 36,246 |
onyx | backend/tests/unit/onyx/connectors/blob/test_blob_connector_region.py | .py | from typing import Any, cast
from unittest.mock import MagicMock, patch
import pytest
from botocore.exceptions import ClientError
from onyx.configs.constants import BlobType
from onyx.connectors.blob.connector import BlobStorageConnector
from onyx.connectors.exceptions import (
CredentialExpiredError,
Insuffi... | 136 | 4,793 |
onyx | backend/tests/unit/onyx/connectors/braintrust/test_braintrust_connector.py | .py | import re
import time
from collections.abc import Iterator
from datetime import datetime, timedelta, timezone
from typing import IO, Any
from unittest.mock import patch
import pytest
from onyx.connectors.braintrust.connector import (
BraintrustCheckpoint,
BraintrustConnector,
)
from onyx.connectors.models imp... | 381 | 13,506 |
onyx | backend/tests/unit/onyx/connectors/zendesk/test_zendesk_checkpointing.py | .py | import time
from collections.abc import Callable, Generator
from typing import Any, cast
from unittest.mock import MagicMock, patch
import pytest
from requests.exceptions import HTTPError
from onyx.configs.constants import DocumentSource
from onyx.connectors.exceptions import (
ConnectorValidationError,
Crede... | 476 | 15,749 |
onyx | backend/tests/unit/onyx/connectors/zendesk/test_zendesk_rate_limit.py | .py | from __future__ import annotations
import types
from typing import Any, Dict
import pytest
class _FakeTime:
"""A controllable time module replacement.
- monotonic(): returns an internal counter (seconds)
- sleep(x): advances the internal counter by x seconds
"""
def __init__(self) -> None:
... | 87 | 2,839 |
onyx | backend/tests/unit/onyx/connectors/web/test_doc_updated_at.py | .py | """Unit test: the web connector must not derive doc_updated_at from Last-Modified.
A server's HTTP Last-Modified header is an unreliable change signal β CDN/SSR
origins (e.g. Vercel ISR) regenerate it on every fetch, so it advances on each
crawl even when content is identical. Letting it populate doc_updated_at makes ... | 89 | 3,199 |
onyx | backend/tests/unit/onyx/connectors/web/test_ssrf_protection.py | .py | """The web connector must not fetch internal/loopback targets (SSRF) anywhere in
its lifecycle β sitemap construction, validation, or indexing β at the default
VALIDATE_ALL level. Covers the recursive and sitemap paths (ON-001 / ON-002).
Targets use literal IPs so socket.getaddrinfo resolves locally (hermetic).
"""
f... | 85 | 3,289 |
onyx | backend/tests/unit/onyx/connectors/web/test_slim_retrieval.py | .py | """Unit tests for WebConnector.retrieve_all_slim_docs (slim pruning path)."""
from __future__ import annotations
from typing import Any
from unittest.mock import MagicMock, patch
import pytest
from onyx.connectors.models import SlimDocument
from onyx.connectors.web.connector import WEB_CONNECTOR_VALID_SETTINGS, Web... | 255 | 8,693 |
onyx | backend/tests/unit/onyx/connectors/web/test_url_rewrites.py | .py | """Unit tests for the web connector's URL rewrite helpers."""
from unittest.mock import patch
from onyx.configs.constants import DocumentSource
from onyx.connectors.models import Document, TextSection
from onyx.connectors.web.connector import (
_URL_REWRITES_ADAPTER,
ScrapeResult,
UrlRewriteRule,
WebC... | 157 | 5,182 |
onyx | backend/tests/unit/onyx/connectors/notion/test_notion_slim_retrieval.py | .py | """Tests for the Notion slim (pruning) enumeration.
Pruning deletes any indexed doc the enumeration does not return, so the core
guarantee is coverage: `retrieve_all_slim_docs` must return every ID the full
load path indexes β including pages the search API misses (child pages and
database rows found only by block tra... | 291 | 10,555 |
onyx | backend/tests/unit/onyx/connectors/notion/test_notion_database_parent_hierarchy.py | .py | """Tests for standalone-database parent page hierarchy node emission.
When _yield_database_hierarchy_nodes discovers that a database's parent is a
page, it records that page ID in _database_parent_page_ids. _read_pages then
emits a hierarchy node for that page even if its BlockReadOutput is empty
(no child pages, no ... | 168 | 6,145 |
onyx | backend/tests/unit/onyx/connectors/notion/test_notion_datasource.py | .py | """Unit tests for Notion connector data source API migration.
Tests the new data source discovery + querying flow and the
data_source_id -> database_id parent resolution.
"""
from unittest.mock import MagicMock, patch
from requests.exceptions import HTTPError
from onyx.connectors.notion.connector import (
Notio... | 323 | 11,199 |
onyx | backend/tests/unit/onyx/connectors/notion/test_notion_block_recursion.py | .py | """Regression tests for unbounded recursion in the Notion connector.
A prod page with ~919 nested blocks overflowed `_read_blocks` and crashed the
index attempt. Two triggers are covered: deep nesting (blocks and child pages)
and reference cycles (e.g. mutually-nested synced blocks).
"""
import sys
from typing import... | 226 | 8,420 |
onyx | backend/tests/unit/onyx/connectors/notion/test_notion_people_and_tables.py | .py | """Unit tests for Notion connector handling of people properties and table blocks.
Reproduces two bugs:
1. ENG-3970: People-type database properties (user mentions) are not extracted β
the user's "name" field is lost when _recurse_properties drills into the
"person" sub-dict.
2. ENG-3971: Inline table blocks (ta... | 319 | 10,941 |
onyx | backend/tests/unit/onyx/connectors/capability_checks/test_registry_fallbacks.py | .py | from unittest.mock import MagicMock
import pytest
from onyx.configs.constants import DocumentSource
from onyx.connectors import source_operations as source_operations_module
from onyx.connectors.capability_checks import registry
from onyx.connectors.capability_checks.models import (
CapabilityCheck,
Capabilit... | 108 | 3,662 |
onyx | backend/tests/unit/onyx/connectors/capability_checks/test_capability_check_ratchet.py | .py | import pytest
from ee.onyx.connectors import capability_checks as ee_capability_checks
from ee.onyx.connectors.capability_checks import get_perm_sync_capability_checks
from onyx.configs.constants import DocumentSource
from onyx.connectors import source_operations as source_operations_module
from onyx.connectors.capabi... | 156 | 5,295 |
onyx | backend/tests/unit/onyx/connectors/capability_checks/test_capability_check_runner.py | .py | import time
from collections.abc import Callable
from typing import cast
from unittest.mock import MagicMock
import pytest
from onyx.configs.constants import DocumentSource
from onyx.connectors.capability_checks.models import (
CapabilityCheck,
CapabilityCheckContext,
CapabilityCheckStatus,
Credential... | 383 | 12,114 |
onyx | backend/tests/unit/onyx/connectors/capability_checks/test_verdict_aggregation.py | .py | from onyx.connectors.capability_checks.models import (
CapabilityCheckResult,
CapabilityCheckStatus,
CapabilityVerdict,
CredentialCapability,
aggregate_capability_verdict,
compute_capability_verdicts,
)
def _result(
status: CapabilityCheckStatus,
required: bool = True,
capability: ... | 233 | 7,435 |
onyx | backend/tests/unit/onyx/connectors/capability_checks/test_generate_capability_report.py | .py | from collections.abc import Callable
from unittest.mock import MagicMock
import pytest
from onyx.configs.constants import DocumentSource
from onyx.connectors.capability_checks import runner as runner_module
from onyx.connectors.capability_checks.models import (
CapabilityCheck,
CapabilityCheckContext,
Cap... | 341 | 11,443 |
onyx | backend/tests/unit/onyx/utils/test_mask_credential_whitelist.py | .py | """mask_credential_dict must pass whitelisted keys through whole (any value
type) while non-whitelisted strings and lists stay masked, so non-secret
lists like OAuth scopes survive an admin-UI round trip."""
from onyx.utils.encryption import mask_credential_dict
def test_whitelisted_list_passes_through_unmasked() ->... | 24 | 937 |
onyx | backend/tests/unit/onyx/utils/test_retry_wrapper.py | .py | """Unit tests for retry_builder (tenacity-backed retry decorator)."""
import pytest
from onyx.utils.retry_wrapper import retry_builder
def test_retry_builder_succeeds_after_transient_failures() -> None:
"""A function failing twice then succeeding returns the success value
and is called exactly 3 times."""
... | 55 | 1,692 |
onyx | backend/tests/unit/onyx/utils/test_audit.py | .py | """Unit tests for the generalized audit-event subsystem (``onyx.utils.audit``).
These cover the invariants the subsystem must never violate: a stable
OCSF-shaped schema, never logging a secret, never raising on missing context,
and Redis-backed dedup that degrades safely when Redis is unavailable.
"""
import io
impor... | 233 | 8,157 |
onyx | backend/tests/unit/onyx/utils/test_threadpool_contextvars.py | .py | import contextvars
import time
from onyx.utils.threadpool_concurrency import (
FunctionCall,
run_functions_in_parallel,
run_functions_tuples_in_parallel,
run_in_background,
run_with_timeout,
start_thread_with_context,
wait_on_background,
)
# Create a test contextvar
test_var = contextvars.... | 207 | 6,704 |
onyx | backend/tests/unit/onyx/utils/test_retry_after.py | .py | from datetime import datetime, timedelta, timezone
from email.utils import format_datetime
import pytest
from onyx.utils.retry_after import parse_retry_after_seconds
@pytest.mark.parametrize(
"value,expected",
[
("0", 0.0),
("1", 1.0),
("120", 120.0),
("12.5", 12.5),
... | 55 | 1,791 |
onyx | backend/tests/unit/onyx/utils/test_client_ip.py | .py | """Unit tests for get_client_ip, current_client_ip, and ClientIPMiddleware."""
from unittest.mock import MagicMock
from fastapi import FastAPI, Request
from fastapi.testclient import TestClient
from onyx.utils.client_ip import ClientIPMiddleware, current_client_ip, get_client_ip
def _fake_request(
*, xff: str ... | 123 | 4,373 |
onyx | backend/tests/unit/onyx/utils/test_sanitize_next_url.py | .py | import pytest
from onyx.utils.url import sanitize_next_url
@pytest.mark.parametrize(
"value",
[
# scheme-bearing payloads
"javascript:alert(1)",
"https://evil.example.com",
"http://evil.example.com/path",
"data:text/html,<script>alert(1)</script>",
# protocol-r... | 49 | 1,256 |
onyx | backend/tests/unit/onyx/utils/test_vespa_tasks.py | .py | from types import SimpleNamespace
from typing import Any
from onyx.background.celery.tasks.vespa import tasks as vespa_tasks
class _StubRedisDocumentSet:
"""Lightweight stand-in for RedisDocumentSet used by monitor tests."""
reset_called = False
@staticmethod
def get_id_from_fence_key(key: str) -> ... | 103 | 3,117 |
onyx | backend/tests/unit/onyx/utils/test_tls.py | .py | import datetime as dt
import ssl
from pathlib import Path
import certifi
import pytest
from cryptography import x509
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.x509.oid import NameOID
from onyx.utils.tls import build_ssl... | 80 | 2,580 |
onyx | backend/tests/unit/onyx/utils/test_third_party_log_cap.py | .py | import logging
from collections.abc import Generator
import pytest
import onyx.utils.logger as logger_module
from onyx.utils.logger import (
LITELLM_NATIVE_LOGGER_NAMES,
THIRD_PARTY_CAPPED_LOGGER_NAMES,
cap_third_party_log_levels,
remove_litellm_native_log_handlers,
)
@pytest.fixture(autouse=True)
d... | 136 | 5,018 |
onyx | backend/tests/unit/onyx/utils/test_os_reaper.py | .py | """Validate subreaper adoption + zombie draining (Linux-only).
Each scenario runs in an isolated subprocess so the subreaper flag and the
waitpid(-1) drains never touch the pytest process. Harnesses end with a
kill-everything finally so a failed assertion can't leave a sleeping
grandchild holding the captured stdout/s... | 205 | 5,758 |
onyx | backend/tests/unit/onyx/utils/test_postgres_sanitization.py | .py | from pytest import MonkeyPatch
from onyx.access.models import ExternalAccess
from onyx.connectors.models import (
BasicExpertInfo,
Document,
DocumentSource,
HierarchyNode,
IndexAttemptMetadata,
TextSection,
)
from onyx.db.enums import HierarchyNodeType
from onyx.indexing import indexing_pipelin... | 234 | 7,921 |
onyx | backend/tests/unit/onyx/utils/test_url_ssrf.py | .py | """
Unit tests for SSRF protection in URL validation utilities.
These tests verify that the SSRF protection correctly blocks
requests to internal/private IP addresses and other potentially dangerous destinations.
"""
from unittest.mock import MagicMock, patch
import pytest
from onyx.utils.url import (
SSRFExcep... | 603 | 28,382 |
onyx | backend/tests/unit/onyx/utils/test_vespa_query.py | .py | from datetime import datetime, timedelta, timezone
from onyx.configs.constants import INDEX_SEPARATOR, DocumentSource
from onyx.context.search.models import IndexFilters, Tag, TimeRange
from onyx.document_index.vespa.shared_utils.vespa_request_builders import (
build_vespa_filters,
)
from onyx.document_index.vespa... | 364 | 15,168 |
onyx | backend/tests/unit/onyx/utils/test_telemetry.py | .py | from typing import Any
from unittest.mock import Mock
from onyx.configs.constants import MilestoneRecordType
from onyx.utils import telemetry as telemetry_utils
class CloudIdentifyHarness:
def __init__(
self,
*,
mapped_tenant_id: str = "tenant_dev",
anon_id: str | None = None,
... | 188 | 6,130 |
onyx | backend/tests/unit/onyx/utils/test_csv_utils.py | .py | import pytest
from onyx.utils.csv_utils import (
sanitize_csv_cell,
sanitize_csv_cell_or_none,
sanitize_csv_row,
)
@pytest.mark.parametrize(
"value,expected",
[
# Formula-trigger prefixes get neutralized with a leading quote
("=cmd|' /C calc'!A1", "'=cmd|' /C calc'!A1"),
(... | 64 | 2,057 |
onyx | backend/tests/unit/onyx/utils/test_sensitive.py | .py | """Tests for SensitiveValue wrapper class."""
import json
from typing import Any
import pytest
from onyx.utils.encryption import mask_env_value_for_logging
from onyx.utils.sensitive import SensitiveAccessError, SensitiveValue
def _encrypt_string(value: str) -> bytes:
"""Simple mock encryption (just encoding fo... | 293 | 10,452 |
onyx | backend/tests/unit/onyx/utils/test_threadpool_concurrency.py | .py | import contextvars
import threading
import time
from collections.abc import Generator, Iterator
from concurrent.futures import ThreadPoolExecutor
import pytest
from onyx.utils.threadpool_concurrency import (
ThreadSafeDict,
parallel_yield,
run_in_background,
run_with_timeout,
wait_on_background,
)... | 395 | 12,379 |
onyx | backend/tests/unit/onyx/utils/test_gpu_utils.py | .py | """
Test cases for onyx/utils/gpu_utils.py with DISABLE_MODEL_SERVER environment variable
"""
import os
from unittest import TestCase
from unittest.mock import MagicMock, patch
import requests
from onyx.utils.gpu_utils import _get_gpu_status_from_model_server
class TestGPUUtils(TestCase):
"""Test cases for GPU... | 103 | 4,459 |
onyx | backend/tests/unit/onyx/utils/test_parse_bracketed_list.py | .py | from __future__ import annotations
import pytest
from onyx.utils.text_processing import parse_bracketed_list
@pytest.mark.parametrize(
"content, expected",
[
("[zendesk, asana]", ["zendesk", "asana"]),
('["zendesk", "asana"]', ["zendesk", "asana"]),
("[zendesk]", ["zendesk"]),
... | 25 | 854 |
onyx | backend/tests/unit/onyx/utils/test_github.py | .py | """Unit tests for onyx.utils.github."""
from collections.abc import Iterable
from unittest.mock import MagicMock, patch
import pytest
import requests
from onyx.error_handling.error_codes import OnyxErrorCode
from onyx.error_handling.exceptions import OnyxError
from onyx.utils.github import (
GitHubSource,
do... | 226 | 8,018 |
onyx | backend/tests/unit/onyx/utils/test_process_isolation.py | .py | """The process-isolation helper must convert a native child crash and a hang into
typed parent-side exceptions, while passing normal return values and ordinary
exceptions through unchanged."""
import ctypes
import multiprocessing as mp
import operator
import os
import time
import pytest
from onyx.utils.process_isola... | 79 | 2,521 |
onyx | backend/tests/unit/onyx/utils/test_datetime_utils.py | .py | """Unit tests for onyx.utils.datetime window helpers."""
import datetime
import pytest
from onyx.utils.datetime import get_window_start
class TestGetWindowStart:
def test_weekly_aligns_to_monday(self) -> None:
# 2026-06-03 is a Wednesday.
dt = datetime.datetime(2026, 6, 3, 14, 22, tzinfo=dateti... | 39 | 1,622 |
onyx | backend/tests/unit/onyx/utils/test_sensitive_typing.py | .py | """
Tests demonstrating static type checking for SensitiveValue.
Run with: mypy tests/unit/onyx/utils/test_sensitive_typing.py --ignore-missing-imports
These tests show what mypy will catch when SensitiveValue is misused.
"""
from typing import Any
# This file demonstrates what mypy will catch.
# The commented-out ... | 79 | 2,726 |
onyx | backend/tests/unit/onyx/utils/test_json_river.py | .py | """Tests for the jsonriver incremental JSON parser."""
import json
import pytest
from onyx.utils.jsonriver import JsonValue, Parser
def _all_deltas(chunks: list[str]) -> list[JsonValue]:
"""Feed chunks one at a time and collect all emitted deltas."""
parser = Parser()
deltas: list[JsonValue] = []
f... | 394 | 13,951 |
onyx | backend/tests/unit/onyx/utils/test_pytest_secret_redaction.py | .py | from _pytest._io.saferepr import saferepr
from tests.utils.pytest_secrets import RedactedDict
SAMPLE_SECRET = "sensitive-test-value"
def test_redacted_dict_hides_values_from_pytest_repr() -> None:
secrets = RedactedDict({"credential": SAMPLE_SECRET})
assert secrets["credential"] == SAMPLE_SECRET
assert... | 14 | 406 |
onyx | backend/tests/unit/onyx/utils/test_external_endpoint.py | .py | """Unit tests for the generic external endpoint client."""
from unittest.mock import MagicMock, patch
import httpx
from pydantic import BaseModel
from onyx.utils.external_endpoint import ExternalEndpointConfig, post_json_to_endpoint
_CONFIG = ExternalEndpointConfig(
endpoint_url="https://endpoint.example.com/x"... | 95 | 3,419 |
onyx | backend/tests/unit/onyx/skills/test_pptx_skill_docs.py | .py | """Doc-integrity check for the pptx built-in skill.
Every ``scripts/β¦`` path (``.py`` or ``.js``) referenced in the skill's
markdown must exist on disk, so docs and scripts can't silently drift apart."""
from __future__ import annotations
import re
from pathlib import Path
_PPTX_SKILL_DIR = Path(__file__).parents[4... | 30 | 1,026 |
onyx | backend/tests/unit/onyx/skills/test_bundle_safety.py | .py | """Traversal and symlink tests for the custom skill upload boundary."""
from __future__ import annotations
import io
import stat
import zipfile
import pytest
from onyx.error_handling.exceptions import OnyxError
from onyx.skills.bundle import _ZIP_UNIX_CREATE_SYSTEM, normalize_custom_bundle
def _build_zip(
ent... | 65 | 1,901 |
onyx | backend/tests/unit/onyx/skills/test_bundle_validation.py | .py | """Unit tests for custom skill bundle validation and normalization."""
from __future__ import annotations
import io
import stat
import zipfile
import pytest
from onyx.error_handling.error_codes import OnyxErrorCode
from onyx.error_handling.exceptions import OnyxError
from onyx.skills.bundle import (
_ZIP_UNIX_C... | 455 | 15,374 |
onyx | backend/tests/unit/onyx/skills/test_ingest.py | .py | import hashlib
import io
import zipfile
from typing import cast
from unittest.mock import MagicMock
import pytest
from onyx.error_handling.exceptions import OnyxError
from onyx.file_store.file_store import FileStore
from onyx.skills.ingest import (
IngestedBundle,
ingest_skill_bundle,
ingested_skill_bundl... | 169 | 5,888 |
onyx | backend/tests/unit/onyx/skills/test_ingest_from_github.py | .py | from __future__ import annotations
import io
import tarfile
import zipfile
from collections.abc import Iterator
from typing import Any
from urllib.parse import unquote
import pytest
from onyx.error_handling.error_codes import OnyxErrorCode
from onyx.error_handling.exceptions import OnyxError
from onyx.skills import ... | 380 | 12,726 |
onyx | backend/tests/unit/onyx/skills/test_built_in_definition.py | .py | """Tests for ``BuiltInSkillDefinition`` construction-time validation."""
from __future__ import annotations
import pytest
from pydantic import ValidationError
from onyx.skills.built_in import BuiltInSkillDefinition
def _definition(name: str) -> BuiltInSkillDefinition:
return BuiltInSkillDefinition(built_in_ski... | 37 | 1,039 |
onyx | backend/tests/unit/onyx/skills/test_metadata.py | .py | """Unit tests for Agent Skills metadata handling."""
from __future__ import annotations
import pytest
from onyx.error_handling.exceptions import OnyxError
from onyx.skills.metadata import parse_skill_document, serialize_skill_md
def _skill_md(frontmatter: str, body: str = "Do the work.") -> bytes:
return f"---... | 157 | 4,894 |
onyx | backend/tests/unit/onyx/skills/test_pptx_lint.py | .py | """Unit tests for the pptx skill's layout linter (scripts/lint.py).
Fixture decks are generated in-test with python-pptx β one per defect class
plus a clean deck β and thresholds are validated in both directions: each
defect is caught, and the clean deck produces zero findings.
"""
import importlib.util
import sys
fr... | 293 | 9,490 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.