Merge PR #483 into 14.0

Signed-off-by alexey-pelykh
This commit is contained in:
OCA-git-bot
2022-08-08 06:49:51 +00:00
7 changed files with 174 additions and 92 deletions

View File

@@ -1,7 +1,7 @@
# Do NOT update manually; changes here will be overwritten by Copier # Do NOT update manually; changes here will be overwritten by Copier
_commit: v1.5.2 _commit: v1.7.0
_src_path: gh:oca/oca-addons-repo-template _src_path: git+https://github.com/oca/oca-addons-repo-template
ci: Travis ci: GitHub
dependency_installation_mode: PIP dependency_installation_mode: PIP
generate_requirements_txt: true generate_requirements_txt: true
include_wkhtmltopdf: false include_wkhtmltopdf: false
@@ -15,3 +15,4 @@ repo_slug: bank-statement-import
repo_website: https://github.com/OCA/bank-statement-import repo_website: https://github.com/OCA/bank-statement-import
travis_apt_packages: [] travis_apt_packages: []
travis_apt_sources: [] travis_apt_sources: []

69
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,69 @@
name: tests
on:
pull_request:
branches:
- "14.0*"
push:
branches:
- "14.0"
- "14.0-ocabot-*"
jobs:
unreleased-deps:
runs-on: ubuntu-latest
name: Detect unreleased dependencies
steps:
- uses: actions/checkout@v2
- run: |
for reqfile in requirements.txt test-requirements.txt ; do
if [ -f ${reqfile} ] ; then
result=0
# reject non-comment lines that contain a / (i.e. URLs, relative paths)
grep "^[^#].*/" ${reqfile} || result=$?
if [ $result -eq 0 ] ; then
echo "Unreleased dependencies found in ${reqfile}."
exit 1
fi
fi
done
test:
runs-on: ubuntu-latest
container: ${{ matrix.container }}
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- container: ghcr.io/oca/oca-ci/py3.6-odoo14.0:latest
makepot: "true"
name: test with Odoo
- container: ghcr.io/oca/oca-ci/py3.6-ocb14.0:latest
name: test with OCB
services:
postgres:
image: postgres:9.6
env:
POSTGRES_USER: odoo
POSTGRES_PASSWORD: odoo
POSTGRES_DB: odoo
ports:
- 5432:5432
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Install addons and dependencies
run: oca_install_addons
- name: Check licenses
run: manifestoo -d . check-licenses
- name: Check development status
run: manifestoo -d . check-dev-status --default-dev-status=Beta
- name: Initialize test db
run: oca_init_test_database
- name: Run tests
run: oca_run_tests
- uses: codecov/codecov-action@v1
- name: Update .pot files
run: oca_export_and_push_pot https://x-access-token:${{ secrets.GIT_PUSH_TOKEN }}@github.com/${{ github.repository }}
if: ${{ matrix.makepot == 'true' && github.event_name == 'push' && github.repository_owner == 'OCA' }}

View File

@@ -1,3 +1,5 @@
[MASTER] [MASTER]
load-plugins=pylint_odoo load-plugins=pylint_odoo
score=n score=n

View File

@@ -1,3 +1,4 @@
[MASTER] [MASTER]
load-plugins=pylint_odoo load-plugins=pylint_odoo
score=n score=n

View File

@@ -1,42 +0,0 @@
language: python
cache:
directories:
- $HOME/.cache/pip
- $HOME/.cache/pre-commit
python:
- "3.6"
addons:
postgresql: "9.6"
apt:
packages:
- expect-dev # provides unbuffer utility
stages:
- test
jobs:
include:
- stage: test
env:
- TESTS=1 ODOO_REPO="odoo/odoo" MAKEPOT="1"
- stage: test
env:
- TESTS=1 ODOO_REPO="OCA/OCB"
env:
global:
- VERSION="14.0" TESTS="0" LINT_CHECK="0" MAKEPOT="0"
- MQT_DEP=PIP
install:
- git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git
${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- travis_install_nightly
script:
- travis_run_tests
after_success:
- travis_after_tests_success

View File

@@ -1,6 +1,7 @@
[![Runboat](https://img.shields.io/badge/runboat-Try%20me-875A7B.png)](https://runboat.odoo-community.org/builds?repo=OCA/bank-statement-import&target_branch=14.0) [![Runboat](https://img.shields.io/badge/runboat-Try%20me-875A7B.png)](https://runboat.odoo-community.org/builds?repo=OCA/bank-statement-import&target_branch=14.0)
[![Build Status](https://travis-ci.com/OCA/bank-statement-import.svg?branch=14.0)](https://travis-ci.com/OCA/bank-statement-import) [![Pre-commit Status](https://github.com/OCA/bank-statement-import/actions/workflows/pre-commit.yml/badge.svg?branch=14.0)](https://github.com/OCA/bank-statement-import/actions/workflows/pre-commit.yml?query=branch%3A14.0)
[![Build Status](https://github.com/OCA/bank-statement-import/actions/workflows/test.yml/badge.svg?branch=14.0)](https://github.com/OCA/bank-statement-import/actions/workflows/test.yml?query=branch%3A14.0)
[![codecov](https://codecov.io/gh/OCA/bank-statement-import/branch/14.0/graph/badge.svg)](https://codecov.io/gh/OCA/bank-statement-import) [![codecov](https://codecov.io/gh/OCA/bank-statement-import/branch/14.0/graph/badge.svg)](https://codecov.io/gh/OCA/bank-statement-import)
[![Translation Status](https://translation.odoo-community.org/widgets/bank-statement-import-14-0/-/svg-badge.svg)](https://translation.odoo-community.org/engage/bank-statement-import-14-0/?utm_source=widget) [![Translation Status](https://translation.odoo-community.org/widgets/bank-statement-import-14-0/-/svg-badge.svg)](https://translation.odoo-community.org/engage/bank-statement-import-14-0/?utm_source=widget)

View File

@@ -1,5 +1,5 @@
# Copyright 2019 Brainbean Apps (https://brainbeanapps.com) # Copyright 2019 Brainbean Apps (https://brainbeanapps.com)
# Copyright 2021 CorporateHub (https://corporatehub.eu) # Copyright 2021-2022 CorporateHub (https://corporatehub.eu)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import json import json
@@ -54,6 +54,13 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
super().setUp() super().setUp()
self.now = fields.Datetime.now() self.now = fields.Datetime.now()
self.now_isoformat = self.now.isoformat() + "+0000"
self.today = datetime(self.now.year, self.now.month, self.now.day)
self.today_isoformat = self.today.isoformat() + "+0000"
self.today_timestamp = str(int(self.today.timestamp()))
self.yesterday = self.today - relativedelta(days=1)
self.yesterday_isoformat = self.yesterday.isoformat() + "+0000"
self.yesterday_timestamp = str(int(self.yesterday.timestamp()))
self.currency_eur = self.env.ref("base.EUR") self.currency_eur = self.env.ref("base.EUR")
self.currency_usd = self.env.ref("base.USD") self.currency_usd = self.env.ref("base.USD")
self.AccountJournal = self.env["account.journal"] self.AccountJournal = self.env["account.journal"]
@@ -245,9 +252,13 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
} }
], ],
"account_id": "1234567890", "account_id": "1234567890",
"as_of_time": "2019-08-01T00:00:00+0000", "as_of_time": "%s",
"last_refresh_time": "2019-08-01T00:00:00+0000" "last_refresh_time": "%s"
}""" }"""
% (
self.now_isoformat,
self.now_isoformat,
)
) )
with mock.patch( with mock.patch(
_provider_class + "._paypal_urlopen", _provider_class + "._paypal_urlopen",
@@ -333,13 +344,18 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
"""{ """{
"transaction_details": [], "transaction_details": [],
"account_number": "1234567890", "account_number": "1234567890",
"start_date": "2019-08-01T00:00:00+0000", "start_date": "%s",
"end_date": "2019-08-01T00:00:00+0000", "end_date": "%s",
"last_refreshed_datetime": "2019-09-01T00:00:00+0000", "last_refreshed_datetime": "%s",
"page": 1, "page": 1,
"total_items": 0, "total_items": 0,
"total_pages": 0 "total_pages": 0
}""", }"""
% (
self.now_isoformat,
self.now_isoformat,
self.now_isoformat,
),
parse_float=Decimal, parse_float=Decimal,
) )
mocked_response_2 = json.loads( mocked_response_2 = json.loads(
@@ -363,9 +379,13 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
} }
], ],
"account_id": "1234567890", "account_id": "1234567890",
"as_of_time": "2019-08-01T00:00:00+0000", "as_of_time": "%s",
"last_refresh_time": "2019-08-01T00:00:00+0000" "last_refresh_time": "%s"
}""", }"""
% (
self.now_isoformat,
self.now_isoformat,
),
parse_float=Decimal, parse_float=Decimal,
) )
with mock.patch( with mock.patch(
@@ -396,13 +416,18 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
"""{ """{
"transaction_details": [], "transaction_details": [],
"account_number": "1234567890", "account_number": "1234567890",
"start_date": "2019-08-01T00:00:00+0000", "start_date": "%s",
"end_date": "2019-08-01T00:00:00+0000", "end_date": "%s",
"last_refreshed_datetime": "2019-09-01T00:00:00+0000", "last_refreshed_datetime": "%s",
"page": 1, "page": 1,
"total_items": 0, "total_items": 0,
"total_pages": 0 "total_pages": 0
}""", }"""
% (
self.now_isoformat,
self.now_isoformat,
self.now_isoformat,
),
parse_float=Decimal, parse_float=Decimal,
) )
with mock.patch( with mock.patch(
@@ -435,8 +460,8 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
"paypal_account_id": "1234567890", "paypal_account_id": "1234567890",
"transaction_id": "1234567890", "transaction_id": "1234567890",
"transaction_event_code": "T1234", "transaction_event_code": "T1234",
"transaction_initiation_date": "2019-08-01T00:00:00+0000", "transaction_initiation_date": "%s",
"transaction_updated_date": "2019-08-01T00:00:00+0000", "transaction_updated_date": "%s",
"transaction_amount": { "transaction_amount": {
"currency_code": "USD", "currency_code": "USD",
"value": "1000.00" "value": "1000.00"
@@ -477,8 +502,8 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
"paypal_account_id": "1234567890", "paypal_account_id": "1234567890",
"transaction_id": "1234567891", "transaction_id": "1234567891",
"transaction_event_code": "T1234", "transaction_event_code": "T1234",
"transaction_initiation_date": "2019-08-02T00:00:00+0000", "transaction_initiation_date": "%s",
"transaction_updated_date": "2019-08-02T00:00:00+0000", "transaction_updated_date": "%s",
"transaction_amount": { "transaction_amount": {
"currency_code": "USD", "currency_code": "USD",
"value": "1000.00" "value": "1000.00"
@@ -516,13 +541,22 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
"incentive_info": {} "incentive_info": {}
}], }],
"account_number": "1234567890", "account_number": "1234567890",
"start_date": "2019-08-01T00:00:00+0000", "start_date": "%s",
"end_date": "2019-08-02T00:00:00+0000", "end_date": "%s",
"last_refreshed_datetime": "2019-09-01T00:00:00+0000", "last_refreshed_datetime": "%s",
"page": 1, "page": 1,
"total_items": 1, "total_items": 1,
"total_pages": 1 "total_pages": 1
}""", }"""
% (
self.yesterday_isoformat,
self.yesterday_isoformat,
self.today_isoformat,
self.today_isoformat,
self.yesterday_isoformat,
self.today_isoformat,
self.now_isoformat,
),
parse_float=Decimal, parse_float=Decimal,
) )
with mock.patch( with mock.patch(
@@ -530,8 +564,8 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
return_value=mocked_response, return_value=mocked_response,
), self.mock_token(): ), self.mock_token():
data = provider._obtain_statement_data( data = provider._obtain_statement_data(
datetime(2019, 8, 1), self.yesterday,
datetime(2019, 8, 2), self.today,
) )
self.assertEqual(len(data[0]), 2) self.assertEqual(len(data[0]), 2)
@@ -539,23 +573,23 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
self.assertEqual( self.assertEqual(
data[0][0], data[0][0],
{ {
"date": datetime(2019, 8, 1), "date": self.yesterday,
"amount": "1000.00", "amount": "1000.00",
"ref": "Invoice 1", "ref": "Invoice 1",
"payment_ref": "1234567890: Payment for Invoice(s) 1", "payment_ref": "1234567890: Payment for Invoice(s) 1",
"partner_name": "Acme, Inc.", "partner_name": "Acme, Inc.",
"unique_import_id": "1234567890-1564617600", "unique_import_id": "1234567890-%s" % (self.yesterday_timestamp,),
}, },
) )
self.assertEqual( self.assertEqual(
data[0][1], data[0][1],
{ {
"date": datetime(2019, 8, 1), "date": self.yesterday,
"amount": "-100.00", "amount": "-100.00",
"ref": "Fee for Invoice 1", "ref": "Fee for Invoice 1",
"payment_ref": "Transaction fee for 1234567890: Payment for Invoice(s) 1", "payment_ref": "Transaction fee for 1234567890: Payment for Invoice(s) 1",
"partner_name": "PayPal", "partner_name": "PayPal",
"unique_import_id": "1234567890-1564617600-FEE", "unique_import_id": "1234567890-%s-FEE" % (self.yesterday_timestamp,),
}, },
) )
self.assertEqual(data[1], {"balance_start": 0.0, "balance_end_real": 900.0}) self.assertEqual(data[1], {"balance_start": 0.0, "balance_end_real": 900.0})
@@ -567,8 +601,8 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
"paypal_account_id": "1234567890", "paypal_account_id": "1234567890",
"transaction_id": "1234567890", "transaction_id": "1234567890",
"transaction_event_code": "T1234", "transaction_event_code": "T1234",
"transaction_initiation_date": "2019-08-01T00:00:00+0000", "transaction_initiation_date": "%s",
"transaction_updated_date": "2019-08-01T00:00:00+0000", "transaction_updated_date": "%s",
"transaction_amount": { "transaction_amount": {
"currency_code": "USD", "currency_code": "USD",
"value": "1000.00" "value": "1000.00"
@@ -605,18 +639,22 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
"auction_info": {}, "auction_info": {},
"incentive_info": {} "incentive_info": {}
}""" }"""
% (
self.today_isoformat,
self.today_isoformat,
)
) )
self.assertEqual(len(lines), 1) self.assertEqual(len(lines), 1)
del lines[0]["online_raw_data"] del lines[0]["online_raw_data"]
self.assertEqual( self.assertEqual(
lines[0], lines[0],
{ {
"date": datetime(2019, 8, 1), "date": self.today,
"amount": "1000.00", "amount": "1000.00",
"ref": "Invoice 1", "ref": "Invoice 1",
"payment_ref": "1234567890: Payment for Invoice(s) 1", "payment_ref": "1234567890: Payment for Invoice(s) 1",
"partner_name": "Acme, Inc.", "partner_name": "Acme, Inc.",
"unique_import_id": "1234567890-1564617600", "unique_import_id": "1234567890-%s" % (self.today_timestamp,),
}, },
) )
@@ -627,8 +665,8 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
"paypal_account_id": "1234567890", "paypal_account_id": "1234567890",
"transaction_id": "1234567890", "transaction_id": "1234567890",
"transaction_event_code": "T1234", "transaction_event_code": "T1234",
"transaction_initiation_date": "2019-08-01T00:00:00+0000", "transaction_initiation_date": "%s",
"transaction_updated_date": "2019-08-01T00:00:00+0000", "transaction_updated_date": "%s",
"transaction_amount": { "transaction_amount": {
"currency_code": "USD", "currency_code": "USD",
"value": "1000.00" "value": "1000.00"
@@ -665,18 +703,22 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
"auction_info": {}, "auction_info": {},
"incentive_info": {} "incentive_info": {}
}""" }"""
% (
self.today_isoformat,
self.today_isoformat,
)
) )
self.assertEqual(len(lines), 1) self.assertEqual(len(lines), 1)
del lines[0]["online_raw_data"] del lines[0]["online_raw_data"]
self.assertEqual( self.assertEqual(
lines[0], lines[0],
{ {
"date": datetime(2019, 8, 1), "date": self.today,
"amount": "1000.00", "amount": "1000.00",
"ref": "Invoice 1", "ref": "Invoice 1",
"payment_ref": "1234567890: Payment for Invoice(s) 1", "payment_ref": "1234567890: Payment for Invoice(s) 1",
"partner_name": "Acme, Inc.", "partner_name": "Acme, Inc.",
"unique_import_id": "1234567890-1564617600", "unique_import_id": "1234567890-%s" % (self.today_timestamp,),
}, },
) )
@@ -687,8 +729,8 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
"paypal_account_id": "1234567890", "paypal_account_id": "1234567890",
"transaction_id": "1234567890", "transaction_id": "1234567890",
"transaction_event_code": "T1234", "transaction_event_code": "T1234",
"transaction_initiation_date": "2019-08-01T00:00:00+0000", "transaction_initiation_date": "%s",
"transaction_updated_date": "2019-08-01T00:00:00+0000", "transaction_updated_date": "%s",
"transaction_amount": { "transaction_amount": {
"currency_code": "USD", "currency_code": "USD",
"value": "1000.00" "value": "1000.00"
@@ -725,29 +767,33 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
"auction_info": {}, "auction_info": {},
"incentive_info": {} "incentive_info": {}
}""" }"""
% (
self.today_isoformat,
self.today_isoformat,
)
) )
self.assertEqual(len(lines), 2) self.assertEqual(len(lines), 2)
del lines[0]["online_raw_data"] del lines[0]["online_raw_data"]
self.assertEqual( self.assertEqual(
lines[0], lines[0],
{ {
"date": datetime(2019, 8, 1), "date": self.today,
"amount": "1000.00", "amount": "1000.00",
"ref": "Invoice 1", "ref": "Invoice 1",
"payment_ref": "1234567890: Payment for Invoice(s) 1", "payment_ref": "1234567890: Payment for Invoice(s) 1",
"partner_name": "Acme, Inc.", "partner_name": "Acme, Inc.",
"unique_import_id": "1234567890-1564617600", "unique_import_id": "1234567890-%s" % (self.today_timestamp,),
}, },
) )
self.assertEqual( self.assertEqual(
lines[1], lines[1],
{ {
"date": datetime(2019, 8, 1), "date": self.today,
"amount": "-100.00", "amount": "-100.00",
"ref": "Fee for Invoice 1", "ref": "Fee for Invoice 1",
"payment_ref": "Transaction fee for 1234567890: Payment for Invoice(s) 1", "payment_ref": "Transaction fee for 1234567890: Payment for Invoice(s) 1",
"partner_name": "PayPal", "partner_name": "PayPal",
"unique_import_id": "1234567890-1564617600-FEE", "unique_import_id": "1234567890-%s-FEE" % (self.today_timestamp,),
}, },
) )
@@ -758,8 +804,8 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
"paypal_account_id": "1234567890", "paypal_account_id": "1234567890",
"transaction_id": "1234567890", "transaction_id": "1234567890",
"transaction_event_code": "T1234", "transaction_event_code": "T1234",
"transaction_initiation_date": "2019-08-01T00:00:00+0000", "transaction_initiation_date": "%s",
"transaction_updated_date": "2019-08-01T00:00:00+0000", "transaction_updated_date": "%s",
"transaction_amount": { "transaction_amount": {
"currency_code": "USD", "currency_code": "USD",
"value": "1000.00" "value": "1000.00"
@@ -792,17 +838,21 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
"auction_info": {}, "auction_info": {},
"incentive_info": {} "incentive_info": {}
}""" }"""
% (
self.today_isoformat,
self.today_isoformat,
)
) )
self.assertEqual(len(lines), 1) self.assertEqual(len(lines), 1)
del lines[0]["online_raw_data"] del lines[0]["online_raw_data"]
self.assertEqual( self.assertEqual(
lines[0], lines[0],
{ {
"date": datetime(2019, 8, 1), "date": self.today,
"amount": "1000.00", "amount": "1000.00",
"ref": "Invoice 1", "ref": "Invoice 1",
"payment_ref": "1234567890: Payment for Invoice(s) 1", "payment_ref": "1234567890: Payment for Invoice(s) 1",
"partner_name": "Acme, Inc.", "partner_name": "Acme, Inc.",
"unique_import_id": "1234567890-1564617600", "unique_import_id": "1234567890-%s" % (self.today_timestamp,),
}, },
) )