53 lines
3.4 KiB
Python
53 lines
3.4 KiB
Python
import io
|
|
import json
|
|
import tarfile
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def make_tar(tmp_path):
|
|
counter = 0
|
|
def create(entries, *, root="arbitrary-wrapper", extra=None):
|
|
nonlocal counter
|
|
counter += 1
|
|
path = tmp_path / f"source-{counter}.data"
|
|
with tarfile.open(path, "w:gz") as archive:
|
|
for name, payload in entries.items():
|
|
data = payload if isinstance(payload, bytes) else json.dumps(payload).encode()
|
|
info = tarfile.TarInfo(root + "/" + name if root else name)
|
|
info.size = len(data)
|
|
archive.addfile(info, io.BytesIO(data))
|
|
for info, data in extra or []:
|
|
archive.addfile(info, io.BytesIO(data) if data is not None else None)
|
|
return path
|
|
return create
|
|
|
|
|
|
@pytest.fixture
|
|
def source_pair(make_tar):
|
|
diag_manifest = {"tool": "wowdiag", "format_version": 2, "tool_version": "0.10.6", "command": "bug", "bug_id": 20,
|
|
"core_revision": "verified-source-revision", "diagnostic_focus_type": "quest", "diagnostic_focus_id": 11117, "warnings": []}
|
|
diag_entries = {
|
|
"manifest.json": diag_manifest,
|
|
"bug/bug.json": {"bug_id": 20, "title": "Wolpertinger spawnen nicht", "description": "Supplied aggregate description"},
|
|
"bug/reports.json": [{"report_id": 32, "bug_id": 20, "description": "Wolpertinger spawnen nicht", "expected_behavior": None,
|
|
"character_name": "Tester", "created_at": "2026-10-08T13:02:21", "target_type": "creature", "target_entry": 23486, "quest_id": 11117}],
|
|
"bug/reproductions.json": [{"reproduction_id": 41, "report_id": 32, "bug_id": 20, "result": "reproduced", "steps": None,
|
|
"observation": "No spawns here; the other location worked", "tester_character_name": "Tester",
|
|
"finished_at": "2026-10-08T13:04:02", "diagnostic_focus_type": "quest", "diagnostic_focus_id": 11117,
|
|
"map_id": 0, "zone_id": 1, "area_id": 1}],
|
|
"bug/reproduction_events.json": [{"event_id": 527, "reproduction_id": 41, "source": "tester", "event_type": "tester_note",
|
|
"event_time": "2026-10-08T13:02:55", "data_json": json.dumps({"text": "Still no spawns"})}],
|
|
"database/quest_template.json": [{"ID": 11117}], "source/secondary.json": [{"numeric_hit": 11117}],
|
|
"unknown.bin": b"\x00\xff", "environment/core.json": {"commit": "verified-source-revision"},
|
|
}
|
|
src_manifest = {"tool": "wowsrc", "format_version": 7, "tool_version": "0.7", "command": "bug", "bug_id": 20,
|
|
"core_revision": "verified-source-revision", "input_wowdiag_format": 2, "input_wowdiag_version": "0.10.6", "warnings": []}
|
|
src_entries = {"manifest.json": src_manifest, "input/wowdiag_manifest.json": diag_manifest,
|
|
"source/development_files_index.json": [{"file": "/unavailable/server/source.cpp", "package_path": "source/development_files/source.cpp", "copied": True, "size": 4}],
|
|
"source/development_files/source.cpp": b"code", "database/schema.json": {"columns": []},
|
|
"source/primary_implementation_units.json": [], "source/source_ranking_policy.json": {"numeric_only_fallback_promotion": False},
|
|
"unknown.extension": b"retained"}
|
|
return make_tar(diag_entries), make_tar(src_entries), diag_entries, src_entries
|