@@ -435,7 +435,8 @@ async def test_update_transaction_expense_data_with_specific_category_and_label(
435
435
transactions_response = await extend .transactions .get_transactions (per_page = 1 )
436
436
assert "report" in transactions_response , "Response should include 'report'"
437
437
assert "transactions" in transactions_response ["report" ], "Response should include 'transactions'"
438
- assert transactions_response ["report" ]["transactions" ], "No transactions available for testing expense data update"
438
+ assert transactions_response ["report" ][
439
+ "transactions" ], "No transactions available for testing expense data update"
439
440
transaction = transactions_response ["report" ]["transactions" ][0 ]
440
441
transaction_id = transaction ["id" ]
441
442
@@ -494,6 +495,46 @@ async def test_create_receipt_attachment(self, extend):
494
495
assert response ["contentType" ] == "image/png" , "Content type should be 'image/png'"
495
496
496
497
498
+ @pytest .mark .integration
499
+ class TestReceiptCaptureEndpoints :
500
+ """Integration tests for the new receipt capture endpoints"""
501
+
502
+ @pytest .mark .asyncio
503
+ async def test_automatch_receipts_and_get_status (self , extend ):
504
+ """
505
+ Integration test that:
506
+ 1. Creates a dummy receipt attachment for an existing transaction.
507
+ 2. Initiates an automatch job using the new endpoint.
508
+ 3. Retrieves and verifies the automatch job status.
509
+ """
510
+ # Create a dummy PNG file in memory (a minimal PNG header plus extra bytes)
511
+ png_header = b'\x89 PNG\r \n \x1a \n '
512
+ dummy_content = png_header + b'\x00 ' * 100
513
+ file_obj = BytesIO (dummy_content )
514
+ file_obj .name = f"test_receipt_{ uuid .uuid4 ()} .png"
515
+
516
+ # Create a receipt attachment using the receipt_attachments endpoint
517
+ attachment_response = await extend .receipt_attachments .create_receipt_attachment (
518
+ file = file_obj
519
+ )
520
+ assert "id" in attachment_response , "Receipt attachment should have an id"
521
+ receipt_attachment_id = attachment_response ["id" ]
522
+
523
+ # Initiate an automatch job using the new receipt capture endpoint
524
+ automatch_response = await extend .receipt_capture .automatch_receipts (
525
+ receipt_attachment_ids = [receipt_attachment_id ]
526
+ )
527
+ assert "id" in automatch_response , "Automatch response should include a job id"
528
+ assert "tasks" in automatch_response , "Automatch response should include tasks"
529
+ job_id = automatch_response ["id" ]
530
+
531
+ # Retrieve the automatch job status using the new endpoint
532
+ status_response = await extend .receipt_capture .get_automatch_status (job_id )
533
+ assert "id" in status_response , "Status response should include a job id"
534
+ assert status_response ["id" ] == job_id , "Job id should match the one returned during automatch"
535
+ assert "tasks" in status_response , "Status response should include tasks"
536
+
537
+
497
538
def test_environment_variables ():
498
539
"""Test that required environment variables are set"""
499
540
assert os .getenv ("EXTEND_API_KEY" ), "EXTEND_API_KEY environment variable is required"
0 commit comments