|
7 | 7 |
|
8 | 8 | from appstoreserverlibrary.api_client import APIError, APIException, AsyncAppStoreServerAPIClient, GetTransactionHistoryVersion |
9 | 9 | from appstoreserverlibrary.models.AccountTenure import AccountTenure |
| 10 | +from appstoreserverlibrary.models.AppTransactionInfoResponse import AppTransactionInfoResponse |
10 | 11 | from appstoreserverlibrary.models.AutoRenewStatus import AutoRenewStatus |
11 | 12 | from appstoreserverlibrary.models.ConsumptionRequest import ConsumptionRequest |
12 | 13 | from appstoreserverlibrary.models.ConsumptionStatus import ConsumptionStatus |
@@ -657,6 +658,72 @@ async def test_delete_default_message(self): |
657 | 658 | {}, |
658 | 659 | None) |
659 | 660 | await client.delete_default_message('com.example.product', 'en-US') |
| 661 | + |
| 662 | + async def test_get_app_transaction_info_success(self): |
| 663 | + client = self.get_client_with_body_from_file('tests/resources/models/appTransactionInfoResponse.json', |
| 664 | + 'GET', |
| 665 | + 'https://local-testing-base-url/inApps/v1/transactions/appTransactions/1234', |
| 666 | + {}, |
| 667 | + None) |
| 668 | + |
| 669 | + app_transaction_info_response = await client.get_app_transaction_info('1234') |
| 670 | + |
| 671 | + self.assertIsNotNone(app_transaction_info_response) |
| 672 | + self.assertEqual('signed_app_transaction_info_value', app_transaction_info_response.signedAppTransactionInfo) |
| 673 | + |
| 674 | + async def test_get_app_transaction_info_invalid_transaction_id(self): |
| 675 | + client = self.get_client_with_body_from_file('tests/resources/models/invalidTransactionIdError.json', |
| 676 | + 'GET', |
| 677 | + 'https://local-testing-base-url/inApps/v1/transactions/appTransactions/invalid_id', |
| 678 | + {}, |
| 679 | + None, |
| 680 | + 400) |
| 681 | + try: |
| 682 | + await client.get_app_transaction_info('invalid_id') |
| 683 | + except APIException as e: |
| 684 | + self.assertEqual(400, e.http_status_code) |
| 685 | + self.assertEqual(4000006, e.raw_api_error) |
| 686 | + self.assertEqual(APIError.INVALID_TRANSACTION_ID, e.api_error) |
| 687 | + self.assertEqual("Invalid transaction id.", e.error_message) |
| 688 | + return |
| 689 | + |
| 690 | + self.assertFalse(True) |
| 691 | + |
| 692 | + async def test_get_app_transaction_info_app_transaction_does_not_exist(self): |
| 693 | + client = self.get_client_with_body_from_file('tests/resources/models/appTransactionDoesNotExistError.json', |
| 694 | + 'GET', |
| 695 | + 'https://local-testing-base-url/inApps/v1/transactions/appTransactions/nonexistent_id', |
| 696 | + {}, |
| 697 | + None, |
| 698 | + 404) |
| 699 | + try: |
| 700 | + await client.get_app_transaction_info('nonexistent_id') |
| 701 | + except APIException as e: |
| 702 | + self.assertEqual(404, e.http_status_code) |
| 703 | + self.assertEqual(4040019, e.raw_api_error) |
| 704 | + self.assertEqual(APIError.APP_TRANSACTION_DOES_NOT_EXIST_ERROR, e.api_error) |
| 705 | + self.assertEqual("No AppTransaction exists for the customer.", e.error_message) |
| 706 | + return |
| 707 | + |
| 708 | + self.assertFalse(True) |
| 709 | + |
| 710 | + async def test_get_app_transaction_info_transaction_id_not_found(self): |
| 711 | + client = self.get_client_with_body_from_file('tests/resources/models/transactionIdNotFoundError.json', |
| 712 | + 'GET', |
| 713 | + 'https://local-testing-base-url/inApps/v1/transactions/appTransactions/not_found_id', |
| 714 | + {}, |
| 715 | + None, |
| 716 | + 404) |
| 717 | + try: |
| 718 | + await client.get_app_transaction_info('not_found_id') |
| 719 | + except APIException as e: |
| 720 | + self.assertEqual(404, e.http_status_code) |
| 721 | + self.assertEqual(4040010, e.raw_api_error) |
| 722 | + self.assertEqual(APIError.TRANSACTION_ID_NOT_FOUND, e.api_error) |
| 723 | + self.assertEqual("Transaction id not found.", e.error_message) |
| 724 | + return |
| 725 | + |
| 726 | + self.assertFalse(True) |
660 | 727 |
|
661 | 728 | def get_signing_key(self): |
662 | 729 | return read_data_from_binary_file('tests/resources/certs/testSigningKey.p8') |
|
0 commit comments