diff --git a/ecs/jskult-batch-daily/src/batch/ultmarc/utmp_tables/table_mapper/concrete/com_forfront_med_equip_mapper.py b/ecs/jskult-batch-daily/src/batch/ultmarc/utmp_tables/table_mapper/concrete/com_forfront_med_equip_mapper.py index d8ed1786..00ebc987 100644 --- a/ecs/jskult-batch-daily/src/batch/ultmarc/utmp_tables/table_mapper/concrete/com_forfront_med_equip_mapper.py +++ b/ecs/jskult-batch-daily/src/batch/ultmarc/utmp_tables/table_mapper/concrete/com_forfront_med_equip_mapper.py @@ -1,8 +1,9 @@ from src.batch.ultmarc.utmp_tables.table_mapper.ultmarc_table_mapper import \ -UltmarcTableMapper + UltmarcTableMapper from src.batch.ultmarc.utmp_tables.tables.com_forfront_med_equip import ComForfrontMedEquip + class ComForfrontMedEquipMapper(UltmarcTableMapper): """レイアウト区分022: COM_先進医療機器 登録処理 """ @@ -92,5 +93,5 @@ class ComForfrontMedEquipMapper(UltmarcTableMapper): self.queries.append(self.UPDATE_QUERY) return else: - return None - + self.queries.append(None) + return diff --git a/ecs/jskult-batch-daily/src/batch/ultmarc/utmp_tables/ultmarc_table_mapper_factory.py b/ecs/jskult-batch-daily/src/batch/ultmarc/utmp_tables/ultmarc_table_mapper_factory.py index faf872ad..54507832 100644 --- a/ecs/jskult-batch-daily/src/batch/ultmarc/utmp_tables/ultmarc_table_mapper_factory.py +++ b/ecs/jskult-batch-daily/src/batch/ultmarc/utmp_tables/ultmarc_table_mapper_factory.py @@ -1,6 +1,6 @@ from src.batch.ultmarc.utmp_tables.table_mapper.concrete import ( com_alma_mapper, com_dr_wrkplace_mapper, com_hamtec_mapper, - com_inst_mapper, com_pharm_mapper, com_forfront_med_equip_mapper, null_mapper) + com_inst_mapper, com_forfront_med_equip_mapper, null_mapper) from src.batch.ultmarc.utmp_tables.table_mapper.ultmarc_table_mapper import \ UltmarcTableMapper from src.db.database import Database diff --git a/ecs/jskult-batch-daily/tests/batch/ultmarc/utmp_tables/table_mapper/com_forfront_med_equip/test_com_forfront_med_equip_mapper.py b/ecs/jskult-batch-daily/tests/batch/ultmarc/utmp_tables/table_mapper/com_forfront_med_equip/test_com_forfront_med_equip_mapper.py index b5d4cc09..fccc56ad 100644 --- a/ecs/jskult-batch-daily/tests/batch/ultmarc/utmp_tables/table_mapper/com_forfront_med_equip/test_com_forfront_med_equip_mapper.py +++ b/ecs/jskult-batch-daily/tests/batch/ultmarc/utmp_tables/table_mapper/com_forfront_med_equip/test_com_forfront_med_equip_mapper.py @@ -3,7 +3,7 @@ from datetime import datetime import pytest -from src.batch.common.batch_config import BatchConfig +from src.batch.common.batch_context import BatchContext from src.batch.ultmarc.utmp_tables.table_mapper.concrete import com_forfront_med_equip_mapper from src.db.database import Database from tests.testing_utility import (assert_table_results, @@ -18,13 +18,13 @@ class TestComForfrontMedEquipMapper: """ レイアウト区分022: COM_先端医療機器 """ db: Database - batch_config: BatchConfig + batch_context: BatchContext test_file_path: str = path.dirname(__file__) @pytest.fixture(autouse=True, scope='function') def pre_test(self, database: Database): """ テスト実行前後処理 """ - self.batch_config = BatchConfig.get_instance() + self.batch_context = BatchContext.get_instance() # setup self.db = database self.db.connect() @@ -50,7 +50,7 @@ class TestComForfrontMedEquipMapper: # Arrange # 処理日設定 - self.batch_config.syor_date = datetime.strftime(datetime.now(), '%Y/%m/%d') + 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_forfront_med_equip_insert.csv')) # 一旦全データをDBから削除 @@ -95,7 +95,7 @@ class TestComForfrontMedEquipMapper: # Arrange # 処理日設定 - self.batch_config.syor_date = datetime.strftime(datetime.now(), '%Y/%m/%d') + 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_forfront_med_equip_update.csv')) # 一旦全データをDBから削除 @@ -152,7 +152,7 @@ class TestComForfrontMedEquipMapper: # Arrange # 処理日設定 - self.batch_config.syor_date = datetime.strftime(datetime.now(), '%Y/%m/%d') + 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_forfront_med_equip_delete.csv')) # 一旦全データをDBから削除 diff --git a/ecs/jskult-batch-daily/tests/testing_utility.py b/ecs/jskult-batch-daily/tests/testing_utility.py index e95da8e7..5a6c3a42 100644 --- a/ecs/jskult-batch-daily/tests/testing_utility.py +++ b/ecs/jskult-batch-daily/tests/testing_utility.py @@ -1,5 +1,5 @@ -"""テスト用共通処理関数""" import csv +import os import tempfile from datetime import datetime @@ -22,12 +22,13 @@ def create_ultmarc_test_data_from_csv(file_path: str) -> DatFile: """ # 一度、Shift-JISファイルで書き出す - with open(file_path, encoding='utf8') as csv_file, tempfile.NamedTemporaryFile('w', encoding='cp932') as tmp_file: + with open(file_path, encoding='utf8') as csv_file, tempfile.NamedTemporaryFile('w', encoding='cp932', delete=False) as tmp_file: tmp_file.write(csv_file.read()) tmp_file.seek(0) tmpfile_path = tmp_file.name - dat_file = DatFile.from_path(tmpfile_path) + dat_file = DatFile.from_path(tmpfile_path) + os.unlink(tmpfile_path) return dat_file