mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[IMP] account_bank_statement_import_online_paypal: tests
This commit is contained in:
committed by
Omar (Comunitea)
parent
53c659796d
commit
0ac06309cd
@@ -4,7 +4,7 @@
|
||||
|
||||
{
|
||||
'name': 'Online Bank Statements: PayPal.com',
|
||||
'version': '12.0.1.0.1',
|
||||
'version': '12.0.1.0.2',
|
||||
'author':
|
||||
'Brainbean Apps, '
|
||||
'Dataplug, '
|
||||
|
||||
@@ -554,7 +554,7 @@ msgid "Mobile payment, made through a mobile phone"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_online_paypal
|
||||
#: code:addons/account_bank_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py:522
|
||||
#: code:addons/account_bank_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py:520
|
||||
#, python-format
|
||||
msgid "No authentication specified!"
|
||||
msgstr ""
|
||||
@@ -852,14 +852,14 @@ msgid "Transfer to external GL entity"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_online_paypal
|
||||
#: code:addons/account_bank_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py:538
|
||||
#: code:addons/account_bank_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py:536
|
||||
#, python-format
|
||||
msgid "Unknown authentication specified!"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_online_paypal
|
||||
#: code:addons/account_bank_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py:485
|
||||
#: code:addons/account_bank_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py:492
|
||||
#: code:addons/account_bank_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py:484
|
||||
#: code:addons/account_bank_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py:490
|
||||
#, python-format
|
||||
msgid "Unknown error"
|
||||
msgstr ""
|
||||
|
||||
@@ -478,18 +478,16 @@ class OnlineBankStatementProviderPayPal(models.Model):
|
||||
|
||||
@api.model
|
||||
def _paypal_decode_error(self, content):
|
||||
generic_error = content.get('name')
|
||||
if generic_error:
|
||||
if 'name' in content:
|
||||
return UserError('%s: %s' % (
|
||||
generic_error,
|
||||
content.get('message') or _('Unknown error'),
|
||||
content['name'],
|
||||
content.get('message', _('Unknown error')),
|
||||
))
|
||||
|
||||
identity_error = content.get('error')
|
||||
if identity_error:
|
||||
UserError('%s: %s' % (
|
||||
generic_error,
|
||||
content.get('error_description') or _('Unknown error'),
|
||||
if 'error' in content:
|
||||
return UserError('%s: %s' % (
|
||||
content['error'],
|
||||
content.get('error_description', _('Unknown error')),
|
||||
))
|
||||
|
||||
return None
|
||||
|
||||
@@ -226,18 +226,15 @@ class TestAccountBankAccountStatementImportOnlinePayPal(
|
||||
|
||||
provider = journal.online_bank_statement_provider_id
|
||||
mocked_response = UrlopenRetValMock("""{
|
||||
"message": "MSG",
|
||||
"message": "MESSAGE",
|
||||
"name": "ERROR"
|
||||
}""", throw=True)
|
||||
with mock.patch(
|
||||
_provider_class + '._paypal_urlopen',
|
||||
return_value=mocked_response,
|
||||
), self.mock_token():
|
||||
):
|
||||
with self.assertRaises(UserError):
|
||||
provider._obtain_statement_data(
|
||||
self.now - relativedelta(years=5),
|
||||
self.now,
|
||||
)
|
||||
provider._paypal_retrieve('https://url', '')
|
||||
|
||||
def test_error_handling_2(self):
|
||||
journal = self.AccountJournal.create({
|
||||
@@ -251,18 +248,15 @@ class TestAccountBankAccountStatementImportOnlinePayPal(
|
||||
|
||||
provider = journal.online_bank_statement_provider_id
|
||||
mocked_response = UrlopenRetValMock("""{
|
||||
"error_description": "DESC",
|
||||
"error_description": "ERROR DESCRIPTION",
|
||||
"error": "ERROR"
|
||||
}""", throw=True)
|
||||
with mock.patch(
|
||||
_provider_class + '._paypal_urlopen',
|
||||
return_value=mocked_response,
|
||||
), self.mock_token():
|
||||
):
|
||||
with self.assertRaises(UserError):
|
||||
provider._obtain_statement_data(
|
||||
self.now - relativedelta(years=5),
|
||||
self.now,
|
||||
)
|
||||
provider._paypal_retrieve('https://url', '')
|
||||
|
||||
def test_empty_pull(self):
|
||||
journal = self.AccountJournal.create({
|
||||
|
||||
Reference in New Issue
Block a user