自動テスト実装 Vメーカー卸組織展開表 ※検証中
This commit is contained in:
parent
bf7f76e347
commit
0b2c6fe151
@ -564,3 +564,66 @@ class TestImportFileToDb:
|
||||
assert result_src_count[0]['count(*)'] == 6
|
||||
|
||||
# teardown
|
||||
|
||||
def test_load_08_mkr_org_horizon_ok(self, mapper):
|
||||
table_name_org = mapper.get_org_table(mapper.CONDKEY_MKR_ORG_HORIZON)
|
||||
table_name_src = mapper.get_src_table(mapper.CONDKEY_MKR_ORG_HORIZON)
|
||||
|
||||
# setup
|
||||
self.batch_context.is_vjsk_stock_import_day = True
|
||||
self.db.execute(f"truncate table {table_name_src}")
|
||||
|
||||
# assertion1 (insert 4row)
|
||||
|
||||
# 処理実行
|
||||
target_dict = {
|
||||
"condkey": mapper.CONDKEY_MKR_ORG_HORIZON,
|
||||
"src_file_path": path.join(self.test_file_path_load_individual, "mkr_org_horizon_202304280000.tsv")
|
||||
}
|
||||
VjskDataLoadManager.load(target_dict)
|
||||
|
||||
# 期待値データファイル読み込み
|
||||
assert_list = create_vjsk_assertion_list(target_dict["src_file_path"])
|
||||
# orgテーブル結果を取得
|
||||
result_org = self.db.execute_select(f"select * from {table_name_org}")
|
||||
# 突合から除外する項目
|
||||
ignore_columns = ['dwh_upd_dt']
|
||||
# orgテーブル結果が期待値通りかを突合
|
||||
assert_table_results(result_org, assert_list, ignore_columns)
|
||||
# srcテーブル結果を取得
|
||||
result_src = self.db.execute_select(f"select * from {table_name_src}")
|
||||
# 突合から除外する項目
|
||||
ignore_columns = ['dwh_upd_dt']
|
||||
# srcテーブル結果が期待値通りかを突合
|
||||
assert_table_results(result_src, assert_list, ignore_columns)
|
||||
|
||||
# assertion2 (update 2row +insert 2row)
|
||||
|
||||
# 処理実行
|
||||
target_dict = {
|
||||
"condkey": mapper.CONDKEY_MKR_ORG_HORIZON,
|
||||
"src_file_path": path.join(self.test_file_path_load_individual, "mkr_org_horizon_202304290000.tsv")
|
||||
}
|
||||
VjskDataLoadManager.load(target_dict)
|
||||
|
||||
# 期待値データファイル読み込み
|
||||
assert_list = create_vjsk_assertion_list(target_dict["src_file_path"])
|
||||
# orgテーブル結果を取得
|
||||
result_org = self.db.execute_select(f"select * from {table_name_org}")
|
||||
# 突合から除外する項目
|
||||
ignore_columns = ['dwh_upd_dt']
|
||||
# orgテーブル結果が期待値通りかを突合
|
||||
assert_table_results(result_org, assert_list, ignore_columns)
|
||||
# srcテーブル結果(orgテーブル結果のPK値で一致するもの)を取得
|
||||
result_src = self.db.execute_select(
|
||||
f"select * from {table_name_src} s inner join {table_name_org} o on (s.v_cd_1 = o.v_cd_1 and s.v_cd_2 = o.v_cd_2)")
|
||||
# 突合から除外する項目
|
||||
ignore_columns = ['dwh_upd_dt']
|
||||
# srcテーブル結果が期待値通りかを突合
|
||||
assert_table_results(result_src, assert_list, ignore_columns)
|
||||
|
||||
# srcテーブル結果のレコード件数 (insert 4row + update 2row + insert 2row = 6row)
|
||||
result_src_count = self.db.execute_select(f"select count(*) from {table_name_src} ")
|
||||
assert result_src_count[0]['count(*)'] == 6
|
||||
|
||||
# teardown
|
||||
|
||||
5
ecs/jskult-batch-daily/tests/batch/vjsk/vjsk_load/testdata/mkr_org_horizon_202304280000.tsv
vendored
Normal file
5
ecs/jskult-batch-daily/tests/batch/vjsk/vjsk_load/testdata/mkr_org_horizon_202304280000.tsv
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
"vid_kind_1" "v_cd_1" "nm_1" "dsp_odr_1" "vid_kind_2" "v_cd_2" "nm_2" "dsp_odr_2" "vid_kind_3" "v_cd_3" "nm_3" "dsp_odr_3" "vid_kind_4" "v_cd_4" "nm_4" "dsp_odr_4" "vid_kind_5" "v_cd_5" "nm_5" "dsp_odr_5" "vid_kind_6" "v_cd_6" "nm_6" "dsp_odr_6" "vid_kind_7" "v_cd_7" "nm_7" "dsp_odr_7" "vid_kind_8" "v_cd_8" "nm_8" "dsp_odr_8" "vid_kind_9" "v_cd_9" "nm_9" "dsp_odr_9" "vid_kind_10" "v_cd_10" "nm_10" "dsp_odr_10" "v_whs_cd" "start_dt" "end_dt" "rec_sts_kbn" "ins_dt" "upd_dt"
|
||||
"3" "300003202" "その他営業本部卸" "0" "3" "300003217" "試薬岐阜(回収)" "0" "3" "300003217" "試薬岐阜(回収)" "0" "3" "300003217" "試薬岐阜(回収)" "0" "3" "300003217" "試薬岐阜(回収)" "0" "3" "300003217" "試薬岐阜(回収)" "0" "3" "300003217" "試薬岐阜(回収)" "0" "3" "300003217" "試薬岐阜(回収)" "0" "3" "300003217" "試薬岐阜(回収)" "0" "3" "300003217" "試薬岐阜(回収)" "0" "200000007" "20190401" "99991231" "0" "19-04-11 11:30:59" "23-04-12 17:52:38"
|
||||
"3" "300003138" "北関東甲信越営業本部" "0" "3" "300003195" "首都圏移管組織" "0" "3" "300003195" "首都圏移管組織" "0" "3" "300003195" "首都圏移管組織" "0" "3" "300003195" "首都圏移管組織" "0" "3" "300003195" "首都圏移管組織" "0" "3" "300003195" "首都圏移管組織" "0" "3" "300003195" "首都圏移管組織" "0" "3" "300003195" "首都圏移管組織" "0" "3" "300003195" "首都圏移管組織" "0" "200000007" "20190401" "99991231" "0" "19-04-11 11:30:59" "23-04-12 17:52:38"
|
||||
"3" "300003202" "その他営業本部卸" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "200000007" "20190401" "99991231" "0" "19-04-11 11:30:59" "23-04-12 17:52:38"
|
||||
"a" "300003144" "メディカル営業本部1" "1" "b" "300003202" "東海スタッフ医療2" "2" "c" "300003203" "東海スタッフ医療3" "3" "d" "300003204" "東海スタッフ医療4" "4" "e" "300003205" "東海スタッフ医療5" "5" "f" "300003206" "東海スタッフ医療6" "6" "g" "300003207" "東海スタッフ医療7" "7" "h" "300003208" "東海スタッフ医療8" "8" "i" "300003209" "東海スタッフ医療9" "9" "j" "300003210" "東海スタッフ医療10" "10" "200000007" "20190401" "99991231" "0" "19-04-11 11:30:59" "23-04-12 17:52:38"
|
||||
|
5
ecs/jskult-batch-daily/tests/batch/vjsk/vjsk_load/testdata/mkr_org_horizon_202304290000.tsv
vendored
Normal file
5
ecs/jskult-batch-daily/tests/batch/vjsk/vjsk_load/testdata/mkr_org_horizon_202304290000.tsv
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
"vid_kind_1" "v_cd_1" "nm_1" "dsp_odr_1" "vid_kind_2" "v_cd_2" "nm_2" "dsp_odr_2" "vid_kind_3" "v_cd_3" "nm_3" "dsp_odr_3" "vid_kind_4" "v_cd_4" "nm_4" "dsp_odr_4" "vid_kind_5" "v_cd_5" "nm_5" "dsp_odr_5" "vid_kind_6" "v_cd_6" "nm_6" "dsp_odr_6" "vid_kind_7" "v_cd_7" "nm_7" "dsp_odr_7" "vid_kind_8" "v_cd_8" "nm_8" "dsp_odr_8" "vid_kind_9" "v_cd_9" "nm_9" "dsp_odr_9" "vid_kind_10" "v_cd_10" "nm_10" "dsp_odr_10" "v_whs_cd" "start_dt" "end_dt" "rec_sts_kbn" "ins_dt" "upd_dt"
|
||||
"3" "300003202" "その他営業本部卸" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "3" "300003226" "大垣(回収)" "0" "200000007" "20190401" "99991231" "0" "19-04-11 11:30:59" "23-04-12 17:52:38"
|
||||
"3" "300003144" "メディカル営業本部" "0" "3" "300003201" "東海スタッフ医療" "0" "3" "300003201" "東海スタッフ医療" "0" "3" "300003201" "東海スタッフ医療" "0" "3" "300003201" "東海スタッフ医療" "0" "3" "300003201" "東海スタッフ医療" "0" "3" "300003201" "東海スタッフ医療" "0" "3" "300003201" "東海スタッフ医療" "0" "3" "300003201" "東海スタッフ医療" "0" "3" "300003201" "東海スタッフ医療" "0" "200000007" "20190401" "99991231" "0" "19-04-11 11:30:59" "23-04-12 17:52:38"
|
||||
"3" "300003202" "その他営業本部卸" "0" "3" "300003224" "岐阜第二(回収)" "0" "3" "300003224" "岐阜第二(回収)" "0" "3" "300003224" "岐阜第二(回収)" "0" "3" "300003224" "岐阜第二(回収)" "0" "3" "300003224" "岐阜第二(回収)" "0" "3" "300003224" "岐阜第二(回収)" "0" "3" "300003224" "岐阜第二(回収)" "0" "3" "300003224" "岐阜第二(回収)" "0" "3" "300003224" "岐阜第二(回収)" "0" "200000007" "20190401" "99991231" "0" "19-04-11 11:30:59" "23-04-12 17:52:38"
|
||||
"3" "300003143" "医薬営業統括本部" "0" "3" "300003196" "医薬その他" "0" "3" "300003196" "医薬その他" "0" "3" "300003196" "医薬その他" "0" "3" "300003196" "医薬その他" "0" "3" "300003196" "医薬その他" "0" "3" "300003196" "医薬その他" "0" "3" "300003196" "医薬その他" "0" "3" "300003196" "医薬その他" "0" "3" "300003196" "医薬その他" "0" "200000007" "20190401" "20190930" "0" "19-04-11 11:30:59" "23-04-12 17:52:38"
|
||||
|
@ -71,7 +71,7 @@ def assert_table_results(actual_rows: list[dict], expect_rows: list[dict], ignor
|
||||
ignore_col_name (list): 比較を無視するDBのカラム名. Default None.
|
||||
"""
|
||||
# 取得件数が一致すること
|
||||
assert len(actual_rows) == len(expect_rows)
|
||||
assert len(actual_rows) == len(expect_rows), f'レコード件数が一致しません。DBレコード数 : {len(actual_rows)} 期待値 : {len(expect_rows)}'
|
||||
|
||||
line_number = 0
|
||||
# 1行ずつ調査
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user