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',
|
'name': 'Online Bank Statements: PayPal.com',
|
||||||
'version': '12.0.1.0.1',
|
'version': '12.0.1.0.2',
|
||||||
'author':
|
'author':
|
||||||
'Brainbean Apps, '
|
'Brainbean Apps, '
|
||||||
'Dataplug, '
|
'Dataplug, '
|
||||||
|
|||||||
@@ -554,7 +554,7 @@ msgid "Mobile payment, made through a mobile phone"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: account_bank_statement_import_online_paypal
|
#. 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
|
#, python-format
|
||||||
msgid "No authentication specified!"
|
msgid "No authentication specified!"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -852,14 +852,14 @@ msgid "Transfer to external GL entity"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: account_bank_statement_import_online_paypal
|
#. 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
|
#, python-format
|
||||||
msgid "Unknown authentication specified!"
|
msgid "Unknown authentication specified!"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: account_bank_statement_import_online_paypal
|
#. 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:484
|
||||||
#: 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:490
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Unknown error"
|
msgid "Unknown error"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -478,18 +478,16 @@ class OnlineBankStatementProviderPayPal(models.Model):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _paypal_decode_error(self, content):
|
def _paypal_decode_error(self, content):
|
||||||
generic_error = content.get('name')
|
if 'name' in content:
|
||||||
if generic_error:
|
|
||||||
return UserError('%s: %s' % (
|
return UserError('%s: %s' % (
|
||||||
generic_error,
|
content['name'],
|
||||||
content.get('message') or _('Unknown error'),
|
content.get('message', _('Unknown error')),
|
||||||
))
|
))
|
||||||
|
|
||||||
identity_error = content.get('error')
|
if 'error' in content:
|
||||||
if identity_error:
|
return UserError('%s: %s' % (
|
||||||
UserError('%s: %s' % (
|
content['error'],
|
||||||
generic_error,
|
content.get('error_description', _('Unknown error')),
|
||||||
content.get('error_description') or _('Unknown error'),
|
|
||||||
))
|
))
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -226,18 +226,15 @@ class TestAccountBankAccountStatementImportOnlinePayPal(
|
|||||||
|
|
||||||
provider = journal.online_bank_statement_provider_id
|
provider = journal.online_bank_statement_provider_id
|
||||||
mocked_response = UrlopenRetValMock("""{
|
mocked_response = UrlopenRetValMock("""{
|
||||||
"message": "MSG",
|
"message": "MESSAGE",
|
||||||
"name": "ERROR"
|
"name": "ERROR"
|
||||||
}""", throw=True)
|
}""", throw=True)
|
||||||
with mock.patch(
|
with mock.patch(
|
||||||
_provider_class + '._paypal_urlopen',
|
_provider_class + '._paypal_urlopen',
|
||||||
return_value=mocked_response,
|
return_value=mocked_response,
|
||||||
), self.mock_token():
|
):
|
||||||
with self.assertRaises(UserError):
|
with self.assertRaises(UserError):
|
||||||
provider._obtain_statement_data(
|
provider._paypal_retrieve('https://url', '')
|
||||||
self.now - relativedelta(years=5),
|
|
||||||
self.now,
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_error_handling_2(self):
|
def test_error_handling_2(self):
|
||||||
journal = self.AccountJournal.create({
|
journal = self.AccountJournal.create({
|
||||||
@@ -251,18 +248,15 @@ class TestAccountBankAccountStatementImportOnlinePayPal(
|
|||||||
|
|
||||||
provider = journal.online_bank_statement_provider_id
|
provider = journal.online_bank_statement_provider_id
|
||||||
mocked_response = UrlopenRetValMock("""{
|
mocked_response = UrlopenRetValMock("""{
|
||||||
"error_description": "DESC",
|
"error_description": "ERROR DESCRIPTION",
|
||||||
"error": "ERROR"
|
"error": "ERROR"
|
||||||
}""", throw=True)
|
}""", throw=True)
|
||||||
with mock.patch(
|
with mock.patch(
|
||||||
_provider_class + '._paypal_urlopen',
|
_provider_class + '._paypal_urlopen',
|
||||||
return_value=mocked_response,
|
return_value=mocked_response,
|
||||||
), self.mock_token():
|
):
|
||||||
with self.assertRaises(UserError):
|
with self.assertRaises(UserError):
|
||||||
provider._obtain_statement_data(
|
provider._paypal_retrieve('https://url', '')
|
||||||
self.now - relativedelta(years=5),
|
|
||||||
self.now,
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_empty_pull(self):
|
def test_empty_pull(self):
|
||||||
journal = self.AccountJournal.create({
|
journal = self.AccountJournal.create({
|
||||||
|
|||||||
Reference in New Issue
Block a user