feat: 例外のケースを追加
This commit is contained in:
parent
24c369b69e
commit
8fab1d87e1
@ -3,7 +3,8 @@ import datetime
|
||||
import pytest
|
||||
|
||||
from src.db.database import Database
|
||||
from src.error.exceptions import MaxRunCountReachedException
|
||||
from src.error.exceptions import (BatchOperationException,
|
||||
MaxRunCountReachedException)
|
||||
from src.manager.jskult_batch_status_manager import JskultBatchStatusManager
|
||||
|
||||
|
||||
@ -150,6 +151,34 @@ class TestJskultBatchStatusManager:
|
||||
assert actual['process_type'] == 'unittest_process_type'
|
||||
assert actual['process_status'] == 'doing'
|
||||
|
||||
def test_set_process_status_raise_exception(self):
|
||||
"""
|
||||
ステータス管理テーブルのレコードが0件のとき、INSERTされること
|
||||
"""
|
||||
# Arrange
|
||||
# 日付テーブルを登録
|
||||
db = Database.get_instance()
|
||||
db.connect()
|
||||
db.execute("""
|
||||
INSERT INTO src07.hdke_tbl
|
||||
(syor_date, bch_actf, dump_sts_kbn,
|
||||
creater, create_date, updater, update_date)
|
||||
VALUES
|
||||
('20250530', '1', '2', CURRENT_USER(), CURRENT_TIMESTAMP(), NULL, NULL)
|
||||
""")
|
||||
|
||||
# Act
|
||||
# 処理名と管理区分をNoneで初期化
|
||||
sut = JskultBatchStatusManager(
|
||||
None,
|
||||
None,
|
||||
3,
|
||||
33
|
||||
)
|
||||
# SQL実行時にNOT NULL制約に引っかかる
|
||||
with pytest.raises(BatchOperationException):
|
||||
sut.set_process_status(None)
|
||||
|
||||
def test_can_run_post_process_success(self):
|
||||
"""
|
||||
完了しているデータ取り込み件数と受信ファイル数が一致している場合、trueが返却されること
|
||||
@ -262,6 +291,33 @@ class TestJskultBatchStatusManager:
|
||||
|
||||
assert actual_record['total_run_count'] == 1
|
||||
|
||||
def test_can_run_post_process_raise_operation_exception(self):
|
||||
"""
|
||||
自分自身のレコードが存在しない場合、例外が送出されること
|
||||
"""
|
||||
# Arrange
|
||||
# 日付テーブルを登録
|
||||
db = Database.get_instance()
|
||||
db.connect()
|
||||
db.execute("""
|
||||
INSERT INTO src07.hdke_tbl
|
||||
(syor_date, bch_actf, dump_sts_kbn,
|
||||
creater, create_date, updater, update_date)
|
||||
VALUES
|
||||
('20250530', '1', '2', CURRENT_USER(), CURRENT_TIMESTAMP(), NULL, NULL)
|
||||
""")
|
||||
|
||||
# バッチステータス管理テーブルを登録しない
|
||||
# Act
|
||||
sut = JskultBatchStatusManager(
|
||||
'unittest_process_name',
|
||||
'unittest_process_type',
|
||||
3,
|
||||
4
|
||||
)
|
||||
with pytest.raises(BatchOperationException):
|
||||
sut.can_run_post_process()
|
||||
|
||||
def test_can_run_post_process_raise_max_run_count_reached_exception(self):
|
||||
"""
|
||||
完了しているデータ取り込み件数と受信ファイル数が一致していないかつ、最大起動回数に到達している場合、例外が送出されること
|
||||
@ -542,6 +598,33 @@ class TestJskultBatchStatusManager:
|
||||
|
||||
assert actual_record['total_run_count'] == 1
|
||||
|
||||
def test_can_run_business_day_update_raise_operation_exception(self):
|
||||
"""
|
||||
自分自身のレコードが存在しない場合、例外が送出されること
|
||||
"""
|
||||
# Arrange
|
||||
# 日付テーブルを登録
|
||||
db = Database.get_instance()
|
||||
db.connect()
|
||||
db.execute("""
|
||||
INSERT INTO src07.hdke_tbl
|
||||
(syor_date, bch_actf, dump_sts_kbn,
|
||||
creater, create_date, updater, update_date)
|
||||
VALUES
|
||||
('20250530', '1', '2', CURRENT_USER(), CURRENT_TIMESTAMP(), NULL, NULL)
|
||||
""")
|
||||
|
||||
# バッチステータス管理テーブルを登録しない
|
||||
# Act
|
||||
sut = JskultBatchStatusManager(
|
||||
'unittest_process_name',
|
||||
'unittest_process_type',
|
||||
3,
|
||||
4
|
||||
)
|
||||
with pytest.raises(BatchOperationException):
|
||||
sut.can_run_business_day_update()
|
||||
|
||||
def test_can_run_business_day_update_raise_max_run_count_reached_exception(self):
|
||||
"""
|
||||
後続処理3件のいずれかが終了していないかつ、最大起動回数に到達している場合、例外が送出されること
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user