Skip to content

Commit

Permalink
Fix flake8 compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
nasudadada committed Oct 28, 2024
1 parent 28e23b7 commit 9f4338e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 4 additions & 2 deletions cliboa/scenario/load/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
14 changes: 8 additions & 6 deletions cliboa/test/scenario/load/test_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 9f4338e

Please sign in to comment.