@@ -95,9 +95,9 @@ def test_handler_with_valid_item(mock_aws_context, mock_pgstac_dsn, database_url
9595 assert result is None
9696
9797 # Verify the item was added to the database
98- assert check_item_exists (
99- database_url , collection_id , item_id
100- ), "Item was not found in the database"
98+ assert check_item_exists (database_url , collection_id , item_id ), (
99+ "Item was not found in the database"
100+ )
101101
102102
103103def test_handler_with_valid_items_multiple_collections (
@@ -135,9 +135,9 @@ def test_handler_with_valid_items_multiple_collections(
135135
136136 # Verify all items were added to their respective collections
137137 for collection_id , item_id , _ in items :
138- assert check_item_exists (
139- database_url , collection_id , item_id
140- ), f"Item { item_id } was not found in collection { collection_id } "
138+ assert check_item_exists (database_url , collection_id , item_id ), (
139+ f"Item { item_id } was not found in collection { collection_id } "
140+ )
141141
142142
143143def test_handler_with_invalid_item (mock_aws_context , mock_pgstac_dsn ):
@@ -191,15 +191,15 @@ def test_handler_with_multiple_items(mock_aws_context, mock_pgstac_dsn, database
191191
192192 # Verify all items were added
193193 for item_id in item_ids :
194- assert check_item_exists (
195- database_url , collection_id , item_id
196- ), f"Item { item_id } was not found in the database"
194+ assert check_item_exists (database_url , collection_id , item_id ), (
195+ f"Item { item_id } was not found in the database"
196+ )
197197
198198 # Verify the count increased by the expected amount
199199 new_count = count_collection_items (database_url , collection_id )
200- assert new_count == initial_count + len (
201- items
202- ), f"Expected { initial_count + len ( items ) } items, but found { new_count } "
200+ assert new_count == initial_count + len (items ), (
201+ f"Expected { initial_count + len ( items ) } items, but found { new_count } "
202+ )
203203
204204
205205def test_handler_with_mixed_items (mock_aws_context , mock_pgstac_dsn , database_url ):
@@ -240,15 +240,15 @@ def test_handler_with_mixed_items(mock_aws_context, mock_pgstac_dsn, database_ur
240240 assert valid_message_id not in failures
241241
242242 # Verify only the valid item was added
243- assert check_item_exists (
244- database_url , collection_id , valid_item_id
245- ), "Valid item was not found in the database"
243+ assert check_item_exists (database_url , collection_id , valid_item_id ), (
244+ "Valid item was not found in the database"
245+ )
246246
247247 # Verify count increased by exactly 1
248248 new_count = count_collection_items (database_url , collection_id )
249- assert (
250- new_count == initial_count + 1
251- ), f"Expected { initial_count + 1 } items, but found { new_count } "
249+ assert new_count == initial_count + 1 , (
250+ f"Expected { initial_count + 1 } items, but found { new_count } "
251+ )
252252
253253
254254def test_handler_with_empty_event (mock_aws_context , mock_pgstac_dsn ):
@@ -406,9 +406,9 @@ def test_handler_upsert_existing_item(mock_aws_context, mock_pgstac_dsn, databas
406406 items = get_all_collection_items (database_url , collection_id )
407407 updated_db_item = next ((item for item in items if item ["id" ] == item_id ), None )
408408 assert updated_db_item is not None
409- assert (
410- updated_db_item [ "content" ][ "properties" ][ "version" ] == "2.0 "
411- ), "Item was not properly updated with new version"
409+ assert updated_db_item [ "content" ][ "properties" ][ "version" ] == "2.0" , (
410+ "Item was not properly updated with new version "
411+ )
412412
413413 # Count should remain the same (1 item was updated, not added)
414414 count = count_collection_items (database_url , collection_id )
@@ -480,9 +480,9 @@ def test_handler_with_s3_event(mock_aws_context, mock_pgstac_dsn, database_url):
480480 )
481481
482482 # Verify the item was added to the database
483- assert check_item_exists (
484- database_url , collection_id , item_id
485- ), "Item from S3 was not found in the database"
483+ assert check_item_exists (database_url , collection_id , item_id ), (
484+ "Item from S3 was not found in the database"
485+ )
486486
487487
488488def test_handler_with_s3_event_invalid_extension (mock_aws_context , mock_pgstac_dsn ):
@@ -632,12 +632,12 @@ def test_handler_with_mixed_s3_and_sqs_events(
632632 assert result is None
633633
634634 # Verify both items were added to the database
635- assert check_item_exists (
636- database_url , collection_id , sqs_item_id
637- ), "SQS item was not found in the database"
638- assert check_item_exists (
639- database_url , collection_id , s3_item_id
640- ), "S3 item was not found in the database"
635+ assert check_item_exists (database_url , collection_id , sqs_item_id ), (
636+ "SQS item was not found in the database"
637+ )
638+ assert check_item_exists (database_url , collection_id , s3_item_id ), (
639+ "S3 item was not found in the database"
640+ )
641641
642642
643643def test_handler_with_s3_event_binary_content (mock_aws_context , mock_pgstac_dsn ):
@@ -690,9 +690,9 @@ def test_handler_with_valid_collection(mock_aws_context, mock_pgstac_dsn, databa
690690 assert result is None
691691
692692 # Verify the collection was added to the database
693- assert check_collection_exists (
694- database_url , collection_id
695- ), "Collection was not found in the database"
693+ assert check_collection_exists (database_url , collection_id ), (
694+ "Collection was not found in the database"
695+ )
696696
697697
698698def test_handler_with_multiple_collections (
@@ -724,15 +724,15 @@ def test_handler_with_multiple_collections(
724724
725725 # Verify all collections were added
726726 for collection_id in collection_ids :
727- assert check_collection_exists (
728- database_url , collection_id
729- ), f"Collection { collection_id } was not found in the database"
727+ assert check_collection_exists (database_url , collection_id ), (
728+ f"Collection { collection_id } was not found in the database"
729+ )
730730
731731 # Verify the count increased by the expected amount
732732 new_count = count_collections (database_url )
733- assert new_count == initial_count + len (
734- collections
735- ), f"Expected { initial_count + len ( collections ) } collections, but found { new_count } "
733+ assert new_count == initial_count + len (collections ), (
734+ f"Expected { initial_count + len ( collections ) } collections, but found { new_count } "
735+ )
736736
737737
738738def test_handler_with_invalid_collection (mock_aws_context , mock_pgstac_dsn ):
@@ -790,14 +790,14 @@ def test_handler_with_mixed_collections_and_items(
790790 assert result is None
791791
792792 # Verify the collection was added
793- assert check_collection_exists (
794- database_url , collection_id
795- ), "Collection was not found in the database"
793+ assert check_collection_exists (database_url , collection_id ), (
794+ "Collection was not found in the database"
795+ )
796796
797797 # Verify the item was added
798- assert check_item_exists (
799- database_url , existing_collection_id , item_id
800- ), "Item was not found in the database"
798+ assert check_item_exists (database_url , existing_collection_id , item_id ), (
799+ "Item was not found in the database"
800+ )
801801
802802 # Verify counts increased correctly
803803 new_collection_count = count_collections (database_url )
@@ -846,9 +846,9 @@ def test_handler_with_collection_from_s3(mock_aws_context, mock_pgstac_dsn, data
846846 )
847847
848848 # Verify the collection was added to the database
849- assert check_collection_exists (
850- database_url , collection_id
851- ), "Collection from S3 was not found in the database"
849+ assert check_collection_exists (database_url , collection_id ), (
850+ "Collection from S3 was not found in the database"
851+ )
852852
853853
854854def test_handler_upsert_existing_collection (
@@ -895,9 +895,9 @@ def test_handler_upsert_existing_collection(
895895 # Verify the collection was updated
896896 updated_db_collection = get_collection (database_url , collection_id )
897897 assert updated_db_collection is not None
898- assert (
899- updated_db_collection [ "content" ][ "title" ] == "Updated Title "
900- ), "Collection was not properly updated with new title"
898+ assert updated_db_collection [ "content" ][ "title" ] == "Updated Title" , (
899+ "Collection was not properly updated with new title "
900+ )
901901
902902 # Count should remain the same (1 collection was updated, not added)
903903 # We can't easily check this without knowing the exact initial count
@@ -1007,15 +1007,15 @@ def test_handler_with_mixed_valid_invalid_collections(
10071007 assert valid_message_id not in failures
10081008
10091009 # Verify only the valid collection was added
1010- assert check_collection_exists (
1011- database_url , valid_collection_id
1012- ), "Valid collection was not found in the database"
1010+ assert check_collection_exists (database_url , valid_collection_id ), (
1011+ "Valid collection was not found in the database"
1012+ )
10131013
10141014 # Verify count increased by exactly 1
10151015 new_count = count_collections (database_url )
1016- assert (
1017- new_count == initial_count + 1
1018- ), f"Expected { initial_count + 1 } collections, but found { new_count } "
1016+ assert new_count == initial_count + 1 , (
1017+ f"Expected { initial_count + 1 } collections, but found { new_count } "
1018+ )
10191019
10201020
10211021def test_handler_with_malformed_sns_message (mock_aws_context , mock_pgstac_dsn ):
@@ -1181,9 +1181,9 @@ def test_handler_creates_missing_collection(
11811181 )
11821182 assert result == 1 , "Collection should have been created"
11831183
1184- assert check_item_exists (
1185- database_url , missing_collection_id , item_id
1186- ), "Item was not found in the database"
1184+ assert check_item_exists (database_url , missing_collection_id , item_id ), (
1185+ "Item was not found in the database"
1186+ )
11871187
11881188
11891189def test_handler_does_not_create_collection_without_env_var (
@@ -1222,9 +1222,9 @@ def test_handler_does_not_create_collection_without_env_var(
12221222 )
12231223 assert result == 0 , "Collection should not have been created"
12241224
1225- assert not check_item_exists (
1226- database_url , missing_collection_id , item_id
1227- ), "Item should not have been added to the database"
1225+ assert not check_item_exists (database_url , missing_collection_id , item_id ), (
1226+ "Item should not have been added to the database"
1227+ )
12281228
12291229
12301230@patch .dict (os .environ , {"CREATE_COLLECTIONS_IF_MISSING" : "true" })
@@ -1254,13 +1254,13 @@ def test_handler_does_not_recreate_existing_collection(
12541254 current_collection = db .query_one (
12551255 f"SELECT * from collections where id = '{ existing_collection_id } '"
12561256 )
1257- assert (
1258- current_collection == original_collection
1259- ), "Existing collection should not have been modified"
1257+ assert current_collection == original_collection , (
1258+ "Existing collection should not have been modified"
1259+ )
12601260
1261- assert check_item_exists (
1262- database_url , existing_collection_id , item_id
1263- ), "Item was not found in the database"
1261+ assert check_item_exists (database_url , existing_collection_id , item_id ), (
1262+ "Item was not found in the database"
1263+ )
12641264
12651265
12661266@patch .dict (os .environ , {"CREATE_COLLECTIONS_IF_MISSING" : "true" })
@@ -1300,9 +1300,9 @@ def test_handler_creates_collection_with_multiple_items(
13001300 assert result == 1 , "Collection should have been created exactly once"
13011301
13021302 for item_id in item_ids :
1303- assert check_item_exists (
1304- database_url , missing_collection_id , item_id
1305- ), f"Item { item_id } was not found in the database"
1303+ assert check_item_exists (database_url , missing_collection_id , item_id ), (
1304+ f"Item { item_id } was not found in the database"
1305+ )
13061306
13071307
13081308@patch .dict (os .environ , {"CREATE_COLLECTIONS_IF_MISSING" : "true" })
@@ -1342,6 +1342,6 @@ def test_handler_collection_creation_failure(
13421342 )
13431343 assert result == 0 , "Collection should not have been created due to failure"
13441344
1345- assert not check_item_exists (
1346- database_url , missing_collection_id , item_id
1347- ), "Item should not have been added to the database"
1345+ assert not check_item_exists (database_url , missing_collection_id , item_id ), (
1346+ "Item should not have been added to the database"
1347+ )
0 commit comments