自動テスト実装 卸ホールディングスマスタ

This commit is contained in:
x.azuma.m@nds-tyo.co.jp 2023-06-02 23:57:08 +09:00
parent 4b21279d5f
commit fa0ff77851
3 changed files with 73 additions and 0 deletions

View File

@ -434,3 +434,66 @@ class TestImportFileToDb:
assert result_src_count[0]['count(*)'] == 6 assert result_src_count[0]['count(*)'] == 6
# teardown # teardown
def test_load_06_hld_mst_ok(self, mapper):
table_name_org = mapper.get_org_table(mapper.CONDKEY_HLD_MST)
table_name_src = mapper.get_src_table(mapper.CONDKEY_HLD_MST)
# 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_HLD_MST,
"src_file_path": path.join(self.test_file_path_load_individual, "hld_mst_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_HLD_MST,
"src_file_path": path.join(self.test_file_path_load_individual, "hld_mst_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_hld_cd = o.v_hld_cd and s.sub_num = o.sub_num)")
# 突合から除外する項目
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

View File

@ -0,0 +1,5 @@
"v_hld_cd" "sub_no" "nm" "kn_nm" "sht_nm" "start_dt" "end_dt" "dsp_odr" "rec_sts_kbn" "ins_dt" "upd_dt"
"10001" "1" "卸ホールディングス名01-1" "オロシホールディングスメイ01-1" "卸名01-1" "20230101" "99991231" "1" "0" "23-05-09 12:00:01" "23-05-09 13:00:01"
"10001" "2" "卸ホールディングス名01-2" "オロシホールディングスメイ01-2" "卸名01-2" "20230102" "99991231" "1" "0" "23-05-09 12:00:02" "23-05-09 13:00:02"
"10001" "3" "卸ホールディングス名01-3" "オロシホールディングスメイ01-3" "卸名01-3" "20230103" "99991231" "1" "0" "23-05-09 12:00:03" "23-05-09 13:00:03"
"10001" "4" "卸ホールディングス名01-4" "オロシホールディングスメイ01-4" "卸名01-4" "20230104" "99991231" "1" "0" "23-05-09 12:00:04" "23-05-09 13:00:04"
1 v_hld_cd sub_no nm kn_nm sht_nm start_dt end_dt dsp_odr rec_sts_kbn ins_dt upd_dt
2 10001 1 卸ホールディングス名01-1 オロシホールディングスメイ01-1 卸名01-1 20230101 99991231 1 0 23-05-09 12:00:01 23-05-09 13:00:01
3 10001 2 卸ホールディングス名01-2 オロシホールディングスメイ01-2 卸名01-2 20230102 99991231 1 0 23-05-09 12:00:02 23-05-09 13:00:02
4 10001 3 卸ホールディングス名01-3 オロシホールディングスメイ01-3 卸名01-3 20230103 99991231 1 0 23-05-09 12:00:03 23-05-09 13:00:03
5 10001 4 卸ホールディングス名01-4 オロシホールディングスメイ01-4 卸名01-4 20230104 99991231 1 0 23-05-09 12:00:04 23-05-09 13:00:04

View File

@ -0,0 +1,5 @@
"v_hld_cd" "sub_no" "nm" "kn_nm" "sht_nm" "start_dt" "end_dt" "dsp_odr" "rec_sts_kbn" "ins_dt" "upd_dt"
"10001" "3" "卸ホールディングス名01-3" "オロシホールディングスメイ01-3" "卸名01-3" "20230101" "99991231" "1" "0" "23-05-09 12:00:03" "23-05-09 13:00:03"
"10001" "4" "卸ホールディングス名01-4" "オロシホールディングスメイ01-4" "卸名01-4" "20230102" "99991231" "1" "0" "23-05-09 12:00:04" "23-05-09 13:00:04"
"10001" "5" "卸ホールディングス名01-5" "オロシホールディングスメイ01-5" "卸名01-5" "20230103" "99991231" "1" "0" "23-05-09 12:00:05" "23-05-09 13:00:05"
"10002" "1" "卸ホールディングス名02-1" "オロシホールディングスメイ02-1" "卸名01-1" "20230104" "99991231" "1" "0" "23-05-09 12:00:06" "23-05-09 13:00:06"
1 v_hld_cd sub_no nm kn_nm sht_nm start_dt end_dt dsp_odr rec_sts_kbn ins_dt upd_dt
2 10001 3 卸ホールディングス名01-3 オロシホールディングスメイ01-3 卸名01-3 20230101 99991231 1 0 23-05-09 12:00:03 23-05-09 13:00:03
3 10001 4 卸ホールディングス名01-4 オロシホールディングスメイ01-4 卸名01-4 20230102 99991231 1 0 23-05-09 12:00:04 23-05-09 13:00:04
4 10001 5 卸ホールディングス名01-5 オロシホールディングスメイ01-5 卸名01-5 20230103 99991231 1 0 23-05-09 12:00:05 23-05-09 13:00:05
5 10002 1 卸ホールディングス名02-1 オロシホールディングスメイ02-1 卸名01-1 20230104 99991231 1 0 23-05-09 12:00:06 23-05-09 13:00:06