feat: 一気通貫テストで処理のログをファイルに書き出すようにした

This commit is contained in:
shimoda.m@nds-tyo.co.jp 2024-03-12 10:15:58 +09:00
parent c47af35775
commit 6dafd8215a
2 changed files with 29 additions and 0 deletions

20
ecs/crm-datafetch/.gitignore vendored Normal file
View File

@ -0,0 +1,20 @@
# Node.jsで実装されたLambdaの管理対象外ファイル群
package-lock.json
node_modules/
# ローカル確認用環境変数ファイル
.env
# Pythonの仮想環境ファイル
.venv
# pythonのキャッシュファイル
__pycache__/
# StepFunctionsステートメント定義変換後のフォルダ
stepfunctions/*/build
**/.vscode/settings.json
# python test
.coverage
.report/
# log
.log

View File

@ -6,6 +6,7 @@ from datetime import datetime, timezone
import boto3
import pytest
from src.controller import controller
from src.parser.json_parser import JsonParser
from src.system_var.constants import YYYYMMDDTHHMMSSTZ
@ -114,6 +115,10 @@ def test_walk_through(s3_test, s3_client, monkeypatch, caplog):
logger.info(f'##########################')
# Assertion
log_messages = caplog.messages
# ログの目視確認を容易にするため、ローカルファイルに書き出す。
with open('crm_datafetch_test_walk_through_diff.log', 'w', encoding='utf8') as f:
f.write('\n'.join(log_messages))
# ループ前のログ確認
assert 'I-CTRL-01 CRMデータ取得処理を開始します' in log_messages
assert 'I-CTRL-02 データ取得準備処理呼び出し' in log_messages
@ -170,6 +175,10 @@ def test_walk_through(s3_test, s3_client, monkeypatch, caplog):
logger.info(f'##########################')
# ログ再取得
log_messages_all = caplog.messages
# ログの目視確認を容易にするため、ローカルファイルに書き出す。
with open('crm_datafetch_test_walk_through_all.log', 'w', encoding='utf8') as f:
f.write('\n'.join(log_messages_all))
object_info_list_all = object_info_files[1]
# 開始ログなどはテスト済みなのでチェックを省く
for object_info in object_info_list_all['objects']: