feat: add profile and defalt hospital
This commit is contained in:
@@ -96,9 +96,10 @@ class CmsInstitutionCrudTest(CacheTestCase):
|
||||
self.assertTrue(any(i['code'] == 'CMS-H010' for i in results))
|
||||
|
||||
def test_create_success(self):
|
||||
# type 不可编辑:即便传 type 也忽略,存库恒为 hospital
|
||||
payload = {
|
||||
'code': 'CMS-NEW-1', 'name': '新建示例医院',
|
||||
'type': 'hospital', 'level': '三甲',
|
||||
'type': 'school', 'level': '三甲',
|
||||
'province': '北京', 'city': '北京',
|
||||
}
|
||||
resp = self.client.post(CMS_INST_URL, payload)
|
||||
@@ -107,7 +108,7 @@ class CmsInstitutionCrudTest(CacheTestCase):
|
||||
self.assertEqual(body['code'], 'CMS-NEW-1')
|
||||
self.assertEqual(body['name'], '新建示例医院')
|
||||
self.assertEqual(body['banner_url'], '') # 未配图为空串
|
||||
self.assertTrue(Institution.objects.filter(code='CMS-NEW-1').exists())
|
||||
self.assertEqual(Institution.objects.get(code='CMS-NEW-1').type, 'hospital') # 忽略传入 school
|
||||
|
||||
def test_create_duplicate_code(self):
|
||||
ensure_institution(name='已存在', code='CMS-DUP')
|
||||
@@ -244,12 +245,13 @@ class CmsInstitutionImportExportTest(CacheTestCase):
|
||||
|
||||
def test_import(self):
|
||||
ensure_institution(name='已存在', code='CMS-IMP-DUP')
|
||||
# 导入模板已去掉「类型」列:机构编码 | 名称 | 等级 | 省 | 市(类型固定 hospital)
|
||||
f = _xlsx(
|
||||
['机构编码', '名称', '类型', '等级', '省', '市'],
|
||||
['机构编码', '名称', '等级', '省', '市'],
|
||||
[
|
||||
['CMS-IMP-1', '新医院A', 'hospital', '三甲', '北京', '北京'],
|
||||
['', '无编码', 'hospital', '', '', ''], # 编码空 → 失败
|
||||
['CMS-IMP-DUP', '重复编码', 'hospital', '', '', ''], # 重复 → 失败
|
||||
['CMS-IMP-1', '新医院A', '三甲', '北京', '北京'],
|
||||
['', '无编码', '', '', ''], # 编码空 → 失败
|
||||
['CMS-IMP-DUP', '重复编码', '', '', ''], # 重复 → 失败
|
||||
],
|
||||
)
|
||||
resp = self.client.post('/api/cms/institutions/import/', {'file': f}, format='multipart')
|
||||
@@ -257,4 +259,4 @@ class CmsInstitutionImportExportTest(CacheTestCase):
|
||||
body = resp.json()
|
||||
self.assertEqual(body['success'], 1)
|
||||
self.assertEqual(body['failed'], 2)
|
||||
self.assertTrue(Institution.objects.filter(code='CMS-IMP-1').exists())
|
||||
self.assertEqual(Institution.objects.get(code='CMS-IMP-1').type, 'hospital')
|
||||
|
||||
@@ -151,6 +151,9 @@ class StatsOverviewTest(TransactionTestCase):
|
||||
def test_hospital_overview(self):
|
||||
d = get_auth_client(self.hosp).get(HOSPITAL).json()
|
||||
self.assertEqual(d['profile']['name'], 'A院')
|
||||
self.assertEqual(d['profile']['code'], 'STAT-A') # 机构编码
|
||||
self.assertEqual(d['profile']['province'], '北京') # 省
|
||||
self.assertEqual(d['profile']['city'], '北京') # 市
|
||||
self.assertEqual(d['summary']['student_count'], 2)
|
||||
self.assertEqual(d['summary']['doctor_count'], 1)
|
||||
self.assertEqual(d['summary']['train_total'], 2) # s1+s2 记录
|
||||
|
||||
Reference in New Issue
Block a user