Fix Zotero table models for Zotero 9:
- Remove stale Annotations/Highlights/Transaction* models
- Add ItemAnnotations, RetractedItems, DeletedCollections,
DeletedSearches, DbDebug1
- Fix ItemAttachments, Libraries, Users column mismatches
New test files covering all major modules:
- cli/{bib,prisma,rec,zot,mail,run} deep exercising tests
- mail/{droplet,postmark,resend,cloudflare} lifecycle tests
- bib/{iom,oig,pincite,sync,regulations_gov,email_ingest,format,store}
- prisma/{vpn,fetch,export,llm,screen,eligibility,extract,project,ingest,flow}
- aco/lake/{unity,quality,deploy} + api/aco coverage gaps
- zot/{ops,db,extract,duck} + rec/{report,engine,base,pricers}
- pfs/{pipe,rules,eq,files}
Add pytest-xdist for parallel test execution.
Tracks #353
98 lines
3.2 KiB
Python
98 lines
3.2 KiB
Python
"""Exercise mail.resend — domain registration + DNS publishing."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import pytest
|
|
|
|
|
|
class TestEnsureResendDomain:
|
|
@patch("mail.resend.env", return_value="test-key")
|
|
def test_adopts_existing(self, mc_env):
|
|
mock_resend = MagicMock()
|
|
mock_resend.Domains.list.return_value = {
|
|
"data": [{"id": "d1", "name": "corwins.media"}]
|
|
}
|
|
mock_resend.Domains.get.return_value = {
|
|
"id": "d1",
|
|
"name": "corwins.media",
|
|
"status": "verified",
|
|
"records": [],
|
|
}
|
|
|
|
with patch.dict(
|
|
sys.modules, {"resend": mock_resend, "resend.exceptions": MagicMock()}
|
|
):
|
|
from mail.resend import ensure_resend_domain
|
|
|
|
result = ensure_resend_domain("corwins.media")
|
|
assert result["name"] == "corwins.media"
|
|
|
|
@patch("mail.resend.env", return_value="test-key")
|
|
def test_creates_new(self, mc_env):
|
|
mock_resend = MagicMock()
|
|
mock_resend.Domains.list.return_value = {"data": []}
|
|
mock_resend.Domains.create.return_value = {"id": "d2"}
|
|
mock_resend.Domains.get.return_value = {
|
|
"id": "d2",
|
|
"name": "new.com",
|
|
"status": "pending",
|
|
"records": [],
|
|
}
|
|
|
|
with patch.dict(
|
|
sys.modules, {"resend": mock_resend, "resend.exceptions": MagicMock()}
|
|
):
|
|
from mail.resend import ensure_resend_domain
|
|
|
|
result = ensure_resend_domain("new.com")
|
|
assert result["id"] == "d2"
|
|
mock_resend.Domains.verify.assert_called_once()
|
|
|
|
@patch("mail.resend.env", return_value="")
|
|
def test_no_api_key(self, mc_env):
|
|
mock_resend = MagicMock()
|
|
with patch.dict(
|
|
sys.modules, {"resend": mock_resend, "resend.exceptions": MagicMock()}
|
|
):
|
|
from mail.resend import ensure_resend_domain
|
|
|
|
with pytest.raises(RuntimeError, match="RESEND_API_KEY"):
|
|
ensure_resend_domain("example.com")
|
|
|
|
|
|
class TestPublishResendDns:
|
|
@patch("mail.cloudflare._upsert_record")
|
|
@patch("mail.cloudflare._zone_id", return_value="z1")
|
|
def test_publishes_records(self, mc_zone, mc_upsert):
|
|
from mail.resend import publish_resend_dns
|
|
|
|
domain_info = {
|
|
"name": "corwins.media",
|
|
"records": [
|
|
{"name": "@", "type": "TXT", "value": "v=spf1 include:resend.com ~all"},
|
|
{"name": "resend._domainkey", "type": "TXT", "value": "v=DKIM1; p=abc"},
|
|
{
|
|
"name": "bounces",
|
|
"type": "MX",
|
|
"value": "feedback-smtp.resend.com",
|
|
"priority": 10,
|
|
},
|
|
],
|
|
}
|
|
cf = MagicMock()
|
|
publish_resend_dns(domain_info, cf)
|
|
assert mc_upsert.call_count == 3
|
|
|
|
@patch("mail.cloudflare._upsert_record")
|
|
@patch("mail.cloudflare._zone_id", return_value="z1")
|
|
def test_no_records(self, mc_zone, mc_upsert):
|
|
from mail.resend import publish_resend_dns
|
|
|
|
domain_info = {"name": "corwins.media", "records": []}
|
|
cf = MagicMock()
|
|
publish_resend_dns(domain_info, cf)
|
|
mc_upsert.assert_not_called()
|