fix: verify cloud image flow and clarify save feedback

This commit is contained in:
Codex
2026-10-04 22:10:03 +08:00
parent 427fd51e14
commit eef46f6ec0
8 changed files with 72 additions and 7 deletions
+11
View File
@@ -25,6 +25,11 @@ class GeographyUnitTests(unittest.TestCase):
result=self.norm(dict(mode='custom',body='火星',path='基地 / 一区 / 一栋'))
self.assertEqual(result['body'],'火星');self.assertEqual(result['countryCode'],'')
def test_invalid_country_types_have_a_validation_error(self):
for code in ([], {}, None, 42, True):
with self.subTest(code=code),self.assertRaises(ValueError):
self.norm(dict(mode='world',countryCode=code))
def test_legacy_edits_drop_stale_codes_and_other_updates_preserve(self):
old=dict(geography=self.norm(dict(mode='china',provinceCode='37',cityCode='3706')),province='山东省',city='烟台市')
item={};geography.apply(item,{},old,app.clean_text,app.Problem)
@@ -39,6 +44,12 @@ class GeographyIntegrationTests(unittest.TestCase):
stop_server=appearance_fixture.AppearanceTests.stop_server
request=appearance_fixture.AppearanceTests.request
def test_bad_country_input_returns_400_and_preserves_profile(self):
old=app.get_object('households',self.aid)
status,result=self.request('/api/households',self.root,dict(id=self.aid,name='不应写入',geography=dict(mode='world',countryCode=[])))
self.assertEqual(status,400);self.assertIn('国家',result['error'])
self.assertEqual(app.get_object('households',self.aid),old)
def test_household_cover_and_path_roundtrip(self):
v=dict(mode='china',provinceCode='37',cityCode='3706',districtCode='370682')
status,saved=self.request('/api/households',self.root,dict(id=self.aid,name='封面与地域',geography=v,coverData=appearance_fixture.image_data()))