Tighten tag JSONL export assertions
Some checks failed
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Waiting to run
Build Docker image / build ${{ matrix.platform }} (digest-linux-amd64, docker-amd64, linux/amd64, ubuntu-24.04) (push) Waiting to run
Build Docker image / build ${{ matrix.platform }} (digest-linux-arm64, docker-arm64, linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Build Docker image / publish multiarch tags (push) Blocked by required conditions
Run linters / lint (push) Waiting to run
Build Pip package / build (push) Waiting to run
Release State / release-state (push) Waiting to run
Parallel Tests / Discover test files (push) Waiting to run
Parallel Tests / ${{ matrix.test.name }} (push) Blocked by required conditions
Parallel Tests / ${{ matrix.plugin.name }} (push) Blocked by required conditions
Run tests / python_tests (ubuntu-22.04, 3.13) (push) Waiting to run
Run tests / docker_tests (push) Waiting to run
Update Homebrew tap / dispatch (push) Waiting to run
Deploy Publicsite to GitHub Pages / deploy (push) Has been cancelled

This commit is contained in:
Nick Sweeting 2026-06-10 11:30:22 -07:00
parent 9b6b95c97c
commit 2f65977b2e
No known key found for this signature in database

View File

@ -1,3 +1,5 @@
import json
import pytest
from archivebox.core.models import Snapshot, Tag
@ -31,6 +33,12 @@ def test_tag_snapshots_export_returns_jsonl(client, api_token, tagged_data):
assert response.status_code == 200
assert response["Content-Type"].startswith("application/x-ndjson")
assert f"tag-{tag.slug}-snapshots.jsonl" in response["Content-Disposition"]
body = response.content.decode()
assert '"type": "Snapshot"' in body
assert '"tags": "Alpha Research"' in body
rows = [json.loads(line) for line in response.content.decode().splitlines()]
rows_by_url = {row["url"]: row for row in rows}
assert set(rows_by_url) == {"https://example.com/one", "https://example.com/two"}
assert rows_by_url["https://example.com/one"]["type"] == "Snapshot"
assert rows_by_url["https://example.com/one"]["title"] == "Example One"
assert rows_by_url["https://example.com/two"]["type"] == "Snapshot"
assert rows_by_url["https://example.com/two"]["title"] == "Example Two"
for row in rows:
assert "Alpha Research" in row["tags"].split(",")