From 9f4338eecff2cdb0d464887ce8ceb3f3329ae6cf Mon Sep 17 00:00:00 2001 From: "yuichi.nasukawa" Date: Mon, 28 Oct 2024 13:03:56 +0900 Subject: [PATCH] Fix flake8 compliance --- cliboa/scenario/load/aws.py | 6 ++++-- cliboa/test/scenario/load/test_aws.py | 14 ++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cliboa/scenario/load/aws.py b/cliboa/scenario/load/aws.py index 2a819544..09772578 100644 --- a/cliboa/scenario/load/aws.py +++ b/cliboa/scenario/load/aws.py @@ -186,10 +186,12 @@ def _write_jsonl_to_dynamodb(self, file, table, partition_key, sort_key): if partition_key not in item: raise InvalidParameter( - f"Partition key '{partition_key}' not found in JSONL file: {file} at line {line_number}" + f"Partition key '{partition_key}' not found in JSONL file: " + f"{file} at line {line_number}" ) if sort_key and sort_key not in item: raise InvalidParameter( - f"Sort key '{sort_key}' not found in JSONL file: {file} at line {line_number}" + f"Sort key '{sort_key}' not found in JSONL file: " + f"{file} at line {line_number}" ) batch.put_item(Item=item) diff --git a/cliboa/test/scenario/load/test_aws.py b/cliboa/test/scenario/load/test_aws.py index 38d7cbd4..42b9b465 100644 --- a/cliboa/test/scenario/load/test_aws.py +++ b/cliboa/test/scenario/load/test_aws.py @@ -12,10 +12,6 @@ # all copies or substantial portions of the Software. # - -import csv -import json -import os import tempfile from unittest.mock import MagicMock, patch @@ -98,7 +94,10 @@ def test_jsonl_success(self, mock_get_target_files, mock_boto3_resource): mock_boto3_resource.return_value.Table.return_value = mock_table mock_table.key_schema = [{"AttributeName": "id", "KeyType": "HASH"}] - jsonl_content = '{"id": "1", "name": "test1"}\n{"id": "2", "name": "test2"}' + jsonl_content = ( + '{"id": "1", "name": "test1", "timestamp": "2023-01-01"}\n' + '{"id": "2", "name": "test2", "timestamp": "2023-01-02"}' + ) with tempfile.NamedTemporaryFile(mode="w", delete=True) as temp_file: temp_file.write(jsonl_content) temp_file.flush() @@ -187,7 +186,10 @@ def test_execute_jsonl_with_sort_key(self, mock_get_target_files, mock_boto3_res {"AttributeName": "timestamp", "KeyType": "RANGE"}, ] - jsonl_content = '{"id": "1", "name": "test1", "timestamp": "2023-01-01"}\n{"id": "2", "name": "test2", "timestamp": "2023-01-02"}' + jsonl_content = ( + '{"id": "1", "name": "test1", "timestamp": "2023-01-01"}\n' + '{"id": "2", "name": "test2", "timestamp": "2023-01-02"}' + ) with tempfile.NamedTemporaryFile(mode="w", delete=True) as temp_file: temp_file.write(jsonl_content) temp_file.flush()