fix(register): align live sentinel flow with successful HAR

This commit is contained in:
Logic
2026-04-07 13:39:01 +08:00
parent ba02799b18
commit 3c6fce8d57
13 changed files with 1784 additions and 51 deletions

View File

@@ -0,0 +1,40 @@
import unittest
from types import SimpleNamespace
from unittest.mock import patch
class YYDSMailClientDomainTests(unittest.TestCase):
@patch('src.vmail_client.httpx.post')
def test_create_mailbox_sends_configured_domain(self, post_mock):
from src.vmail_client import YYDSMailClient, settings
captured = {}
def fake_post(url, headers=None, json=None, timeout=None):
captured['url'] = url
captured['headers'] = headers
captured['json'] = json
captured['timeout'] = timeout
return SimpleNamespace(
status_code=201,
json=lambda: {
'data': {
'id': 'box-1',
'address': 'chosen@20001028.xyz',
'token': 'temp-token',
}
},
)
post_mock.side_effect = fake_post
with patch.object(settings, 'yyds_mail_domain', '20001028.xyz', create=True):
client = YYDSMailClient()
mailbox = client.create_mailbox()
self.assertEqual(mailbox['address'], 'chosen@20001028.xyz')
self.assertEqual(captured['json'], {'domain': '20001028.xyz'})
if __name__ == '__main__':
unittest.main()