From 68d721a84b7db485242017045f37f9ca0d9c9808 Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Thu, 30 May 2024 14:04:38 +0300 Subject: [PATCH] enabled test_reports.py and addes missing fields to ReportTransactionsFilters --- mangopay/fields.py | 18 +++++++++++++ mangopay/utils.py | 15 +++++++++-- tests/test_reports.py | 62 +++++++++++++++++++++++++++++++++++++++---- 3 files changed, 88 insertions(+), 7 deletions(-) diff --git a/mangopay/fields.py b/mangopay/fields.py index fa447e9..6e85dde 100644 --- a/mangopay/fields.py +++ b/mangopay/fields.py @@ -338,6 +338,8 @@ def python_value(self, value): if value is not None: local_min_debited_funds_amount = '' local_max_debited_funds_amount = '' + local_min_fees_amount = '' + local_max_fees_amount = '' if 'MinDebitedFundsAmount' in value and value['MinDebitedFundsAmount']: local_min_debited_funds_amount = int(value['MinDebitedFundsAmount']) @@ -345,6 +347,12 @@ def python_value(self, value): if 'MaxDebitedFundsAmount' in value and value['MaxDebitedFundsAmount']: local_max_debited_funds_amount = int(value['MaxDebitedFundsAmount']) + if 'MinFeesAmount' in value and value['MinFeesAmount']: + local_min_fees_amount = int(value['MinFeesAmount']) + + if 'MaxFeesAmount' in value and value['MaxFeesAmount']: + local_max_fees_amount = int(value['MaxFeesAmount']) + author_id = None wallet_id = None if 'AuthorId' in value: @@ -361,6 +369,11 @@ def python_value(self, value): min_debited_funds_currency=value['MinDebitedFundsCurrency'], max_debited_funds_amount=local_max_debited_funds_amount, max_debited_funds_currency=value['MaxDebitedFundsCurrency'], + result_code=value['ResultCode'], + min_fees_amount=local_min_fees_amount, + min_fees_currency=value['MinFeesCurrency'], + max_fees_amount=local_max_fees_amount, + max_fees_currency=value['MaxFeesCurrency'], author_id=author_id, wallet_id=wallet_id ) return value @@ -390,6 +403,11 @@ def api_value(self, value): 'MinDebitedFundsCurrency': value.min_debited_funds_currency, 'MaxDebitedFundsAmount': value.max_debited_funds_amount, 'MaxDebitedFundsCurrency': value.max_debited_funds_currency, + 'ResultCode': value.result_code, + 'MinFeesAmount': value.min_fees_amount, + 'MinFeesCurrency': value.min_fees_currency, + 'MaxFeesAmount': value.max_fees_amount, + 'MaxFeesCurrency': value.max_fees_currency, 'AuthorId': value.author_id, 'WalletId': value.wallet_id, } diff --git a/mangopay/utils.py b/mangopay/utils.py index 186a140..5734a4e 100644 --- a/mangopay/utils.py +++ b/mangopay/utils.py @@ -386,7 +386,8 @@ def __eq__(self, other): class ReportTransactionsFilters(object): def __init__(self, before_date=None, after_date=None, transaction_type=None, status=None, nature=None, min_debited_funds_amount=None, min_debited_funds_currency=None, max_debited_funds_amount=None, - max_debited_funds_currency=None, author_id=None, wallet_id=None): + max_debited_funds_currency=None, author_id=None, wallet_id=None, result_code=None, + min_fees_amount=None, min_fees_currency=None, max_fees_amount=None, max_fees_currency=None): self.before_date = before_date self.after_date = after_date self.transaction_type = transaction_type @@ -398,6 +399,11 @@ def __init__(self, before_date=None, after_date=None, transaction_type=None, sta self.max_debited_funds_currency = max_debited_funds_currency self.author_id = author_id self.wallet_id = wallet_id + self.result_code = result_code + self.min_fees_amount = min_fees_amount + self.min_fees_currency = min_fees_currency + self.max_fees_amount = max_fees_amount + self.max_fees_currency = max_fees_currency def __eq__(self, other): if isinstance(other, ReportTransactionsFilters): @@ -411,7 +417,12 @@ def __eq__(self, other): (self.max_debited_funds_amount == other.max_debited_funds_amount) and (self.max_debited_funds_currency == other.max_debited_funds_currency) and (self.author_id == other.author_id) and - (self.wallet_id == other.wallet_id) + (self.wallet_id == other.wallet_id) and + (self.result_code == other.result_code) and + (self.min_fees_amount == other.min_fees_amount) and + (self.min_fees_currency == other.min_fees_currency) and + (self.max_fees_amount == other.max_fees_amount) and + (self.max_fees_currency == other.max_fees_currency) ) return stat return False diff --git a/tests/test_reports.py b/tests/test_reports.py index 21909ff..33691b8 100644 --- a/tests/test_reports.py +++ b/tests/test_reports.py @@ -3,11 +3,9 @@ from mangopay.resources import ReportTransactions, Report from mangopay.utils import ReportTransactionsFilters from tests.test_base import BaseTestLive -import unittest class ReportsTestLive(BaseTestLive): - @unittest.skip("reason for skipping") def test_ReportCreate(self): report = ReportTransactions() report.report_type = 'transactions' @@ -16,7 +14,6 @@ def test_ReportCreate(self): self.assertIsNotNone(result) self.assertTrue(result['id']) - @unittest.skip("reason for skipping") def test_ReportFilteredCreate(self): report = ReportTransactions() report.report_type = 'transactions' @@ -33,14 +30,69 @@ def test_ReportFilteredCreate(self): self.assertEqual(report.filters.author_id, result['filters'].author_id) self.assertEqual(report.filters.wallet_id, result['filters'].wallet_id) - @unittest.skip("reason for skipping") + def test_ReportFilteredCreate_SpecificUseCase(self): + report = ReportTransactions() + report.report_type = 'transactions' + report.tag = 'Created using Mangopay Python SDK' + report.download_format = 'CSV' + report.callback_url = 'https://mangopay.com/docs/please-ignore' + report.preview = False + report.filters = ReportTransactionsFilters( + before_date=1714435201, + after_date=1714348799, + status=['SUCCEEDED'], + nature=['REGULAR'], + wallet_id=None, + author_id=None, + min_debited_funds_amount=0, + min_debited_funds_currency='EUR', + max_debited_funds_amount=1000000, + max_debited_funds_currency='EUR' + ) + report.columns = [ + 'Id', + 'Tag', + 'CreationDate', + 'ExecutionDate', + 'AuthorId', + 'CreditedUserId', + 'DebitedFundsAmount', + 'DebitedFundsCurrency', + 'CreditedFundsAmount', + 'CreditedFundsCurrency', + 'FeesAmount', + 'FeesCurrency', + 'Status', + 'ResultCode', + 'ResultMessage', + 'Type', + 'Nature', + 'CreditedWalletId', + 'DebitedWalletId' + ] + report.sort = 'CreationDate: DESC' + result = report.save() + + self.assertIsNotNone(result) + self.assertIsNotNone(result['filters']) + + self.assertEqual(report.filters.before_date, result['filters'].before_date) + self.assertEqual(report.filters.after_date, result['filters'].after_date) + self.assertEqual(report.filters.status, result['filters'].status) + self.assertEqual(report.filters.nature, result['filters'].nature) + self.assertEqual(report.filters.min_debited_funds_amount, result['filters'].min_debited_funds_amount) + self.assertEqual(report.filters.min_debited_funds_currency, result['filters'].min_debited_funds_currency) + self.assertEqual(report.filters.max_debited_funds_amount, result['filters'].max_debited_funds_amount) + self.assertEqual(report.filters.max_debited_funds_currency, result['filters'].max_debited_funds_currency) + self.assertIsNone(result['filters'].wallet_id) + self.assertIsNone(result['filters'].author_id) + def test_ReportGet(self): report = BaseTestLive.get_johns_report() result = Report.get(report.id) self.assertEqual(report.id, result.id) - @unittest.skip("reason for skipping") def test_Reports_All(self): time.sleep(3) report = BaseTestLive.get_johns_report(recreate=True)