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 |
|---|---|---|---|---|---|
ArchiveBox | archivebox/tests/test_ui_admin_machine.py | .py | """Machine, binary, and process admin UI tests."""
import uuid
import asyncio
import os
from importlib.resources import files
from pathlib import Path
import pytest
from django.urls import reverse
from django.utils import timezone
from archivebox.tests.conftest import ADMIN_TEST_HOST
from archivebox.tests.conftest i... | 229 | 9,372 |
ArchiveBox | archivebox/tests/test_ui_admin_user.py | .py | """User admin UI tests."""
import pytest
from django.urls import reverse
from archivebox.tests.conftest import ADMIN_TEST_HOST
pytestmark = pytest.mark.django_db
class TestUserAdmin:
def test_user_admin_list_view_renders(self, client, admin_user):
client.force_login(admin_user)
response = clien... | 28 | 1,139 |
ArchiveBox | archivebox/tests/test_api_v1_cli_remove.py | .py | from datetime import datetime, timedelta
from pathlib import Path
import pytest
from django.utils import timezone
from archivebox.core.models import Snapshot, Tag
from archivebox.crawls.models import Crawl
from archivebox.tests.conftest import api_client_request, init_archive
pytestmark = pytest.mark.django_db(tran... | 206 | 8,030 |
ArchiveBox | archivebox/tests/test_cli_add.py | .py | #!/usr/bin/env python3
"""
Comprehensive tests for archivebox add command.
Verify add creates snapshots in DB, crawls, source files, and archive directories.
"""
import os
import json
from pathlib import Path
import pytest
from django.utils import timezone
from archivebox.core.models import ArchiveResult, Snapshot, ... | 1,263 | 48,398 |
ArchiveBox | archivebox/tests/test_serve_static.py | .py | from pathlib import Path
from django.test import RequestFactory
from archivebox.misc.serve_static import serve_static_with_byterange_support
def test_archive_file_response_uses_async_iterator_under_asgi(tmp_path: Path):
output = tmp_path / "screenshot" / "output.png"
output.parent.mkdir()
output.write_b... | 26 | 781 |
ArchiveBox | archivebox/tests/test_api_v1_core_tags.py | .py | import pytest
from archivebox.core.models import Tag
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_admin_user, api_headers):
Tag.objects.create(name="api-basic-tag", created_by=api_admin_user)
response = client.get("/api/v1/core/tags", **api... | 15 | 388 |
ArchiveBox | archivebox/tests/test_cli_mcp.py | .py | #!/usr/bin/env python3
"""
Tests for archivebox mcp command.
"""
from archivebox.tests.conftest import run_archivebox_cmd
def test_mcp_help_runs_successfully(tmp_path):
"""The mcp command should be registered and expose help."""
result = run_archivebox_cmd(["mcp", "--help"])
assert result.returncode ==... | 16 | 365 |
ArchiveBox | archivebox/tests/test_api_v1_machine_binaries.py | .py | import pytest
from archivebox.machine.models import Machine
from archivebox.tests.conftest import install_real_binary
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_headers):
machine = Machine.current(refresh=True)
binary = install_real_binary... | 22 | 715 |
ArchiveBox | archivebox/tests/test_api_v1_auth_check_api_token.py | .py | import pytest
from archivebox.tests.conftest import API_TEST_HOST, api_client_request
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_token):
response = api_client_request(
client,
"post",
"/api/v1/auth/check_api_token",
... | 20 | 517 |
ArchiveBox | archivebox/tests/test_ui_admin_tag.py | .py | """Tag admin UI and API tests."""
import pytest
from django.urls import reverse
from archivebox.tests.conftest import ADMIN_TEST_HOST
pytestmark = pytest.mark.django_db
def test_tag_admin_changelist_renders_custom_ui(admin_client, tagged_data):
response = admin_client.get(reverse("admin:core_tag_changelist"), ... | 29 | 1,023 |
ArchiveBox | archivebox/tests/test_api_v1_machine_machine_current.py | .py | import pytest
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_headers):
response = client.get("/api/v1/machine/machine/current", **api_headers)
assert response.status_code == 200, response.content
| 11 | 273 |
ArchiveBox | archivebox/tests/test_api_v1_core_tags_remove_from_snapshot.py | .py | import pytest
from archivebox.core.models import Snapshot, Tag
from archivebox.crawls.models import Crawl
from archivebox.tests.conftest import api_client_request
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, api_admin_user, api_headers):
crawl = Crawl.objects... | 27 | 923 |
ArchiveBox | archivebox/tests/test_cli_process.py | .py | #!/usr/bin/env python3
"""
Tests for archivebox process command.
"""
from archivebox.tests.conftest import run_archivebox_cmd
def test_process_help_runs_successfully(tmp_path):
"""The process command should be registered and expose help."""
result = run_archivebox_cmd(["process", "--help"])
assert resu... | 17 | 420 |
ArchiveBox | archivebox/tests/test_migrations_08_to_09.py | .py | #!/usr/bin/env python3
"""
Migration tests from 0.8.x to 0.9.x.
0.8.x introduced:
- Crawl model for grouping URLs
- Seed model (removed in 0.9.x)
- UUID primary keys for Snapshot
- Status fields for state machine
- New fields like depth, retry_at, etc.
"""
import sqlite3
import json
import uuid
from datetime import d... | 1,072 | 46,267 |
ArchiveBox | archivebox/tests/test_migrations_04_to_09.py | .py | """End-to-end migration coverage from the oldest Django ArchiveBox schema."""
import json
import sqlite3
from .migrations_helpers import (
SCHEMA_0_4,
create_data_dir_structure,
filesystem_manifest,
run_archivebox_migration_cmd,
seed_0_4_data,
)
LEGACY_OUTPUTS = {
"title": ("title/title.txt"... | 134 | 6,484 |
ArchiveBox | archivebox/tests/test_cli_machine.py | .py | #!/usr/bin/env python3
"""
Tests for archivebox machine command.
"""
from archivebox.tests.conftest import run_archivebox_cmd
def test_machine_help_runs_successfully(tmp_path):
"""The machine command should be registered and expose help."""
result = run_archivebox_cmd(["machine", "--help"])
assert resu... | 17 | 420 |
ArchiveBox | archivebox/tests/test_server_security_browser.py | .py | #!/usr/bin/env python3
"""Browser-level security mode tests using the existing Node/Puppeteer runtime."""
from __future__ import annotations
import json
import os
import time
import subprocess
import textwrap
from pathlib import Path
from urllib.parse import urlencode
import pytest
import requests
import yaml
from ... | 972 | 34,319 |
ArchiveBox | archivebox/tests/test_cli_list.py | .py | """
Tests for archivebox list command.
Verify list emits snapshot JSONL and applies the documented filters.
"""
import json
import pytest
from django.contrib.auth import get_user_model
from django.db import connection
from django.utils import timezone
from archivebox.core.models import Snapshot
from archivebox.cli.a... | 488 | 17,120 |
ArchiveBox | archivebox/tests/test_urls.py | .py | import os
import subprocess
import sys
import textwrap
from functools import partial
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
from pathlib import Path
from threading import Thread
import pytest
from archivebox.tests.conftest import run_archivebox_cmd
REPO_ROOT = Path(__file__).resolve().... | 1,326 | 57,840 |
ArchiveBox | archivebox/tests/test_cli_extract_input.py | .py | """Tests for archivebox extract input handling and pipelines."""
import subprocess
import pytest
from archivebox.core.models import ArchiveResult, Snapshot
from archivebox.tests.conftest import cli_env, find_snapshot_dir, parse_jsonl_output, run_archivebox_cmd
from archivebox.tests.test_orm_helpers import use_archi... | 399 | 19,233 |
ArchiveBox | archivebox/tests/test_util.py | .py | from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from threading import Thread
import pytest
from archivebox.misc.util import download_url, find_all_urls, fix_url_from_markdown
class _ExampleHandler(BaseHTTPRequestHandler):
def do_GET(self):
body = b"<html><body><h1>Example Domain</h1>... | 159 | 7,157 |
ArchiveBox | archivebox/tests/test_search.py | .py | import os
import re
import time
from datetime import timedelta
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from itertools import pairwise
from pathlib import Path
from threading import Thread
from urllib.parse import urlencode
import pytest
import requests
from asgiref.sync import async_to_sync... | 1,267 | 56,148 |
ArchiveBox | archivebox/tests/test_cli_snapshot.py | .py | """
Tests for archivebox snapshot CLI command.
Tests cover:
- snapshot create (from URLs, from Crawl JSONL, pass-through)
- snapshot list (with filters)
- snapshot update
- snapshot delete
"""
import json
import os
import pytest
from archivebox.core.models import Snapshot, Tag
from archivebox.machine.models import ... | 549 | 19,548 |
ArchiveBox | archivebox/tests/test_api_v1_core_any_id.py | .py | import pytest
from archivebox.core.models import Snapshot
from archivebox.crawls.models import Crawl
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_admin_user, api_headers):
crawl = Crawl.objects.create(urls="https://example.com/any", created_by=a... | 17 | 566 |
ArchiveBox | archivebox/tests/test_cli_extract.py | .py | #!/usr/bin/env python3
"""Tests for archivebox extract command."""
import pytest
from archivebox.core.models import ArchiveResult, Snapshot
from archivebox.tests.conftest import cli_env, find_snapshot_dir, parse_jsonl_output, run_archivebox_cmd
from archivebox.tests.test_orm_helpers import use_archivebox_db
pytestm... | 135 | 6,192 |
ArchiveBox | archivebox/tests/test_cli_help.py | .py | #!/usr/bin/env python3
"""
Tests for archivebox help command.
Verify command runs successfully and produces output.
"""
from archivebox.tests.conftest import run_archivebox_cmd
def test_help_runs_successfully(tmp_path):
"""Test that help command runs and produces output."""
result = run_archivebox_cmd(["help... | 28 | 776 |
ArchiveBox | archivebox/tests/test_ui_add_view.py | .py | import json
import pytest
from django.contrib.auth import get_user_model
from django.urls import reverse
from archivebox.config.common import ArchiveBoxConfig
from archivebox.core.models import Snapshot, Tag
from archivebox.crawls.models import Crawl
from archivebox.machine.models import Machine
from archivebox.perso... | 702 | 26,244 |
ArchiveBox | archivebox/tests/test_settings_signal_webhooks.py | .py | from django.test import TestCase
class TestSignalWebhooksSettings(TestCase):
def test_task_handler_runs_after_transaction_commit(self):
from signal_webhooks.settings import webhook_settings
assert webhook_settings.TASK_HANDLER.__name__ == "transaction_on_commit_task_handler"
| 9 | 299 |
ArchiveBox | archivebox/tests/test_permissions.py | .py | from pathlib import Path
from archivebox.config.permissions import (
is_root_identity,
root_parent_can_grant_group_traversal,
root_should_handoff_data_dir,
select_archivebox_user,
)
def test_root_identity_includes_real_or_effective_root():
assert is_root_identity(0, 0)
assert is_root_identity... | 192 | 6,579 |
ArchiveBox | archivebox/tests/test_api_v1_core_tags_create.py | .py | import pytest
from archivebox.tests.conftest import api_client_request
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, api_headers):
response = api_client_request(
client,
"post",
"/api/v1/core/tags/create/",
payload={"name": "api... | 20 | 481 |
ArchiveBox | archivebox/tests/test_config_MAX_limits.py | .py | """Tests for MAX/SIZE crawl limit config behavior."""
import asyncio
import json
from importlib.resources import files
from pathlib import Path
import pytest
from archivebox.core.models import Snapshot
from archivebox.crawls.models import Crawl
from archivebox.tests.conftest import cli_env, run_archivebox_cmd
from a... | 308 | 10,467 |
ArchiveBox | archivebox/tests/test_setup_script.py | .py | import os
import shutil
import subprocess
import tomllib
from pathlib import Path
SETUP_SCRIPT = Path(__file__).parents[2] / "bin" / "setup.sh"
def test_setup_script_creates_archivebox_user_instead_of_rejecting_root():
script = SETUP_SCRIPT.read_text()
assert "You cannot run this script as root" not in scr... | 193 | 7,755 |
ArchiveBox | archivebox/tests/test_process_runtime_paths.py | .py | from importlib.resources import files
from pathlib import Path
import pytest
from archivebox.tests.conftest import run_archivebox_cmd
from archivebox.tests.test_orm_helpers import use_archivebox_db
pytestmark = pytest.mark.django_db(transaction=True)
class TestProcessRuntimePaths:
def test_hook_processes_use_i... | 57 | 2,339 |
ArchiveBox | archivebox/tests/test_api_v1_cli_schedule.py | .py | from io import StringIO
import pytest
import requests
from django.test import RequestFactory
from archivebox.api.v1_cli import ScheduleCommandSchema, cli_schedule
from archivebox.crawls.models import CrawlSchedule
from .conftest import (
api_auth_headers,
cli_env,
create_admin_and_token,
get_free_port... | 72 | 2,183 |
ArchiveBox | archivebox/tests/test_cli_oneshot.py | .py | import tempfile
from importlib.metadata import version
from pathlib import Path
from archivebox.tests.conftest import run_archivebox_cmd
def test_oneshot_runs_abx_dl_through_abxpkg_env_projection():
with tempfile.TemporaryDirectory(prefix="archivebox-oneshot-") as tmp_dir:
work_dir = Path(tmp_dir)
... | 24 | 777 |
ArchiveBox | archivebox/tests/test_core_forms.py | .py | import pytest
from archivebox.core.forms import TagField, TagWidget
from archivebox.core.models import Tag
pytestmark = pytest.mark.django_db
def test_tag_field_parses_legacy_tag_input():
field = TagField()
assert field.clean("alpha beta alpha") == ["alpha", "beta"]
assert field.clean("alpha, beta, Al... | 32 | 1,033 |
ArchiveBox | archivebox/tests/test_api_v1_core_tag_tag_id.py | .py | import pytest
from archivebox.core.models import Tag
pytestmark = pytest.mark.django_db(transaction=True)
@pytest.mark.parametrize("request_method", ("get", "delete"))
def test_basic_success_case_request(client, tmp_path, api_admin_user, api_headers, request_method):
tag = Tag.objects.create(name="api-basic-ta... | 16 | 502 |
ArchiveBox | archivebox/tests/test_ui_admin_apitoken.py | .py | """API token admin UI tests."""
import pytest
from django.urls import reverse
from archivebox.tests.conftest import ADMIN_TEST_HOST
pytestmark = pytest.mark.django_db
class TestAPITokenAdmin:
def test_api_token_admin_list_view_renders(self, client, admin_user):
client.force_login(admin_user)
re... | 18 | 500 |
ArchiveBox | archivebox/tests/test_core_config.py | .py | from archivebox.config import CONSTANTS
def test_sonic_dir_is_allowed_inside_data_dir():
assert "sonic" in CONSTANTS.ALLOWED_IN_DATA_DIR
| 6 | 143 |
ArchiveBox | archivebox/tests/test_snapshot_url_length.py | .py | """Tests for very long Snapshot URLs.
ArchiveBox supports URLs up to MAX_URL_LENGTH chars. The url column is stored as a
variable-length TextField (so short URLs don't reserve the full max length) but stays fully
indexed, so exact, prefix, and substring lookups all keep working for long URLs.
"""
import pytest
from d... | 94 | 3,585 |
ArchiveBox | archivebox/tests/test_misc_checks.py | .py | import os
import signal
import subprocess
import sys
import textwrap
import pytest
from archivebox.core.shutdown_util import foreground_shutdown_signals
from archivebox.core.shutdown_util import raise_if_shutdown_requested
from archivebox.misc.checks import _migration_interrupt_message
from archivebox.misc.checks imp... | 87 | 2,780 |
ArchiveBox | archivebox/tests/test_config_SAVE_TITLE.py | .py | from pathlib import Path
from archivebox.tests.conftest import cli_env, run_archivebox_cmd, run_queued_crawls
import pytest
from archivebox.core.models import Snapshot
from archivebox.tests.test_orm_helpers import use_archivebox_db
from .conftest import resolve_abxpkg_chrome_env
pytestmark = pytest.mark.django_db(t... | 70 | 2,373 |
ArchiveBox | archivebox/tests/test_api_v1_auth_get_api_token.py | .py | import pytest
from archivebox.tests.conftest import API_TEST_HOST, api_client_request
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_admin_user):
response = api_client_request(
client,
"post",
"/api/v1/auth/get_api_token",
... | 23 | 593 |
ArchiveBox | archivebox/tests/test_ui_admin_config_widget.py | .py | from pathlib import Path
import pytest
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from django.http import HttpResponse
from django.template.loader import render_to_string
from django.test import RequestFactory
from archivebox.base_models.admin import KeyValueWidget
from arch... | 374 | 17,436 |
ArchiveBox | archivebox/tests/test_api_v1_core_tag_tag_id_rename.py | .py | import pytest
from archivebox.core.models import Tag
from archivebox.tests.conftest import ADMIN_TEST_HOST, api_client_request
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_admin_user, api_headers):
tag = Tag.objects.create(name="api-basic-tag", ... | 39 | 1,039 |
ArchiveBox | archivebox/tests/test_api_v1_core_archiveresult_archiveresult_id.py | .py | import pytest
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test.client import BOUNDARY, MULTIPART_CONTENT, encode_multipart
from archivebox.core.models import ArchiveResult, Snapshot
from archivebox.crawls.models import Crawl
pytestmark = pytest.mark.django_db(transaction=True)
def tes... | 70 | 2,448 |
ArchiveBox | archivebox/tests/test_cli_persona.py | .py | #!/usr/bin/env python3
"""
Tests for archivebox persona command.
"""
from archivebox.tests.conftest import run_archivebox_cmd
def test_persona_help_runs_successfully(tmp_path):
"""The persona command should be registered and expose help."""
result = run_archivebox_cmd(["persona", "--help"])
assert resu... | 17 | 420 |
ArchiveBox | archivebox/tests/test_ui_admin_links.py | .py | import pytest
import subprocess
from datetime import datetime, timezone as dt_timezone
from importlib.resources import files
from pathlib import Path
from django.contrib.admin.sites import AdminSite
from django.contrib.messages import get_messages
from django.contrib.messages.storage.fallback import FallbackStorage
fro... | 408 | 15,208 |
ArchiveBox | archivebox/tests/test_cli_tag.py | .py | #!/usr/bin/env python3
"""
Tests for archivebox tag command.
"""
from archivebox.tests.conftest import run_archivebox_cmd
def test_tag_help_runs_successfully(tmp_path):
"""The tag command should be registered and expose help."""
result = run_archivebox_cmd(["tag", "--help"])
assert result.returncode ==... | 17 | 400 |
ArchiveBox | archivebox/tests/test_machine_service.py | .py | import textwrap
from pathlib import Path
import pytest
from archivebox.machine.models import Binary, Machine, Process
from archivebox.tests.conftest import run_archivebox_cmd
from archivebox.tests.test_orm_helpers import use_archivebox_db
pytestmark = pytest.mark.django_db(transaction=True)
def _runtime_env(data_d... | 137 | 5,499 |
ArchiveBox | archivebox/tests/test_misc_monkey_patches.py | .py | import datetime
import io
def test_daphne_access_log_redacts_sensitive_query_params():
from archivebox.misc.monkey_patches import ModifiedAccessLogGenerator
stream = io.StringIO()
logger = ModifiedAccessLogGenerator(stream)
logger.write_entry(
host="127.0.0.1:54321",
date=datetime.da... | 22 | 672 |
ArchiveBox | archivebox/tests/test_tag_service.py | .py | import asyncio
import pytest
from abx_dl.events import TagEvent
from abx_dl.orchestrator import create_bus
pytestmark = pytest.mark.django_db(transaction=True)
def _create_snapshot():
from archivebox.base_models.models import get_or_create_system_user_pk
from archivebox.crawls.models import Crawl
from... | 52 | 1,353 |
ArchiveBox | archivebox/tests/test_api_v1_cli_workflow_add_search_update_remove.py | .py | import pytest
from archivebox.core.models import Snapshot
from archivebox.tests.test_orm_helpers import use_archivebox_db
from .conftest import (
cli_env,
create_admin_and_token,
get_free_port,
init_archive,
live_api_request,
run_archivebox_cmd,
start_archivebox_server,
stop_server,
... | 155 | 5,193 |
ArchiveBox | archivebox/tests/test_api_v1_workflow_core_token_auth_side_effects.py | .py | import pytest
import requests
from archivebox.core.models import Snapshot
from archivebox.crawls.models import Crawl
from archivebox.tests.conftest import (
cli_env,
create_admin_and_token,
get_free_port,
init_archive,
live_api_request,
start_archivebox_server,
stop_archivebox_process,
... | 220 | 8,105 |
ArchiveBox | archivebox/tests/test_takeover_util.py | .py | #!/usr/bin/env python3
"""Takeover utility tests and live command handoff flows."""
import os
import json
import re
import signal
import subprocess
import sys
from pathlib import Path
import pytest
import psutil
from archivebox.core.models import ArchiveResult, Snapshot
from archivebox.crawls.models import Crawl
fro... | 957 | 38,303 |
ArchiveBox | archivebox/tests/test_cli_version.py | .py | #!/usr/bin/env python3
"""
Tests for archivebox version command.
Verify version output and system information reporting.
"""
import os
import re
import tempfile
from pathlib import Path
from archivebox.config.paths import tmp_dir_socket_path_is_short_enough
from archivebox.cli.archivebox_version import _binary_row_ded... | 275 | 9,640 |
ArchiveBox | archivebox/tests/test_api_v1_crawls_crawl_crawl_id_files_folder_filename.py | .py | import pytest
from archivebox.crawls.models import Crawl
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_admin_user, api_headers):
crawl = Crawl.objects.create(urls="https://example.com/crawl-file-nested", created_by=api_admin_user)
nested_dir ... | 18 | 607 |
ArchiveBox | archivebox/tests/test_crawl_service.py | .py | from pathlib import Path
import pytest
from archivebox.core.models import ArchiveResult, Snapshot
from archivebox.crawls.models import Crawl
from archivebox.tests.conftest import run_archivebox_cmd
from archivebox.tests.test_orm_helpers import use_archivebox_db
from .conftest import cli_env, get_free_port, init_archi... | 119 | 4,918 |
ArchiveBox | archivebox/tests/test_cli_remove.py | .py | #!/usr/bin/env python3
"""
Comprehensive tests for archivebox remove command.
Verify remove deletes snapshots from DB and filesystem.
"""
import json
from pathlib import Path
from archivebox.tests.conftest import find_snapshot_dir, run_archivebox_cmd, run_queued_crawls, cli_env
def _snapshot_rows(data_dir: Path, en... | 248 | 7,601 |
ArchiveBox | archivebox/tests/test_api_v1_core_tags_search.py | .py | import pytest
from django.contrib.auth import get_user_model
from django.utils import timezone
from archivebox.core.models import Snapshot, Tag
from archivebox.tests.conftest import ADMIN_TEST_HOST
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_admin_... | 104 | 4,012 |
ArchiveBox | archivebox/tests/test_recursive_crawl.py | .py | #!/usr/bin/env python3
"""Integration tests for recursive crawling functionality."""
import json
import os
from pathlib import Path
import pytest
from archivebox.core.models import ArchiveResult, Snapshot
from archivebox.crawls.models import Crawl
from archivebox.machine.models import Binary, Process
from archivebox... | 801 | 32,920 |
ArchiveBox | archivebox/tests/test_api_v1_core_snapshots_rss.py | .py | from datetime import datetime
from typing import cast
import pytest
from django.contrib.auth import get_user_model
from django.contrib.auth.models import UserManager
from django.utils import timezone
pytestmark = pytest.mark.django_db
User = get_user_model()
ADMIN_HOST = "admin.archivebox.localhost:8000"
@pytest... | 116 | 3,749 |
ArchiveBox | archivebox/tests/test_cli_piping.py | .py | """
Tests for JSONL piping contracts and `archivebox run`.
This file covers both:
- low-level JSONL/stdin parsing behavior that makes CLI piping work
- subprocess integration for the supported records `archivebox run` consumes
"""
import os
import pty
import sys
import uuid
from importlib.resources import files
from ... | 413 | 15,936 |
ArchiveBox | archivebox/tests/test_api_v1_personas_sync.py | .py | import pytest
from archivebox.tests.conftest import api_client_request
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, api_headers):
response = api_client_request(
client,
"post",
"/api/v1/personas/sync",
payload={
"ex... | 26 | 651 |
ArchiveBox | archivebox/tests/test_frozen_crawl_config.py | .py | import time
from types import SimpleNamespace
import pytest
from django.utils import timezone
pytestmark = pytest.mark.django_db(transaction=True)
SENSITIVE_SECRET = "raw-twocaptcha-secret-for-frozen-crawl-test"
UPDATED_SECRET = "updated-secret-that-must-not-affect-old-crawl"
@pytest.fixture
def archivebox_db(ini... | 343 | 13,630 |
ArchiveBox | archivebox/tests/test_config_ONLY_NEW.py | .py | """Tests for ONLY_NEW crawl config behavior."""
import pytest
from archivebox.core.models import Snapshot
from archivebox.crawls.models import Crawl
pytestmark = pytest.mark.django_db
def test_create_snapshots_from_urls_respects_only_new_exact_url_matches(admin_user):
existing_crawl = Crawl.objects.create(urls... | 88 | 2,869 |
ArchiveBox | archivebox/tests/test_crawl_pause.py | .py | from django.utils import timezone
from archivebox.workers.models import RETRY_AT_MAX
def test_retry_at_max_is_safe_for_admin_timezone_localization():
with timezone.override("Pacific/Kiritimati"):
assert timezone.localtime(RETRY_AT_MAX).year == 9999
| 9 | 264 |
ArchiveBox | archivebox/tests/test_migrations_07_to_09.py | .py | """
Migration tests from 0.7.x to 0.9.x.
0.7.x schema includes:
- Tag model with ManyToMany to Snapshot
- ArchiveResult model with ForeignKey to Snapshot
- AutoField primary keys
"""
import json
import sqlite3
import zipfile
from uuid import UUID
import pytest
from .migrations_helpers import (
SCHEMA_0_7,
c... | 647 | 26,598 |
ArchiveBox | archivebox/tests/test_cli_shell.py | .py | #!/usr/bin/env python3
"""
Tests for archivebox shell command.
Verify shell command starts Django shell (basic smoke tests only).
"""
from archivebox.tests.conftest import run_archivebox_cmd
def test_shell_command_exists(initialized_archive):
"""Test that shell command is recognized."""
result = run_archive... | 33 | 856 |
ArchiveBox | archivebox/tests/test_cli_install.py | .py | #!/usr/bin/env python3
"""
Comprehensive tests for archivebox install command.
Verify install detects and records binary dependencies in DB.
"""
import os
from pathlib import Path
from archivebox.tests.conftest import run_archivebox_cmd
import pytest
from archivebox.cli.archivebox_install import ensure_data_dir_lib... | 223 | 7,724 |
ArchiveBox | archivebox/tests/test_cli_run.py | .py | """
Tests for archivebox run CLI command.
Tests cover:
- run with stdin JSONL (Crawl, Snapshot, ArchiveResult)
- create-or-update behavior (records with/without id)
- pass-through output (for chaining)
"""
import os
import signal
import subprocess
import psutil
import pytest
from archivebox.tests.conftest import (
... | 2,799 | 109,324 |
ArchiveBox | archivebox/tests/test_cli_config.py | .py | #!/usr/bin/env python3
"""
Comprehensive tests for archivebox config command.
Verify config reads/writes ArchiveBox.conf file correctly.
"""
from archivebox.tests.conftest import run_archivebox_cmd
from archivebox.config.configset import _read_ini_config_cached
def test_config_displays_all_config(initialized_archive... | 294 | 8,577 |
ArchiveBox | archivebox/tests/test_api_v1_crawls_crawl_crawl_id_files_filename.py | .py | import pytest
from archivebox.crawls.models import Crawl
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_admin_user, api_headers):
crawl = Crawl.objects.create(urls="https://example.com/crawl-file-root", created_by=api_admin_user)
crawl.output_... | 17 | 565 |
ArchiveBox | archivebox/tests/test_ui_add_view_runtime.py | .py | import re
import json
from pathlib import Path
import pytest
import requests
from archivebox.core.models import ArchiveResult, Snapshot
from archivebox.crawls.models import Crawl, CrawlSchedule
from archivebox.tests.test_orm_helpers import use_archivebox_db
from .conftest import (
cli_env,
create_admin_and_to... | 788 | 32,578 |
ArchiveBox | archivebox/tests/test_api_v1_core_snapshot_snapshot_id.py | .py | import json
from datetime import timedelta
from pathlib import Path
from threading import Thread
import pytest
from django.utils import timezone
from archivebox.core.models import ArchiveResult, Snapshot
from archivebox.crawls.models import Crawl
from archivebox.tests.conftest import run_archivebox_cmd
from archivebo... | 506 | 20,939 |
ArchiveBox | archivebox/tests/test_api_v1_core_archiveresults.py | .py | from datetime import timedelta
import pytest
from django.db import connection
from django.test.utils import CaptureQueriesContext
from django.utils import timezone
from archivebox.core.models import ArchiveResult, Snapshot
from archivebox.crawls.models import Crawl
from archivebox.tests.conftest import api_client_req... | 171 | 6,503 |
ArchiveBox | archivebox/tests/test_ui_live_progress.py | .py | """Live progress UI tests."""
import subprocess
import uuid
from datetime import datetime, timezone as dt_timezone
from importlib.resources import files
from pathlib import Path
from threading import Thread
import pytest
from django.test import override_settings
from django.urls import reverse
from django.utils impor... | 568 | 22,888 |
ArchiveBox | archivebox/tests/test_cli_update_reindex_snapshots.py | .py | import json
import os
from datetime import datetime, timedelta
from archivebox.tests.conftest import cli_env, run_archivebox_cmd
import pytest
from django.utils import timezone
from archivebox.core.models import ArchiveResult, Snapshot
from archivebox.tests.migrations_helpers import filesystem_manifest
from archivebo... | 564 | 21,495 |
ArchiveBox | archivebox/tests/test_api_v1_cli_search.py | .py | import pytest
from archivebox.core.models import Snapshot
from archivebox.crawls.models import Crawl
from .conftest import api_client_request
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_admin_user, api_headers):
crawl = Crawl.objects.create(url... | 32 | 981 |
ArchiveBox | archivebox/tests/test_snapshot_service.py | .py | import json
from pathlib import Path
import pytest
from archivebox.core.models import ArchiveResult, Snapshot
from archivebox.tests.conftest import run_archivebox_cmd
from archivebox.tests.test_orm_helpers import use_archivebox_db
from .conftest import (
cli_env,
get_free_port,
init_archive,
)
pytestmark... | 83 | 3,351 |
ArchiveBox | archivebox/tests/test_api_v1_core_tag_tag_id_snapshots_jsonl.py | .py | import json
import pytest
from archivebox.core.models import Snapshot, Tag
from archivebox.crawls.models import Crawl
from archivebox.tests.conftest import ADMIN_TEST_HOST
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_admin_user, api_headers):
t... | 45 | 1,817 |
ArchiveBox | archivebox/tests/test_ui_admin_crawl.py | .py | """Crawl model and admin UI tests."""
import re
import pytest
from django.urls import reverse
from archivebox.core.models import Snapshot
from archivebox.crawls.admin import CrawlAdminForm
from archivebox.crawls.models import Crawl
from archivebox.tests.conftest import ADMIN_TEST_HOST
pytestmark = pytest.mark.djang... | 461 | 16,677 |
ArchiveBox | archivebox/tests/test_api_v1_core_tags_autocomplete.py | .py | import pytest
from archivebox.core.models import Tag
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_admin_user, api_token):
Tag.objects.create(name="api-basic-tag", created_by=api_admin_user)
response = client.get(
"/api/v1/core/tags/... | 19 | 507 |
ArchiveBox | archivebox/tests/test_cli_binary.py | .py | #!/usr/bin/env python3
"""
Tests for archivebox binary command.
"""
from archivebox.tests.conftest import run_archivebox_cmd
def test_binary_help_runs_successfully(tmp_path):
"""The binary command should be registered and expose help."""
result = run_archivebox_cmd(["binary", "--help"])
assert result.r... | 17 | 415 |
ArchiveBox | archivebox/tests/test_ui_admin_archiveresult.py | .py | """ArchiveResult admin UI tests."""
import asyncio
import os
from importlib.resources import files
from pathlib import Path
import pytest
from django.urls import reverse
from archivebox.tests.conftest import ADMIN_TEST_HOST, resolve_abxpkg_binary_env
pytestmark = pytest.mark.django_db(transaction=True)
@pytest.fi... | 97 | 3,992 |
ArchiveBox | archivebox/tests/migrations_helpers.py | .py | #!/usr/bin/env python3
"""
Helper functions and schema definitions for migration tests.
This module provides:
- Schema definitions for each major ArchiveBox version (0.4.x, 0.7.x, 0.8.x)
- Data seeding functions to populate test databases
- Helper functions to run archivebox commands and verify results
"""
import jso... | 1,453 | 54,040 |
ArchiveBox | archivebox/tests/test_version_metadata.py | .py | import json
import os
import shutil
import subprocess
import sys
import tomllib
from pathlib import Path
from archivebox.config import version
REPO_DIR = Path(__file__).resolve().parents[2]
def test_release_metadata_versions_match() -> None:
project_version = tomllib.loads((REPO_DIR / "pyproject.toml").read_te... | 131 | 4,380 |
ArchiveBox | archivebox/tests/test_release_workflow.py | .py | from pathlib import Path
import shlex
import yaml
REPO_ROOT = Path(__file__).resolve().parents[2]
RELEASE_WORKFLOW = REPO_ROOT / ".github" / "workflows" / "release.yml"
def test_release_uses_registered_publisher_and_authorized_tag_credentials():
assert RELEASE_WORKFLOW.exists()
assert not (REPO_ROOT / ".gi... | 81 | 3,937 |
ArchiveBox | archivebox/tests/test_api_v1_workflow_frozen_crawl_config_sources.py | .py | from django.test import RequestFactory
import pytest
pytestmark = pytest.mark.django_db(transaction=True)
SENSITIVE_SECRET = "raw-twocaptcha-secret-for-frozen-crawl-test"
@pytest.fixture
def archivebox_db(initialized_archive):
from archivebox.tests.test_orm_helpers import use_archivebox_db
with use_arch... | 67 | 2,191 |
ArchiveBox | archivebox/tests/test_ui_savepagenow.py | .py | """Integration tests for /web/https://... shortcut (Save Page Now)."""
import subprocess
import sys
import textwrap
from pathlib import Path
from archivebox.tests.conftest import cli_env, create_test_url
ADMIN_HOST = "admin.archivebox.localhost:8000"
def _run_savepagenow_script(
initialized_archive: Path,
... | 249 | 8,927 |
ArchiveBox | archivebox/tests/test_api_v1_machine_machines.py | .py | import pytest
from archivebox.machine.models import Machine
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_headers):
Machine.current(refresh=True)
response = client.get("/api/v1/machine/machines", **api_headers)
assert response.status_co... | 15 | 348 |
ArchiveBox | archivebox/tests/test_cli_update.py | .py | #!/usr/bin/env python3
"""
Comprehensive tests for archivebox update command.
Verify update drains old dirs, reconciles DB, and queues snapshots.
"""
import pytest
from archivebox.core.models import Snapshot
from archivebox.tests.conftest import run_queued_crawls, run_archivebox_cmd, cli_env
from archivebox.tests.te... | 158 | 4,994 |
ArchiveBox | archivebox/tests/test_api_v1_machine_binary_by_name_name.py | .py | import pytest
from archivebox.machine.models import Machine
from archivebox.tests.conftest import install_real_binary
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_headers):
machine = Machine.current(refresh=True)
binary = install_real_binary... | 22 | 698 |
ArchiveBox | archivebox/tests/test_ui_public_snapshot.py | .py | """Public snapshot UI tests."""
import json
import re
import pytest
import requests
from django.test import override_settings
from archivebox.core.middleware import ADMIN_LOGIN_HINT_COOKIE
from archivebox.tests.conftest import WEB_TEST_HOST
from archivebox.tests.conftest import (
cli_env,
create_admin_and_to... | 606 | 24,511 |
ArchiveBox | archivebox/tests/test_api_v1_crawls_crawl_crawl_id_files_folder_subfolder_filename.py | .py | import pytest
from archivebox.crawls.models import Crawl
pytestmark = pytest.mark.django_db(transaction=True)
def test_basic_success_case_request(client, tmp_path, api_admin_user, api_headers):
crawl = Crawl.objects.create(urls="https://example.com/crawl-file-deep", created_by=api_admin_user)
nested_dir = ... | 18 | 629 |
ArchiveBox | archivebox/tests/test_hooks.py | .py | #!/usr/bin/env python3
"""
Unit tests for the ArchiveBox hook architecture.
Tests hook discovery, execution, JSONL parsing, background hook detection,
binary lookup, and required_binaries XYZ_BINARY passthrough handling.
Run with:
sudo -u testuser bash -c 'source .venv/bin/activate && python -m pytest archivebox/... | 662 | 27,559 |
ArchiveBox | archivebox/tests/test_ui_config_views.py | .py | import pytest
from django.contrib.auth import get_user_model
from django.test import RequestFactory
from archivebox.config import views as config_views
from archivebox.plugins import views as plugin_views
from archivebox.core import views as core_views
from archivebox.config import CONSTANTS
from archivebox.machine.mo... | 253 | 10,727 |
ArchiveBox | archivebox/tests/test_crawl_runner.py | .py | import asyncio
from importlib.resources import files
from pathlib import Path
import sys
import pytest
from asgiref.sync import sync_to_async
from archivebox.tests.conftest import install_real_binary, resolve_abxpkg_binary_env
pytestmark = pytest.mark.django_db
@pytest.mark.django_db(transaction=True)
def test_can... | 1,167 | 44,147 |
ArchiveBox | archivebox/tests/test_api_v1_cli_update.py | .py | import pytest
from .conftest import (
api_client_request,
cli_env,
create_admin_and_token,
get_free_port,
init_archive,
live_api_request,
parse_jsonl_output,
run_archivebox_cmd,
start_archivebox_server,
stop_server,
wait_for_live_api,
)
pytestmark = pytest.mark.django_db(tr... | 132 | 5,893 |
ArchiveBox | archivebox/tests/test_api_v1_cli_add.py | .py | import pytest
import json
import subprocess
from pathlib import Path
from concurrent.futures import ThreadPoolExecutor
from threading import Event
from .conftest import (
api_client_request,
cli_env,
create_admin_and_token,
get_free_port,
init_archive,
live_api_request,
run_archivebox_cmd,
... | 468 | 17,942 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.