@@ -95,9 +95,9 @@ def test_handler_with_valid_item(mock_aws_context, mock_pgstac_dsn, database_url
95
95
assert result is None
96
96
97
97
# 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
+ )
101
101
102
102
103
103
def test_handler_with_valid_items_multiple_collections (
@@ -135,9 +135,9 @@ def test_handler_with_valid_items_multiple_collections(
135
135
136
136
# Verify all items were added to their respective collections
137
137
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
+ )
141
141
142
142
143
143
def 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
191
191
192
192
# Verify all items were added
193
193
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
+ )
197
197
198
198
# Verify the count increased by the expected amount
199
199
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
+ )
203
203
204
204
205
205
def 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
240
240
assert valid_message_id not in failures
241
241
242
242
# 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
+ )
246
246
247
247
# Verify count increased by exactly 1
248
248
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
+ )
252
252
253
253
254
254
def 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
406
406
items = get_all_collection_items (database_url , collection_id )
407
407
updated_db_item = next ((item for item in items if item ["id" ] == item_id ), None )
408
408
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
+ )
412
412
413
413
# Count should remain the same (1 item was updated, not added)
414
414
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):
480
480
)
481
481
482
482
# 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
+ )
486
486
487
487
488
488
def 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(
632
632
assert result is None
633
633
634
634
# 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
+ )
641
641
642
642
643
643
def 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
690
690
assert result is None
691
691
692
692
# 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
+ )
696
696
697
697
698
698
def test_handler_with_multiple_collections (
@@ -724,15 +724,15 @@ def test_handler_with_multiple_collections(
724
724
725
725
# Verify all collections were added
726
726
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
+ )
730
730
731
731
# Verify the count increased by the expected amount
732
732
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
+ )
736
736
737
737
738
738
def test_handler_with_invalid_collection (mock_aws_context , mock_pgstac_dsn ):
@@ -790,14 +790,14 @@ def test_handler_with_mixed_collections_and_items(
790
790
assert result is None
791
791
792
792
# 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
+ )
796
796
797
797
# 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
+ )
801
801
802
802
# Verify counts increased correctly
803
803
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
846
846
)
847
847
848
848
# 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
+ )
852
852
853
853
854
854
def test_handler_upsert_existing_collection (
@@ -895,9 +895,9 @@ def test_handler_upsert_existing_collection(
895
895
# Verify the collection was updated
896
896
updated_db_collection = get_collection (database_url , collection_id )
897
897
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
+ )
901
901
902
902
# Count should remain the same (1 collection was updated, not added)
903
903
# We can't easily check this without knowing the exact initial count
@@ -1007,15 +1007,15 @@ def test_handler_with_mixed_valid_invalid_collections(
1007
1007
assert valid_message_id not in failures
1008
1008
1009
1009
# 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
+ )
1013
1013
1014
1014
# Verify count increased by exactly 1
1015
1015
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
+ )
1019
1019
1020
1020
1021
1021
def test_handler_with_malformed_sns_message (mock_aws_context , mock_pgstac_dsn ):
@@ -1181,9 +1181,9 @@ def test_handler_creates_missing_collection(
1181
1181
)
1182
1182
assert result == 1 , "Collection should have been created"
1183
1183
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
+ )
1187
1187
1188
1188
1189
1189
def test_handler_does_not_create_collection_without_env_var (
@@ -1222,9 +1222,9 @@ def test_handler_does_not_create_collection_without_env_var(
1222
1222
)
1223
1223
assert result == 0 , "Collection should not have been created"
1224
1224
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
+ )
1228
1228
1229
1229
1230
1230
@patch .dict (os .environ , {"CREATE_COLLECTIONS_IF_MISSING" : "true" })
@@ -1254,13 +1254,13 @@ def test_handler_does_not_recreate_existing_collection(
1254
1254
current_collection = db .query_one (
1255
1255
f"SELECT * from collections where id = '{ existing_collection_id } '"
1256
1256
)
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
+ )
1260
1260
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
+ )
1264
1264
1265
1265
1266
1266
@patch .dict (os .environ , {"CREATE_COLLECTIONS_IF_MISSING" : "true" })
@@ -1300,9 +1300,9 @@ def test_handler_creates_collection_with_multiple_items(
1300
1300
assert result == 1 , "Collection should have been created exactly once"
1301
1301
1302
1302
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
+ )
1306
1306
1307
1307
1308
1308
@patch .dict (os .environ , {"CREATE_COLLECTIONS_IF_MISSING" : "true" })
@@ -1342,6 +1342,6 @@ def test_handler_collection_creation_failure(
1342
1342
)
1343
1343
assert result == 0 , "Collection should not have been created due to failure"
1344
1344
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