テスト完了
This commit is contained in:
parent
b8635ff992
commit
b835aaa6ff
@ -412,8 +412,8 @@ class ComInstAttMapper(UltmarcTableMapper):
|
||||
:anesthetizing_manage_spec_day,
|
||||
:anesthetizing_manage_can_day,
|
||||
:home_recuperation_flag,
|
||||
:home_recuperation_specday,
|
||||
:home_recuperation_cancelday,
|
||||
:home_recuperation_spec_day,
|
||||
:home_recuperation_cancel_day,
|
||||
:synthesis_when_staying_flag,
|
||||
:synthesis_when_staying_spec_day,
|
||||
:synthesis_when_staying_can_day,
|
||||
@ -666,7 +666,7 @@ class ComInstAttMapper(UltmarcTableMapper):
|
||||
|
||||
def make_query(self):
|
||||
# 『修正区分がB(修正)かつ専門医メンテナンス区分が1(退職)』の場合、物理削除
|
||||
if self.record.maint_flag == 'C' and self.record.adddel_div == 1:
|
||||
if self.record.maint_flag == 'B' and self.record.adddel_div == '1':
|
||||
self.queries.append(self.PHYSICAL_DELETE_QUERY)
|
||||
return
|
||||
|
||||
@ -732,7 +732,7 @@ class ComInstAttMapper(UltmarcTableMapper):
|
||||
set_clauses.append('areasuphpcandate = :areasuphp_can_date')
|
||||
if self.record.areasuphp_flag == '@':
|
||||
self.query_parameter['areasuphp_flag'] = ''
|
||||
self.query_parameter['areasuphp_intrate'] = ''
|
||||
self.query_parameter['areasuphp_intrate'] = None
|
||||
self.query_parameter['areasuphp_ok_date'] = ''
|
||||
self.query_parameter['areasuphp_can_date'] = ''
|
||||
|
||||
@ -960,8 +960,8 @@ class ComInstAttMapper(UltmarcTableMapper):
|
||||
|
||||
# ケアミックス区分
|
||||
if len(self.record.caremix_kind) > 0:
|
||||
set_clauses.append('homelateflag = :caremix_kind')
|
||||
if self.record.caremixkind == '@':
|
||||
set_clauses.append('caremixkind = :caremix_kind')
|
||||
if self.record.caremix_kind == '@':
|
||||
self.query_parameter['caremix_kind'] = ''
|
||||
|
||||
# 完全型・移行型区分
|
||||
@ -971,7 +971,7 @@ class ComInstAttMapper(UltmarcTableMapper):
|
||||
self.query_parameter['fullmove_flag'] = ''
|
||||
|
||||
# 療養型病床群
|
||||
if sum(len(item) for item in self.record.resthp_list) > 0:
|
||||
if sum(len(item) for item in self.record.resthp_items) > 0:
|
||||
set_clauses.append('resthpflag = :resthp_flag')
|
||||
set_clauses.append('resthpcarekind = :resthp_care_kind')
|
||||
set_clauses.append('resthpbednum = :resthp_bed_num')
|
||||
@ -985,14 +985,14 @@ class ComInstAttMapper(UltmarcTableMapper):
|
||||
if self.record.resthp_flag == '@':
|
||||
self.query_parameter['resthp_flag'] = ''
|
||||
self.query_parameter['resthp_care_kind'] = ''
|
||||
self.query_parameter['resthp_bed_num'] = ''
|
||||
self.query_parameter['resthp_bed_num'] = None
|
||||
self.query_parameter['resthp_ok_date'] = ''
|
||||
self.query_parameter['resthp_can_date'] = ''
|
||||
self.query_parameter['resthp_care_nrs_kind'] = ''
|
||||
self.query_parameter['resthp_care_bed_num'] = ''
|
||||
self.query_parameter['resthp_care_bed_num'] = None
|
||||
self.query_parameter['resthp_care_ok_date'] = ''
|
||||
self.query_parameter['resthp_care_can_date'] = ''
|
||||
self.query_parameter['resthp_sbed_num'] = ''
|
||||
self.query_parameter['resthp_sbed_num'] = None
|
||||
|
||||
# 一般病棟
|
||||
if len(self.record.nrmhp_flag) > 0:
|
||||
@ -1002,7 +1002,7 @@ class ComInstAttMapper(UltmarcTableMapper):
|
||||
if self.record.nrmhp_flag == '@':
|
||||
self.query_parameter['nrmhp_flag'] = ''
|
||||
self.query_parameter['nrmhp_care_kind'] = ''
|
||||
self.query_parameter['nrmhp_bed_total_num'] = ''
|
||||
self.query_parameter['nrmhp_bed_total_num'] = None
|
||||
|
||||
# 精神病棟
|
||||
if len(self.record.menthp_flag) > 0:
|
||||
@ -1012,7 +1012,7 @@ class ComInstAttMapper(UltmarcTableMapper):
|
||||
if self.record.menthp_flag == '@':
|
||||
self.query_parameter['menthp_flag'] = ''
|
||||
self.query_parameter['menthp_care_kind'] = ''
|
||||
self.query_parameter['menthp_bed_num'] = ''
|
||||
self.query_parameter['menthp_bed_num'] = None
|
||||
|
||||
# 結核病棟
|
||||
if len(self.record.tubhp_flag) > 0:
|
||||
@ -1022,7 +1022,7 @@ class ComInstAttMapper(UltmarcTableMapper):
|
||||
if self.record.tubhp_flag == '@':
|
||||
self.query_parameter['tubhp_flag'] = ''
|
||||
self.query_parameter['tubhp_care_kind'] = ''
|
||||
self.query_parameter['tubhp_bed_num'] = ''
|
||||
self.query_parameter['tubhp_bed_num'] = None
|
||||
|
||||
# 感染症指定医療機関
|
||||
if len(self.record.infhp_flag) > 0:
|
||||
@ -1040,7 +1040,7 @@ class ComInstAttMapper(UltmarcTableMapper):
|
||||
set_clauses.append('infhpbednum = :infhp_bed_num')
|
||||
if self.record.infhp_bed_flag == '@':
|
||||
self.query_parameter['infhp_bed_flag'] = ''
|
||||
self.query_parameter['infhp_bed_num'] = ''
|
||||
self.query_parameter['infhp_bed_num'] = None
|
||||
|
||||
# 緩和ケア病棟設置病院
|
||||
if len(self.record.hospice_flag) > 0:
|
||||
@ -1050,7 +1050,7 @@ class ComInstAttMapper(UltmarcTableMapper):
|
||||
set_clauses.append('hospicecandate = :hospice_can_date')
|
||||
if self.record.hospice_flag == '@':
|
||||
self.query_parameter['hospice_flag'] = ''
|
||||
self.query_parameter['hospice_bed_num'] = ''
|
||||
self.query_parameter['hospice_bed_num'] = None
|
||||
self.query_parameter['hospice_ok_date'] = ''
|
||||
self.query_parameter['hospice_can_date'] = ''
|
||||
|
||||
@ -1059,12 +1059,12 @@ class ComInstAttMapper(UltmarcTableMapper):
|
||||
set_clauses.append('hpfuncestflag = :hpfunce_st_flag')
|
||||
set_clauses.append('hpfuncestkind = :hpfunce_st_kind')
|
||||
set_clauses.append('hpfuncestokdate = :hpfunce_st_ok_date')
|
||||
set_clauses.append('hpfuncestcandate = :hospice_ok_date')
|
||||
set_clauses.append('hpfuncestcandate = :hpfunce_st_can_date')
|
||||
if self.record.hpfunce_st_flag == '@':
|
||||
self.query_parameter['hpfunce_st_flag'] = ''
|
||||
self.query_parameter['hpfunce_st_kind'] = ''
|
||||
self.query_parameter['hpfunce_st_ok_date'] = ''
|
||||
self.query_parameter['hospice_ok_date'] = ''
|
||||
self.query_parameter['hpfunce_st_can_date'] = ''
|
||||
|
||||
# 臨床研修指定病院
|
||||
if sum(len(item) for item in self.record.cl_items) > 0:
|
||||
|
||||
@ -19,7 +19,7 @@ class ComInstAtt(UltmarcTable):
|
||||
funchp_ok_date: str # 特定機能病院承認年月日
|
||||
funchp_can_date: str # 特定機能病院取消年月日
|
||||
areasuphp_flag: str # 地域医療支援病院フラグ
|
||||
areasuphp_intrate: str # 地域医 ※
|
||||
areasuphp_intrate: str # 地域医療支援病院紹介率 ※
|
||||
areasuphp_ok_date: str # 地域医療支援病院承認年月日
|
||||
areasuphp_can_date: str # 地域医療支援病院取消年月日
|
||||
acuthp_add_flag: str # 超急性期脳卒中加算フラグ
|
||||
@ -103,30 +103,30 @@ class ComInstAtt(UltmarcTable):
|
||||
fullmove_flag: str # 完全型・移行型区分
|
||||
resthp_flag: str # 療養型病床群フラグ
|
||||
resthp_care_kind: str # 療養型病床群_医療型(看護種別)
|
||||
resthp_bed_num: str # 療養 ※
|
||||
resthp_bed_num: str # 療養型病床群_医療型(病床数) ※
|
||||
resthp_ok_date: str # 療養型病床群_医療型(承認年月日)
|
||||
resthp_can_date: str # 療養型病床群_医療型(取消年月日)
|
||||
resthp_care_nrs_kind: str # 療養型病床群_介護型(看護種別)
|
||||
resthp_care_bed_num: str # 療養 ※
|
||||
resthp_care_bed_num: str # 療養型病床群_介護型(病床数) ※
|
||||
resthp_care_ok_date: str # 療養型病床群_介護型(承認年月日)
|
||||
resthp_care_can_date: str # 療養型病床群_介護型(取消年月日)
|
||||
resthp_sbed_num: str # 療養 ※
|
||||
resthp_sbed_num: str # 療養型病床群_稼動数合計(病床数) ※
|
||||
nrmhp_flag: str # 一般病棟フラグ
|
||||
nrmhp_care_kind: str # 一般病棟看護種別
|
||||
nrmhp_bed_total_num: str # 一般 ※
|
||||
nrmhp_bed_total_num: str # 一般病棟病床数 ※
|
||||
menthp_flag: str # 精神病棟フラグ
|
||||
menthp_care_kind: str # 精神病棟看護種別
|
||||
menthp_bed_num: str # 精神 ※
|
||||
menthp_bed_num: str # 精神病棟病床数 ※
|
||||
tubhp_flag: str # 結核病棟フラグ
|
||||
tubhp_care_kind: str # 結核病棟看護種別
|
||||
tubhp_bed_num: str # 結核 ※
|
||||
tubhp_bed_num: str # 結核病棟病床数 ※
|
||||
infhp_flag: str # 感染症特定
|
||||
infhp_flag1: str # 感染症1種
|
||||
infhp_flag2: str # 感染症2種
|
||||
infhp_bed_flag: str # 感染症病床フラグ
|
||||
infhp_bed_num: str # 感染症病 ※
|
||||
infhp_bed_num: str # 感染症病床病床数 ※
|
||||
hospice_flag: str # 緩和ケア病棟設置病院フラグ
|
||||
hospice_bed_num: str # 緩和ケア ※
|
||||
hospice_bed_num: str # 緩和ケア病棟設置病院病床数 ※
|
||||
hospice_ok_date: str # 緩和ケア病棟設置病院承認年月日
|
||||
hospice_can_date: str # 緩和ケア病棟設置病院取消年月日
|
||||
hpfunce_st_flag: str # 医療機能評価フラグ
|
||||
@ -663,8 +663,10 @@ class ComInstAtt(UltmarcTable):
|
||||
|
||||
# DCFDSF施設コード
|
||||
self.dcfdsf_inst_code = self.dcfhp_id + self.dcfhp_code + self.dcfhp_yobi
|
||||
|
||||
# 療養型病床群
|
||||
self.resthp_items = [
|
||||
self.resthp_flag,
|
||||
self.resthp_care_kind,
|
||||
self.resthp_bed_num,
|
||||
self.resthp_ok_date,
|
||||
@ -688,3 +690,14 @@ class ComInstAtt(UltmarcTable):
|
||||
self.cldephp_ok_date,
|
||||
self.cldephp_can_date
|
||||
]
|
||||
|
||||
# smallint型のカラム値は、空文字で渡ってきた場合はNULLに変換する
|
||||
self.areasuphp_intrate = self.areasuphp_intrate if len(self.areasuphp_intrate) > 0 else None
|
||||
self.resthp_bed_num = self.resthp_bed_num if len(self.resthp_bed_num) > 0 else None
|
||||
self.resthp_care_bed_num = self.resthp_care_bed_num if len(self.resthp_care_bed_num) > 0 else None
|
||||
self.resthp_sbed_num = self.resthp_sbed_num if len(self.resthp_sbed_num) > 0 else None
|
||||
self.nrmhp_bed_total_num = self.nrmhp_bed_total_num if len(self.nrmhp_bed_total_num) > 0 else None
|
||||
self.menthp_bed_num = self.menthp_bed_num if len(self.menthp_bed_num) > 0 else None
|
||||
self.tubhp_bed_num = self.tubhp_bed_num if len(self.tubhp_bed_num) > 0 else None
|
||||
self.infhp_bed_num = self.infhp_bed_num if len(self.infhp_bed_num) > 0 else None
|
||||
self.hospice_bed_num = self.hospice_bed_num if len(self.hospice_bed_num) > 0 else None
|
||||
|
||||
@ -28,13 +28,13 @@ class TestComInstMapper:
|
||||
# setup
|
||||
self.db = database
|
||||
self.db.connect()
|
||||
# self.db.begin()
|
||||
self.db.begin()
|
||||
|
||||
# testing
|
||||
yield
|
||||
|
||||
# teardown
|
||||
# self.db.rollback()
|
||||
self.db.rollback()
|
||||
self.db.disconnect()
|
||||
|
||||
def test_insert_record(self):
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
"111","123","456789","99","B","1","NULL","NULL","9","20230510","20230511","2","2023","20230514","5","20230516","20230517","8","20230519","20230520","1","22.1","20230523","20230524","5","20230526","20230527","8","20230529","20230530","1","20230502","20230503","4","20230505","20230506","7","20230508","20230509","0","20230501","20230402","3","20230404","20230405","6","20230407","20230408","9","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","0","20230701","20230702","3","20230704","20230705","6","20230707","20230708","9","80","81","82","83","84","85","86","87","88","89","0","20230901","20230902","3","20230904","20230905","6","20230907","20230908","9","20231001","20231011","2","3","4","105","106","20231007","20231008","109","110","20231101","20231102","113","4","0115","116","7","0118","119","0","0121","122","3","4","5","6","127","8","129","20230130","20230131","2","33","20230104","20230105","6","20230107","20230108","9","20230104","20230101","2","20230103","20230104","5","6","7","8","9","0","1","20230102","20230403","4","20230105","20230106","7","8","9","160","1","162","3","164","5","166","7","168","9","170","1","172","3","174","5","176","7","178","9","180","1","182","3","184","5","186","7","188","9","190","1","192","3","194","5","196","7","198","9","200","1","202","3","204","5","206","7","208","9","210","1","212","3","214","5","216","7","218","9","220","1","222","3","224","5","226","7","228","9","230","1","232","3","234","5","236","7","238","9","0","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","1","62","3","64","5","66","7","68","9","70","1","72","3","74","5","76","7","78","9","80","1","82","3","84","5","86","7","88","9","90","1","92","3","94","5","96","7","98","9","00","1","2","3","0000304","05","202303"
|
||||
"111","00","9900146","","B","1","20160905","20160910","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
|
||||
"111","00","9900615","","B","1","20160905","20160910","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
|
||||
"111","00","9901806","","B","1","20160905","20160910","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
|
||||
"111","00","9901918","","B","1","20160905","20160910","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
|
||||
"111","00","9904136","","B","1","20160905","20160910","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
|
||||
|
Can't render this file because it has a wrong number of fields in line 2.
|
@ -0,0 +1,20 @@
|
||||
"111","123","456789","99","A","0","NULL","NULL","9","20230510","20230511","2","2023","20230514","5","20230516","20230517","8","20230519","20230520","1","22.1","20230523","20230524","5","20230526","20230527","8","20230529","20230530","1","20230502","20230503","4","20230505","20230506","7","20230508","20230509","0","20230501","20230402","3","20230404","20230405","6","20230407","20230408","9","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","0","20230701","20230702","3","20230704","20230705","6","20230707","20230708","9","80","81","82","83","84","85","86","87","88","89","0","20230901","20230902","3","20230904","20230905","6","20230907","20230908","9","20231001","20231011","2","3","4","105","106","20231007","20231008","109","110","20231101","20231102","113","4","0115","116","7","0118","119","0","0121","122","3","4","5","6","127","8","129","20230130","20230131","2","33","20230104","20230105","6","20230107","20230108","9","20230104","20230101","2","20230103","20230104","5","6","7","8","9","0","1","20230102","20230403","4","20230105","20230106","7","8","9","160","1","162","3","164","5","166","7","168","9","170","1","172","3","174","5","176","7","178","9","180","1","182","3","184","5","186","7","188","9","190","1","192","3","194","5","196","7","198","9","200","1","202","3","204","5","206","7","208","9","210","1","212","3","214","5","216","7","218","9","220","1","222","3","224","5","226","7","228","9","230","1","232","3","234","5","236","7","238","9","0","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","1","62","3","64","5","66","7","68","9","70","1","72","3","74","5","76","7","78","9","80","1","82","3","84","5","86","7","88","9","90","1","92","3","94","5","96","7","98","9","00","1","2","3","0000304","05","202303"
|
||||
"111","00","9900146","","A","2","20141113","20141114","1","20080701","","","","","1","20100401","","","","","1","","20011022","","1","20130501","","1","20130501","","1","20130501","","1","20130501","","1","20130501","","1","20130501","","","","20081130","1","20130501","","1","99","","","","","","","","","","","","","","","","","","","","1","20130501","","1","20140401","","1","20130501","","1","01","02","03","04","","","","","","","1","20130501","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","1","4","","","","","","","","","","","20040229","1","20031030","","1","20050914","","1","1","","1","","","","","","1","20090401","","","","1","217","5","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","11","31","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","195604"
|
||||
"111","00","9900194","","A","2","20141113","20141114","1","20060501","","","","","","","","","","","","","","20111231","","","","","","","1","20130801","","1","20140501","","1","20120401","","","","","","","","","","","1","99","","","","","","","","","","","","","","","","","","","","1","20100401","","1","20091101","","1","20131101","","1","01","02","03","","","","","","","","1","20080601","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","08","20130705","","","","","","","20110331","1","20040331","","","1","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","11","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","198204"
|
||||
"111","00","9900615","","A","2","20141113","20141114","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","1","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
|
||||
"111","00","9900631","","A","2","20141113","20141114","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","20120401","","1","20060401","","1","19971001","","","1","1","3991","6","19990930","","","","","","6","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
|
||||
"111","00","9900700","","A","2","20141113","20141114","1","20100701","","","","","1","20100401","","","","","1","","20080514","","1","20080401","","","","","1","20140401","","1","20061101","","1","20080401","","1","20120601","","","","","1","20080601","","1","99","","","","","","","","","","","","","","","","","","","","1","20061101","","1","20061101","","1","20080401","","1","01","02","03","","","","","","","","1","20061101","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","1","4","","","","","","","","20061118","1","20030401","","","","","1","20031030","","1","1","1","1","","","","","","","","","","","1","169","1","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","31","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","195310"
|
||||
"111","00","9901649","","A","2","20141113","20141114","","","","1","2009","","","","","","","","","","","","","","","","","","1","20121201","","1","20080901","","","","20080331","","","","","","","1","20080701","","1","99","","","","","","","","","","","","","","","","","","","","1","20100401","","","","","","","","1","01","02","03","","","","","","","","1","19970701","","1","20130101","","1","20060401","","","","","1","9","1","I001","43","20061001","","","","","","43","1","B999","120","","","","","","","","","","","","","","","","1","12","20131101","","","","","","","","","","","","1","1","","","","","","","","","","1","1","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","11","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","198004"
|
||||
"111","00","9901806","","A","2","20141113","20141114","1","20090401","","","","","1","20100401","","","","","1","","20130806","","1","20080401","","","","","1","20131101","","1","20000401","","1","20080401","","","","","","","","1","20130901","","1","99","","","","","","","","","","","","","","","","","","","","1","20100401","","1","20020401","","1","20110701","","1","01","02","03","","","","","","","","1","19960401","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","1","8","","","","20010731","1","13","20140502","","","","20040229","1","20031030","","1","20031030","","1","1","","1","","","","","","","","","1","1","1","202","1","198","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","11","31","34","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","195011"
|
||||
"111","00","9901820","","A","2","20141113","20141114","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","19981130","1","20030601","","","","","1","01","02","","","","","","","","","","","","1","20140301","","","","","","","","1","1","1","","","","","4101","116","20090501","","116","1","B999","40","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","","","","","","","","","","","1","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","196405"
|
||||
"111","00","9901918","","A","2","20141113","20141114","","","","","","","","","","","","","1","84.6","20020218","","","","","","","","1","20130901","","1","20051001","","1","20120101","","","","","","","","1","19780401","","1","99","","","","","","","","","","","","","","","","","","","","1","20100401","","","","20070531","","","","1","01","02","03","04","","","","","","","","","20070228","","","","","","","","","","1","1","1","I002","84","20120101","","","","","","84","1","B999","177","","","","","","","","","","","","","","","","1","11","20110506","","","","","","","","","","","","1","1","","","","","","","","","","1","1","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","11","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","00","3404537","","196601"
|
||||
"111","00","9902043","","A","2","20141113","20141114","1","20140401","","","","20140331","","","","","","","","","","","","","","","","","1","20130501","","1","20100401","","1","20100401","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","20100601","","","","","1","20100401","","1","01","02","","","","","","","","","","","","","","","","","","","","","1","9","1","I002","48","20110401","","","","","","48","1","B999","224","1","M999","40","1","K999","4","","","1","1","4","","","","","","","","","","","","","","","1","20040331","","1","1","","","","","","","","","","","1","1","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","201004"
|
||||
"111","00","9902175","","A","2","20141113","20141114","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","20111001","","1","20111001","","1","20111001","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","20110331","","","","","1","","","","","","","","1","1","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","199704"
|
||||
"111","00","9902728","","A","2","20141113","20141114","1","20090401","","","","","","","","","","","","","","","","","","","","","1","20140401","","1","20140401","","1","20120801","","","","","1","20100401","","","","20040131","1","99","","","","","","","","","","","","","","","","","","","","1","20040214","","1","20100801","","1","20120401","","1","01","02","03","04","","","","","","","1","20030801","","","","","","","","","","","","","","","","","20040430","","","","20040430","","","","","","","","","","","","","","","","","","","","1","08","20121207","","","","","","","","1","20080919","","","1","1","","","","","","","","","","1","1","1","198","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","11","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","00","5303814","","198005"
|
||||
"111","00","9903500","","A","2","20141113","20141114","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","2","9","1","I001","26","20061001","","","","","","26","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","198912"
|
||||
"111","00","9904136","","A","2","20141113","20141114","1","20080701","","","","","","","","","","","1","","20111125","","1","20110401","","1","20130501","","1","20120601","","1","20110401","","1","20110401","","","","","","","","1","20110401","","1","99","","","","","","","","","","","","","","","","","","","","1","20110401","","1","20110801","","1","20110401","","1","01","02","03","04","","","","","","","1","20110401","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","1","1","1","10","","","","","1","13","20140307","","","","","1","19990401","","1","20040331","","1","1","1","1","","","","","","","","","1","","1","228","5","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","34","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","195208"
|
||||
"111","00","9904439","","A","2","20141113","20141114","1","20060401","","","","","","","20100331","","","","1","97.9","20041105","","","","","","","","1","20130401","","1","20140401","","1","20100701","","","","","","","","1","20020201","","1","99","","","","","","","","","","","","","","","","","","","","1","20140401","","1","20140401","","","","","1","01","02","03","","","","","","","","1","20131101","","","","","","","","","","","1","1","1","I001","54","20120401","","","","","20040930","54","1","B999","450","","","","","","","","","","","","1","21","20130901","","1","13","20130906","","","","","1","20041001","","","","","1","1","1","","","","","","","","","","1","1","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","198812"
|
||||
"111","00","9906696","","A","2","20141113","20141114","1","20060601","","","","","","","","","","","1","","20100401","","1","20080401","","","","","1","20140401","","1","20020401","","1","20080701","","","","","","","","1","20090401","","1","99","","","","","","","","","","","","","","","","","","","","1","20100401","","1","20040501","","","","20081130","1","01","02","03","04","","","","","","","1","19970901","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","13","20140404","","","","","1","20031030","","1","20031027","","","1","1","","","","","","","","","","1","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","00","8106522","","199708"
|
||||
"111","00","9908576","","A","2","20141113","20141114","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","20100401","","","","","1","20080401","","","","","","","","","","","","","","","","","","20070831","","","20070831","","","","2","9","1","I001","33","20130401","","","","","","33","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","200704"
|
||||
"111","00","9910624","","A","2","20141113","20141114","1","20030401","","","","","1","20120401","","1","19940201","","","","","","1","20120401","","","","","","","","1","20121201","","1","20090701","","1","20061101","","","","","","","","1","99","","","","","","","","","","","","","","","","","","","","1","20100401","","1","20140401","","1","20140401","","1","01","02","03","04","","","","","","","1","20140401","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","08","20100402","","","","20060331","1","20041001","","1","20040331","","1","1","1","","","1","2","20070702","","","","","1","1","1","002","1","006","1","051","4","004","1","100","2","165","1","035","1","168","1","118","1","101","1","182","","202","1","214","5","149","","197","1","198","","177","1","183","1","213","5","217","5","212","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","11","31","34","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","192202"
|
||||
"111","00","9929798","","A","2","20141113","20141114","1","20080701","","","","","","","","","","","","","","","","","","","","","1","20100401","","1","20090301","","1","20100401","","","","20080531","","","","1","19971201","","","","","","","","","","","","","","","","","","","","","","","1","20100401","","","","","1","20080401","","1","01","02","03","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","13","20140106","","","","","","","","1","20040331","","","1","1","","","","","","","","","","1","1","1","168","1","197","1","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","195305"
|
||||
|
@ -0,0 +1,5 @@
|
||||
"111","123","456789","99","A","0","NULL","NULL","9","20230510","20230511","2","2023","20230514","5","20230516","20230517","8","20230519","20230520","1","22.1","20230523","20230524","5","20230526","20230527","8","20230529","20230530","1","20230502","20230503","4","20230505","20230506","7","20230508","20230509","0","20230501","20230402","3","20230404","20230405","6","20230407","20230408","9","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","0","20230701","20230702","3","20230704","20230705","6","20230707","20230708","9","80","81","82","83","84","85","86","87","88","89","0","20230901","20230902","3","20230904","20230905","6","20230907","20230908","9","20231001","20231011","2","3","4","105","106","20231007","20231008","109","110","20231101","20231102","113","4","0115","116","7","0118","119","0","0121","122","3","4","5","6","127","8","129","20230130","20230131","2","33","20230104","20230105","6","20230107","20230108","9","20230104","20230101","2","20230103","20230104","5","6","7","8","9","0","1","20230102","20230403","4","20230105","20230106","7","8","9","160","1","162","3","164","5","166","7","168","9","170","1","172","3","174","5","176","7","178","9","180","1","182","3","184","5","186","7","188","9","190","1","192","3","194","5","196","7","198","9","200","1","202","3","204","5","206","7","208","9","210","1","212","3","214","5","216","7","218","9","220","1","222","3","224","5","226","7","228","9","230","1","232","3","234","5","236","7","238","9","0","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","1","62","3","64","5","66","7","68","9","70","1","72","3","74","5","76","7","78","9","80","1","82","3","84","5","86","7","88","9","90","1","92","3","94","5","96","7","98","9","00","1","2","3","0000304","05","202303"
|
||||
"111","00","9900631","","B","","20141113","20141114","1","20171009","","1","2017","20171009","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","@","","","@","","","","","","","@","@","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","3","","","","","","","","","","","","","","","","","","","","1","1","2","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","1","0","12","","20",""
|
||||
"111","00","9901649","","B","","20141113","20141114","","","","1","2009","20171010","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","201710"
|
||||
"111","00","9990146","","B","","20171113","20171114","@","","","@","","","@","","","@","","","@","","","","@","","","@","","","@","","","@","","","@","","","@","","","@","","","@","","","@","","","","","","","","","","","","","","","","","","","","","@","","","@","","","@","","","@","","","","","","","","","","","@","","","@","","","@","","","@","","","@","@","@","","","","","","","","","","@","","","@","","","@","","","@","","","@","","@","","","","@","","","","@","","","","","","","","","@","@","","","@","@","","","","@","","","@","@","@","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","@","","","","","","","","","","","","","","","","","","","","","@","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","@","","","","@"
|
||||
"111","99","9999999","99","B","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,232 @@
|
||||
import os.path as path
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
|
||||
from src.batch.common.batch_context import BatchContext
|
||||
from src.batch.ultmarc.utmp_tables.table_mapper.concrete import com_inst_att_mapper
|
||||
from src.db.database import Database
|
||||
from tests.testing_utility import (assert_table_results,
|
||||
create_db_data_from_csv,
|
||||
create_delete_sql_with_parameter,
|
||||
create_insert_sql_with_parameter,
|
||||
create_ultmarc_table_mapper_sut,
|
||||
create_ultmarc_test_data_from_csv)
|
||||
|
||||
|
||||
class TestComInstAttMapper:
|
||||
"""レイアウト区分111: COM_施設属性"""
|
||||
|
||||
db: Database
|
||||
batch_context: BatchContext
|
||||
test_file_path: str = path.dirname(__file__)
|
||||
|
||||
# smallint型のカラム群
|
||||
smallint_columns = [
|
||||
'areasuphpintrate',
|
||||
'resthpbednum',
|
||||
'resthpcarebednum',
|
||||
'resthpsbednum',
|
||||
'nrmhpbedtotalnum',
|
||||
'menthpbednum',
|
||||
'tubhpbednum',
|
||||
'infhpbednum',
|
||||
'hospicebednum'
|
||||
]
|
||||
|
||||
@pytest.fixture(autouse=True, scope='function')
|
||||
def pre_test(self, database: Database):
|
||||
"""テスト実行前後処理"""
|
||||
self.batch_context = BatchContext.get_instance()
|
||||
# setup
|
||||
self.db = database
|
||||
self.db.connect()
|
||||
self.db.begin()
|
||||
|
||||
# testing
|
||||
yield
|
||||
|
||||
# teardown
|
||||
self.db.rollback()
|
||||
self.db.disconnect()
|
||||
|
||||
def test_insert_record(self):
|
||||
"""
|
||||
Cases:
|
||||
COM_施設属性テーブルにレコードを登録する
|
||||
Arranges:
|
||||
- CSVデータを用意し、読み込む
|
||||
- 追加対象となるレコードを削除する
|
||||
Expects:
|
||||
- 登録内容が期待値と一致すること
|
||||
"""
|
||||
|
||||
# Arrange
|
||||
# 処理日設定
|
||||
self.batch_context.syor_date = datetime.strftime(datetime.now(), '%Y/%m/%d')
|
||||
# テスト用のCSVを読み込む
|
||||
test_dat_file = create_ultmarc_test_data_from_csv(path.join(self.test_file_path, 'com_inst_att_insert.csv'))
|
||||
# 一旦全データをDBから削除
|
||||
delete_sql, delete_parameter = create_delete_sql_with_parameter('src05.com_inst_att', {'1': '1'})
|
||||
self.db.execute(delete_sql, delete_parameter)
|
||||
|
||||
# Act
|
||||
for line_number, line in enumerate(test_dat_file, start=1):
|
||||
sut: com_inst_att_mapper.ComInstAttMapper = create_ultmarc_table_mapper_sut(line, self.db)
|
||||
assert type(sut) is com_inst_att_mapper.ComInstAttMapper, f'{line_number}行目:マッパークラスが期通りか'
|
||||
|
||||
sut.make_query()
|
||||
sut.execute_queries()
|
||||
|
||||
# Assert
|
||||
# 期待値ファイルを読み込む
|
||||
expect_data_list = create_db_data_from_csv(path.join(self.test_file_path, 'expect_com_inst_att_insert.csv'))
|
||||
primary_keys = [f"'{primary_key['dcf_dsf_inst_cd']}'" for primary_key in expect_data_list]
|
||||
actual_select_sql = f"SELECT * FROM src05.com_inst_att WHERE dcf_dsf_inst_cd IN ({','.join(primary_keys)})"
|
||||
actual_data_list = self.db.execute_select(actual_select_sql)
|
||||
# 期待値検査
|
||||
ignore_columns = ['regist_ymd', 'sys_update_date', 'sys_regist_date'] + self.smallint_columns
|
||||
assert_table_results(actual_data_list, expect_data_list, ignore_col_name=ignore_columns)
|
||||
# 動的日付項目の個別確認
|
||||
line_number = 0
|
||||
for actual_row, expect_row in zip(actual_data_list, expect_data_list):
|
||||
line_number += 1
|
||||
for actual_col_name, expect_col_name in zip(actual_row, expect_row):
|
||||
if actual_col_name in ignore_columns:
|
||||
if actual_col_name in self.smallint_columns:
|
||||
if expect_row[expect_col_name] is not None and len(expect_row[expect_col_name]) > 0:
|
||||
if actual_col_name == 'areasuphpintrate':
|
||||
assert actual_row[actual_col_name] == Decimal(expect_row[expect_col_name]), f'{line_number}行目:{actual_col_name}が、期待値と一致すること'
|
||||
else:
|
||||
assert actual_row[actual_col_name] == int(expect_row[expect_col_name]), f'{line_number}行目:{actual_col_name}が、期待値と一致すること'
|
||||
else:
|
||||
assert actual_row[actual_col_name] >= expect_row[expect_col_name], f'{line_number}行目:{actual_col_name}が、期待値以降であること'
|
||||
|
||||
def test_update_record(self):
|
||||
"""
|
||||
Cases:
|
||||
COM_施設属性テーブルのレコードを更新する
|
||||
Arranges:
|
||||
- CSVデータを用意し、読み込む
|
||||
- 更新対象となるレコードを登録する
|
||||
Expects:
|
||||
- 登録内容が期待値と一致すること
|
||||
"""
|
||||
|
||||
# Arrange
|
||||
# 処理日設定
|
||||
self.batch_context.syor_date = datetime.strftime(datetime.now(), '%Y/%m/%d')
|
||||
# テスト用のCSVを読み込む
|
||||
test_dat_file = create_ultmarc_test_data_from_csv(path.join(self.test_file_path, 'com_inst_att_update.csv'))
|
||||
# 一旦全データをDBから削除
|
||||
delete_sql, delete_parameter = create_delete_sql_with_parameter('src05.com_inst_att', {'1': '1'})
|
||||
self.db.execute(delete_sql, delete_parameter)
|
||||
# テストデータをDBに登録
|
||||
# DBデータを読み込む
|
||||
test_sql_data_list = create_db_data_from_csv(path.join(self.test_file_path, 'db_com_inst_att_before_update.csv'))
|
||||
for test_data in test_sql_data_list:
|
||||
insert_sql, insert_parameter = create_insert_sql_with_parameter(
|
||||
'src05.com_inst_att',
|
||||
test_data.keys(),
|
||||
test_data.values()
|
||||
)
|
||||
self.db.execute(insert_sql, insert_parameter)
|
||||
|
||||
# Act
|
||||
for line_number, line in enumerate(test_dat_file, start=1):
|
||||
sut: com_inst_att_mapper.ComInstAttMapper = create_ultmarc_table_mapper_sut(line, self.db)
|
||||
assert type(sut) is com_inst_att_mapper.ComInstAttMapper, f'{line_number}行目:マッパークラスが期通りか'
|
||||
sut.make_query()
|
||||
sut.execute_queries()
|
||||
|
||||
# Assert
|
||||
# 期待値ファイルを読み込む
|
||||
expect_data_list = create_db_data_from_csv(path.join(self.test_file_path, 'expect_com_inst_att_update.csv'))
|
||||
primary_keys = [f"'{primary_key['dcf_dsf_inst_cd']}'" for primary_key in expect_data_list]
|
||||
actual_select_sql = f"SELECT * FROM src05.com_inst_att WHERE dcf_dsf_inst_cd IN ({','.join(primary_keys)})"
|
||||
actual_data_list = self.db.execute_select(actual_select_sql)
|
||||
# 期待値検査
|
||||
ignore_columns = ['regist_ymd', 'update_ymd', 'sys_update_date', 'sys_regist_date'] + self.smallint_columns
|
||||
assert_table_results(actual_data_list, expect_data_list, ignore_col_name=ignore_columns)
|
||||
# 動的日付項目の個別確認
|
||||
line_number = 0
|
||||
for actual_row, expect_row in zip(actual_data_list, expect_data_list):
|
||||
line_number += 1
|
||||
for actual_col_name, expect_col_name in zip(actual_row, expect_row):
|
||||
if actual_col_name in ignore_columns:
|
||||
if expect_row[expect_col_name] is None:
|
||||
assert actual_row[actual_col_name] is None, f'{line_number}行目:{actual_col_name}が、登録されていないこと'
|
||||
else:
|
||||
if actual_col_name in self.smallint_columns:
|
||||
if expect_row[expect_col_name] is not None and len(expect_row[expect_col_name]) > 0:
|
||||
if actual_col_name == 'areasuphpintrate':
|
||||
assert actual_row[actual_col_name] == Decimal(expect_row[expect_col_name]), f'{line_number}行目:{actual_col_name}が、期待値と一致すること'
|
||||
else:
|
||||
assert actual_row[actual_col_name] == int(expect_row[expect_col_name]), f'{line_number}行目:{actual_col_name}が、期待値と一致すること'
|
||||
else:
|
||||
assert actual_row[actual_col_name] >= expect_row[expect_col_name], f'{line_number}行目:{actual_col_name}が、期待値以降であること'
|
||||
|
||||
def test_logical_delete(self):
|
||||
"""
|
||||
Cases:
|
||||
COM_施設属性テーブルのレコードを1件論理削除する
|
||||
Arranges:
|
||||
- CSVデータを用意し、読み込む
|
||||
- 削除対象となるレコードを登録する
|
||||
Expects:
|
||||
- 登録内容が期待値と一致すること
|
||||
"""
|
||||
|
||||
# Arrange
|
||||
# 処理日設定
|
||||
self.batch_context.syor_date = datetime.strftime(datetime.now(), '%Y/%m/%d')
|
||||
# テスト用のCSVを読み込む
|
||||
test_dat_file = create_ultmarc_test_data_from_csv(path.join(self.test_file_path, 'com_inst_att_delete.csv'))
|
||||
# 一旦全データをDBから削除
|
||||
delete_sql, delete_parameter = create_delete_sql_with_parameter('src05.com_inst_att', {'1': '1'})
|
||||
self.db.execute(delete_sql, delete_parameter)
|
||||
# テストデータをDBに登録
|
||||
# DBデータを読み込む
|
||||
test_sql_data_list = create_db_data_from_csv(path.join(self.test_file_path, 'db_com_inst_att_before_delete.csv'))
|
||||
for test_data in test_sql_data_list:
|
||||
insert_sql, insert_parameter = create_insert_sql_with_parameter(
|
||||
'src05.com_inst_att',
|
||||
test_data.keys(),
|
||||
test_data.values()
|
||||
)
|
||||
self.db.execute(insert_sql, insert_parameter)
|
||||
|
||||
# Act
|
||||
for line_number, line in enumerate(test_dat_file, start=1):
|
||||
sut: com_inst_att_mapper.ComInstAttMapper = create_ultmarc_table_mapper_sut(line, self.db)
|
||||
assert type(sut) is com_inst_att_mapper.ComInstAttMapper, f'{line_number}行目:マッパークラスが期通りか'
|
||||
sut.make_query()
|
||||
sut.execute_queries()
|
||||
|
||||
# Assert
|
||||
# 期待値ファイルを読み込む
|
||||
expect_data_list = create_db_data_from_csv(path.join(self.test_file_path, 'expect_com_inst_att_delete.csv'))
|
||||
primary_keys = [f"'{primary_key['dcf_dsf_inst_cd']}'" for primary_key in expect_data_list]
|
||||
actual_select_sql = f"SELECT * FROM src05.com_inst_att WHERE dcf_dsf_inst_cd IN ({','.join(primary_keys)})"
|
||||
actual_data_list = self.db.execute_select(actual_select_sql)
|
||||
# 期待値検査
|
||||
ignore_columns = ['regist_ymd', 'update_ymd', 'delete_ymd', 'sys_update_date', 'sys_regist_date'] + self.smallint_columns
|
||||
assert_table_results(actual_data_list, expect_data_list, ignore_col_name=ignore_columns)
|
||||
# 動的日付項目の個別確認
|
||||
line_number = 0
|
||||
for actual_row, expect_row in zip(actual_data_list, expect_data_list):
|
||||
line_number += 1
|
||||
for actual_col_name, expect_col_name in zip(actual_row, expect_row):
|
||||
if actual_col_name in ignore_columns:
|
||||
if expect_row[expect_col_name] is None:
|
||||
assert actual_row[actual_col_name] is None, f'{line_number}行目:{actual_col_name}が、登録されていないこと'
|
||||
else:
|
||||
if actual_col_name in self.smallint_columns:
|
||||
if expect_row[expect_col_name] is not None and len(expect_row[expect_col_name]) > 0:
|
||||
if actual_col_name == 'areasuphpintrate':
|
||||
assert actual_row[actual_col_name] == Decimal(expect_row[expect_col_name]), f'{line_number}行目:{actual_col_name}が、期待値と一致すること'
|
||||
else:
|
||||
assert actual_row[actual_col_name] == int(expect_row[expect_col_name]), f'{line_number}行目:{actual_col_name}が、期待値と一致すること'
|
||||
else:
|
||||
assert actual_row[actual_col_name] >= expect_row[expect_col_name], f'{line_number}行目:{actual_col_name}が、期待値以降であること'
|
||||
Loading…
x
Reference in New Issue
Block a user