From 591f3f0bb9ec944757a482db40e34162b3eb2fbe Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Tue, 4 May 2021 18:36:45 +0530 Subject: [PATCH 01/31] ci: Try Parallel tests --- .github/helper/install.sh | 2 +- .github/workflows/ci-tests.yml | 55 ++++++++++++++++++---------------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/.github/helper/install.sh b/.github/helper/install.sh index 7b0f944c66..fd32624c2d 100644 --- a/.github/helper/install.sh +++ b/.github/helper/install.sh @@ -12,7 +12,7 @@ sudo apt install npm pip install frappe-bench -git clone https://github.com/frappe/frappe --branch "${GITHUB_BASE_REF:-${GITHUB_REF##*/}}" --depth 1 +git clone https://github.com/surajshetty3416/frappe --branch "${GITHUB_BASE_REF:-${GITHUB_REF##*/}}" --depth 1 bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench mkdir ~/frappe-bench/sites/test_site diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 84ecfb1457..de8d7ac503 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -13,7 +13,10 @@ jobs: include: - TYPE: "server" JOB_NAME: "Server" - RUN_COMMAND: cd ~/frappe-bench/ && bench --site test_site run-tests --app erpnext --coverage + RUN_COMMAND: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --with-coverage --ci-build-id $GITHUB_RUN_ID --app erpnext + - TYPE: "server" + JOB_NAME: "Server" + RUN_COMMAND: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --with-coverage --ci-build-id $GITHUB_RUN_ID --app erpnext - TYPE: "patch" JOB_NAME: "Patch" RUN_COMMAND: cd ~/frappe-bench/ && wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz && bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz && bench --site test_site migrate @@ -80,29 +83,29 @@ jobs: env: TYPE: ${{ matrix.TYPE }} - - name: Coverage - Pull Request - if: matrix.TYPE == 'server' && github.event_name == 'pull_request' - run: | - cp ~/frappe-bench/sites/.coverage ${GITHUB_WORKSPACE} - cd ${GITHUB_WORKSPACE} - pip install coveralls==2.2.0 - pip install coverage==4.5.4 - coveralls --service=github - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} - COVERALLS_SERVICE_NAME: github - - - name: Coverage - Push - if: matrix.TYPE == 'server' && github.event_name == 'push' - run: | - cp ~/frappe-bench/sites/.coverage ${GITHUB_WORKSPACE} - cd ${GITHUB_WORKSPACE} - pip install coveralls==2.2.0 - pip install coverage==4.5.4 - coveralls --service=github-actions - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} - COVERALLS_SERVICE_NAME: github-actions + # - name: Coverage - Pull Request + # if: matrix.TYPE == 'server' && github.event_name == 'pull_request' + # run: | + # cp ~/frappe-bench/sites/.coverage ${GITHUB_WORKSPACE} + # cd ${GITHUB_WORKSPACE} + # pip install coveralls==2.2.0 + # pip install coverage==4.5.4 + # coveralls --service=github + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} + # COVERALLS_SERVICE_NAME: github + + # - name: Coverage - Push + # if: matrix.TYPE == 'server' && github.event_name == 'push' + # run: | + # cp ~/frappe-bench/sites/.coverage ${GITHUB_WORKSPACE} + # cd ${GITHUB_WORKSPACE} + # pip install coveralls==2.2.0 + # pip install coverage==4.5.4 + # coveralls --service=github-actions + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} + # COVERALLS_SERVICE_NAME: github-actions From dd1530492104759f28df37e5b0235ab19551cff5 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Tue, 4 May 2021 18:58:20 +0530 Subject: [PATCH 02/31] fix: Frappe branch --- .github/helper/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/helper/install.sh b/.github/helper/install.sh index fd32624c2d..44659f22fa 100644 --- a/.github/helper/install.sh +++ b/.github/helper/install.sh @@ -12,7 +12,7 @@ sudo apt install npm pip install frappe-bench -git clone https://github.com/surajshetty3416/frappe --branch "${GITHUB_BASE_REF:-${GITHUB_REF##*/}}" --depth 1 +git clone https://github.com/surajshetty3416/frappe --branch "python-distributed-testing" --depth 1 bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench mkdir ~/frappe-bench/sites/test_site From 34e620fb5b50b6198544ae16b9480b345933ab70 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 6 May 2021 13:04:12 +0530 Subject: [PATCH 03/31] test: Fix dependency --- erpnext/tests/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/tests/__init__.py b/erpnext/tests/__init__.py index e69de29bb2..dcc4f5336d 100644 --- a/erpnext/tests/__init__.py +++ b/erpnext/tests/__init__.py @@ -0,0 +1 @@ +global_test_dependencies = ['User', 'Company'] From 85dd5d2252d5d2539bec0cabb364c87df22d8660 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 6 May 2021 13:05:03 +0530 Subject: [PATCH 04/31] chore: Debug --- .github/workflows/ci-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index de8d7ac503..7373c1efa6 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -1,6 +1,6 @@ name: CI -on: [pull_request, workflow_dispatch, push] +on: [pull_request, workflow_dispatch] jobs: test: From 0f3d862ba993e56b1312e67334ae138ee52b663c Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 6 May 2021 15:13:09 +0530 Subject: [PATCH 05/31] chore: Debug --- .github/workflows/ci-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 7373c1efa6..b03aad794b 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -17,6 +17,9 @@ jobs: - TYPE: "server" JOB_NAME: "Server" RUN_COMMAND: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --with-coverage --ci-build-id $GITHUB_RUN_ID --app erpnext + - TYPE: "server" + JOB_NAME: "Server" + RUN_COMMAND: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --with-coverage --ci-build-id $GITHUB_RUN_ID --app erpnext - TYPE: "patch" JOB_NAME: "Patch" RUN_COMMAND: cd ~/frappe-bench/ && wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz && bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz && bench --site test_site migrate From 7b74985a548aaf80778555b84fe10104ee2b90e6 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 6 May 2021 17:44:26 +0530 Subject: [PATCH 06/31] test: Fix test_dependencies --- erpnext/accounts/doctype/budget/test_budget.py | 2 ++ erpnext/education/doctype/fees/test_fees.py | 3 +-- erpnext/tests/__init__.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/budget/test_budget.py b/erpnext/accounts/doctype/budget/test_budget.py index c5ec23c829..603e21ea24 100644 --- a/erpnext/accounts/doctype/budget/test_budget.py +++ b/erpnext/accounts/doctype/budget/test_budget.py @@ -11,6 +11,8 @@ from erpnext.buying.doctype.purchase_order.test_purchase_order import create_pur from erpnext.accounts.doctype.budget.budget import get_actual_expense, BudgetError from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry +test_dependencies = ['Monthly Distribution'] + class TestBudget(unittest.TestCase): def test_monthly_budget_crossed_ignore(self): set_total_expense_zero(nowdate(), "cost_center") diff --git a/erpnext/education/doctype/fees/test_fees.py b/erpnext/education/doctype/fees/test_fees.py index eedc2ae730..c6bb704b41 100644 --- a/erpnext/education/doctype/fees/test_fees.py +++ b/erpnext/education/doctype/fees/test_fees.py @@ -9,8 +9,7 @@ from frappe.utils import nowdate from frappe.utils.make_random import get_random from erpnext.education.doctype.program.test_program import make_program_and_linked_courses -# test_records = frappe.get_test_records('Fees') - +test_dependencies = ['Company'] class TestFees(unittest.TestCase): def test_fees(self): diff --git a/erpnext/tests/__init__.py b/erpnext/tests/__init__.py index dcc4f5336d..593bc7c71b 100644 --- a/erpnext/tests/__init__.py +++ b/erpnext/tests/__init__.py @@ -1 +1 @@ -global_test_dependencies = ['User', 'Company'] +global_test_dependencies = ['User', 'Company', 'Cost Center', 'Account', 'Warehouse', 'Item'] From 232cd28d67921096ce10fb206894790264ef9e54 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 6 May 2021 18:37:14 +0530 Subject: [PATCH 07/31] test: Fix dependencies --- .../doctype/accounting_dimension/test_accounting_dimension.py | 3 ++- .../test_accounting_dimension_filter.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/accounting_dimension/test_accounting_dimension.py b/erpnext/accounts/doctype/accounting_dimension/test_accounting_dimension.py index fc1d7e344a..6fb661eb54 100644 --- a/erpnext/accounts/doctype/accounting_dimension/test_accounting_dimension.py +++ b/erpnext/accounts/doctype/accounting_dimension/test_accounting_dimension.py @@ -7,7 +7,8 @@ import frappe import unittest from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import delete_accounting_dimension + +test_dependencies = ['Location'] class TestAccountingDimension(unittest.TestCase): def setUp(self): diff --git a/erpnext/accounts/doctype/accounting_dimension_filter/test_accounting_dimension_filter.py b/erpnext/accounts/doctype/accounting_dimension_filter/test_accounting_dimension_filter.py index 7877abd026..78a88eb48c 100644 --- a/erpnext/accounts/doctype/accounting_dimension_filter/test_accounting_dimension_filter.py +++ b/erpnext/accounts/doctype/accounting_dimension_filter/test_accounting_dimension_filter.py @@ -9,6 +9,8 @@ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sal from erpnext.accounts.doctype.accounting_dimension.test_accounting_dimension import create_dimension, disable_dimension from erpnext.exceptions import InvalidAccountDimensionError, MandatoryAccountDimensionError +test_dependencies = ['Location'] + class TestAccountingDimensionFilter(unittest.TestCase): def setUp(self): create_dimension() From c26d41acf98216fbd31a3b97344e9865ec25d8f5 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 6 May 2021 18:37:45 +0530 Subject: [PATCH 08/31] chore: Remove unnecessary print statements --- erpnext/controllers/accounts_controller.py | 1 - erpnext/setup/doctype/email_digest/email_digest.py | 3 +-- erpnext/stock/stock_balance.py | 5 +---- erpnext/utilities/__init__.py | 1 - 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 544e624725..f88e8df728 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1011,7 +1011,6 @@ class AccountsController(TransactionBase): else: grand_total -= self.get("total_advance") base_grand_total = flt(grand_total * self.get("conversion_rate"), self.precision("base_grand_total")) - if total != flt(grand_total, self.precision("grand_total")) or \ base_total != flt(base_grand_total, self.precision("base_grand_total")): frappe.throw(_("Total Payment Amount in Payment Schedule must be equal to Grand / Rounded Total")) diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py index 8c97322a71..5db54eeee1 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.py +++ b/erpnext/setup/doctype/email_digest/email_digest.py @@ -808,7 +808,6 @@ def get_incomes_expenses_for_period(account, from_date, to_date): val = balance_on_to_date - balance_before_from_date else: last_year_closing_balance = get_balance_on(account, date=fy_start_date - timedelta(days=1)) - print(fy_start_date - timedelta(days=1), last_year_closing_balance) val = balance_on_to_date + (last_year_closing_balance - balance_before_from_date) return val @@ -837,4 +836,4 @@ def get_future_date_for_calendaer_event(frequency): elif frequency == "Monthly": to_date = add_to_date(from_date, months=1) - return from_date, to_date \ No newline at end of file + return from_date, to_date diff --git a/erpnext/stock/stock_balance.py b/erpnext/stock/stock_balance.py index 8ba1f1ca5c..8917bfeae4 100644 --- a/erpnext/stock/stock_balance.py +++ b/erpnext/stock/stock_balance.py @@ -194,9 +194,6 @@ def set_stock_balance_as_per_serial_no(item_code=None, posting_date=None, postin serial_nos = frappe.db.sql("""select count(name) from `tabSerial No` where item_code=%s and warehouse=%s and docstatus < 2""", (d[0], d[1])) - if serial_nos and flt(serial_nos[0][0]) != flt(d[2]): - print(d[0], d[1], d[2], serial_nos[0][0]) - sle = frappe.db.sql("""select valuation_rate, company from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and is_cancelled = 0 order by posting_date desc limit 1""", (d[0], d[1])) @@ -230,7 +227,7 @@ def set_stock_balance_as_per_serial_no(item_code=None, posting_date=None, postin }) update_bin(args) - + create_repost_item_valuation_entry({ "item_code": d[0], "warehouse": d[1], diff --git a/erpnext/utilities/__init__.py b/erpnext/utilities/__init__.py index 618cc985ae..0a5aa3c49b 100644 --- a/erpnext/utilities/__init__.py +++ b/erpnext/utilities/__init__.py @@ -12,7 +12,6 @@ def update_doctypes(): for f in dt.fields: if f.fieldname == d.fieldname and f.fieldtype in ("Text", "Small Text"): - print(f.parent, f.fieldname) f.fieldtype = "Text Editor" dt.save() break From 3b69aa80fcd0d4abf270076762bc451141af29ac Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 7 May 2021 00:32:00 +0530 Subject: [PATCH 09/31] ci: Enable coveralls --- .github/workflows/ci-tests.yml | 62 +++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index b03aad794b..4d955190be 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -12,13 +12,13 @@ jobs: matrix: include: - TYPE: "server" - JOB_NAME: "Server" + JOB_NAME: "Server.1" RUN_COMMAND: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --with-coverage --ci-build-id $GITHUB_RUN_ID --app erpnext - TYPE: "server" - JOB_NAME: "Server" + JOB_NAME: "Server.2" RUN_COMMAND: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --with-coverage --ci-build-id $GITHUB_RUN_ID --app erpnext - TYPE: "server" - JOB_NAME: "Server" + JOB_NAME: "Server.3" RUN_COMMAND: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --with-coverage --ci-build-id $GITHUB_RUN_ID --app erpnext - TYPE: "patch" JOB_NAME: "Patch" @@ -86,29 +86,37 @@ jobs: env: TYPE: ${{ matrix.TYPE }} - # - name: Coverage - Pull Request - # if: matrix.TYPE == 'server' && github.event_name == 'pull_request' - # run: | - # cp ~/frappe-bench/sites/.coverage ${GITHUB_WORKSPACE} - # cd ${GITHUB_WORKSPACE} - # pip install coveralls==2.2.0 - # pip install coverage==4.5.4 - # coveralls --service=github - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} - # COVERALLS_SERVICE_NAME: github + - name: Upload Coverage Data + if: matrix.TYPE == 'server' + run: | + cp ~/frappe-bench/sites/.coverage ${GITHUB_WORKSPACE} + cd ${GITHUB_WORKSPACE} + pip3 install coverage==5.5 + pip3 install coveralls==3.0.1 + coveralls --service=github-actions + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} + COVERALLS_FLAG_NAME: run-${{ matrix.container }} + COVERALLS_SERVICE_NAME: github-actions + COVERALLS_PARALLEL: true - # - name: Coverage - Push - # if: matrix.TYPE == 'server' && github.event_name == 'push' - # run: | - # cp ~/frappe-bench/sites/.coverage ${GITHUB_WORKSPACE} - # cd ${GITHUB_WORKSPACE} - # pip install coveralls==2.2.0 - # pip install coverage==4.5.4 - # coveralls --service=github-actions - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} - # COVERALLS_SERVICE_NAME: github-actions + coveralls: + name: Coverage Wrap Up + needs: test + container: python:3-slim + runs-on: ubuntu-18.04 + steps: + - name: Clone + uses: actions/checkout@v2 + + - name: Coveralls Finished + run: | + cd ${GITHUB_WORKSPACE} + ls -al + pip3 install coverage==5.5 + pip3 install coveralls==3.0.1 + coveralls --finish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From b4c958caf05c2605c615e07fb82ab1d9df0419c0 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sat, 8 May 2021 00:04:34 +0530 Subject: [PATCH 10/31] chore: Debug --- .github/workflows/patch.yml | 69 +++++++++++++++++++ .../{ci-tests.yml => server-tests.yml} | 31 +++------ 2 files changed, 78 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/patch.yml rename .github/workflows/{ci-tests.yml => server-tests.yml} (70%) diff --git a/.github/workflows/patch.yml b/.github/workflows/patch.yml new file mode 100644 index 0000000000..7c9e0272c9 --- /dev/null +++ b/.github/workflows/patch.yml @@ -0,0 +1,69 @@ +name: Patch + +on: [pull_request, workflow_dispatch] + +jobs: + test: + runs-on: ubuntu-18.04 + + name: Patch Test + + services: + mysql: + image: mariadb:10.3 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: YES + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3 + + steps: + - name: Clone + uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.6 + + - name: Add to Hosts + run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts + + - name: Cache pip + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + ${{ runner.os }}- + + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - uses: actions/cache@v2 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install + run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh + + - name: Run Patch Tests + run: cd ~/frappe-bench/ && wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz && bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz && bench --site test_site migrate diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/server-tests.yml similarity index 70% rename from .github/workflows/ci-tests.yml rename to .github/workflows/server-tests.yml index 4d955190be..4042a407e7 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/server-tests.yml @@ -1,4 +1,4 @@ -name: CI +name: Server on: [pull_request, workflow_dispatch] @@ -7,24 +7,12 @@ jobs: runs-on: ubuntu-18.04 strategy: - fail-fast: false + fail-fast: true matrix: - include: - - TYPE: "server" - JOB_NAME: "Server.1" - RUN_COMMAND: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --with-coverage --ci-build-id $GITHUB_RUN_ID --app erpnext - - TYPE: "server" - JOB_NAME: "Server.2" - RUN_COMMAND: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --with-coverage --ci-build-id $GITHUB_RUN_ID --app erpnext - - TYPE: "server" - JOB_NAME: "Server.3" - RUN_COMMAND: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --with-coverage --ci-build-id $GITHUB_RUN_ID --app erpnext - - TYPE: "patch" - JOB_NAME: "Patch" - RUN_COMMAND: cd ~/frappe-bench/ && wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz && bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz && bench --site test_site migrate + container: [1, 2] - name: ${{ matrix.JOB_NAME }} + name: Server Tests services: mysql: @@ -42,7 +30,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v2 with: - python-version: 3.6 + python-version: 3.7 - name: Add to Hosts run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts @@ -55,6 +43,7 @@ jobs: restore-keys: | ${{ runner.os }}-pip- ${{ runner.os }}- + - name: Cache node modules uses: actions/cache@v2 env: @@ -66,6 +55,7 @@ jobs: ${{ runner.os }}-build-${{ env.cache-name }}- ${{ runner.os }}-build- ${{ runner.os }}- + - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" @@ -82,12 +72,11 @@ jobs: run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh - name: Run Tests - run: ${{ matrix.RUN_COMMAND }} + run: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app erpnext --build-number ${{ matrix.container }} --total-builds 2 --with-coverage env: - TYPE: ${{ matrix.TYPE }} + TYPE: server - name: Upload Coverage Data - if: matrix.TYPE == 'server' run: | cp ~/frappe-bench/sites/.coverage ${GITHUB_WORKSPACE} cd ${GITHUB_WORKSPACE} @@ -113,10 +102,8 @@ jobs: - name: Coveralls Finished run: | cd ${GITHUB_WORKSPACE} - ls -al pip3 install coverage==5.5 pip3 install coveralls==3.0.1 coveralls --finish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - From 5e88b14a01e790fd324c537f9f7a71928b4bffea Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sat, 8 May 2021 00:05:48 +0530 Subject: [PATCH 11/31] chore: Debug --- .github/workflows/server-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/server-tests.yml b/.github/workflows/server-tests.yml index 4042a407e7..1e9196119e 100644 --- a/.github/workflows/server-tests.yml +++ b/.github/workflows/server-tests.yml @@ -10,7 +10,7 @@ jobs: fail-fast: true matrix: - container: [1, 2] + container: [1, 2, 3] name: Server Tests @@ -72,7 +72,7 @@ jobs: run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh - name: Run Tests - run: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app erpnext --build-number ${{ matrix.container }} --total-builds 2 --with-coverage + run: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app erpnext --build-number ${{ matrix.container }} --total-builds 3 --with-coverage env: TYPE: server From 6ca8989013656aa749b89c8afadd173ce1406ec8 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sat, 8 May 2021 13:51:34 +0530 Subject: [PATCH 12/31] ci: Disble failfast temporarily --- .github/workflows/server-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/server-tests.yml b/.github/workflows/server-tests.yml index 1e9196119e..0d5a3ba61a 100644 --- a/.github/workflows/server-tests.yml +++ b/.github/workflows/server-tests.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-18.04 strategy: - fail-fast: true + fail-fast: false matrix: container: [1, 2, 3] From 8696580254f35c6145063a34de54b0a811068c04 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sat, 8 May 2021 16:02:40 +0530 Subject: [PATCH 13/31] ci: Fix coveralls --- .github/workflows/server-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/server-tests.yml b/.github/workflows/server-tests.yml index 0d5a3ba61a..e5fb72538d 100644 --- a/.github/workflows/server-tests.yml +++ b/.github/workflows/server-tests.yml @@ -82,12 +82,12 @@ jobs: cd ${GITHUB_WORKSPACE} pip3 install coverage==5.5 pip3 install coveralls==3.0.1 - coveralls --service=github-actions + coveralls env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} COVERALLS_FLAG_NAME: run-${{ matrix.container }} - COVERALLS_SERVICE_NAME: github-actions + COVERALLS_SERVICE_NAME: ${{ github.event_name == 'pull_request' && 'github' || 'github-actions' }} COVERALLS_PARALLEL: true coveralls: From 175cb27bcbdd23ef41e256bbf09748229135feeb Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sat, 8 May 2021 19:03:53 +0530 Subject: [PATCH 14/31] test: Pass ConflictingTaxRule during tax rule test --- erpnext/shopping_cart/test_shopping_cart.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/shopping_cart/test_shopping_cart.py b/erpnext/shopping_cart/test_shopping_cart.py index d857bf5f5c..ac61aebc56 100644 --- a/erpnext/shopping_cart/test_shopping_cart.py +++ b/erpnext/shopping_cart/test_shopping_cart.py @@ -7,7 +7,7 @@ import frappe from frappe.utils import nowdate, add_months from erpnext.shopping_cart.cart import _get_cart_quotation, update_cart, get_party from erpnext.tests.utils import create_test_contact_and_address - +from erpnext.accounts.doctype.tax_rule.tax_rule import ConflictingTaxRule # test_dependencies = ['Payment Terms Template'] @@ -125,7 +125,7 @@ class TestShoppingCart(unittest.TestCase): tax_rule = frappe.get_test_records("Tax Rule")[0] try: frappe.get_doc(tax_rule).insert() - except frappe.DuplicateEntryError: + except (frappe.DuplicateEntryError, ConflictingTaxRule): pass def create_quotation(self): From c79f5d7514e73fb64f4e868dc672d6fd33a27ad3 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sun, 9 May 2021 11:29:00 +0530 Subject: [PATCH 15/31] ci: Try parallel testing with orchestrator --- .github/workflows/server-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/server-tests.yml b/.github/workflows/server-tests.yml index e5fb72538d..0e638104c8 100644 --- a/.github/workflows/server-tests.yml +++ b/.github/workflows/server-tests.yml @@ -72,9 +72,10 @@ jobs: run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh - name: Run Tests - run: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app erpnext --build-number ${{ matrix.container }} --total-builds 3 --with-coverage + run: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app erpnext --use-orchestrator --with-coverage env: TYPE: server + CI_BUILD_ID: ${{ github.run_id }} - name: Upload Coverage Data run: | From ab8816e11da22887e413b53b1a11bb916f21127e Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sun, 9 May 2021 14:38:28 +0530 Subject: [PATCH 16/31] test: Fix test dependency --- .../doctype/accounting_dimension/test_accounting_dimension.py | 2 +- .../test_accounting_dimension_filter.py | 2 +- .../doctype/accounting_period/test_accounting_period.py | 4 +++- erpnext/tests/__init__.py | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/accounting_dimension/test_accounting_dimension.py b/erpnext/accounts/doctype/accounting_dimension/test_accounting_dimension.py index 6fb661eb54..e657a9ae34 100644 --- a/erpnext/accounts/doctype/accounting_dimension/test_accounting_dimension.py +++ b/erpnext/accounts/doctype/accounting_dimension/test_accounting_dimension.py @@ -8,7 +8,7 @@ import unittest from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry -test_dependencies = ['Location'] +test_dependencies = ['Cost Center', 'Location', 'Warehouse', 'Department'] class TestAccountingDimension(unittest.TestCase): def setUp(self): diff --git a/erpnext/accounts/doctype/accounting_dimension_filter/test_accounting_dimension_filter.py b/erpnext/accounts/doctype/accounting_dimension_filter/test_accounting_dimension_filter.py index 78a88eb48c..7f6254f99f 100644 --- a/erpnext/accounts/doctype/accounting_dimension_filter/test_accounting_dimension_filter.py +++ b/erpnext/accounts/doctype/accounting_dimension_filter/test_accounting_dimension_filter.py @@ -9,7 +9,7 @@ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sal from erpnext.accounts.doctype.accounting_dimension.test_accounting_dimension import create_dimension, disable_dimension from erpnext.exceptions import InvalidAccountDimensionError, MandatoryAccountDimensionError -test_dependencies = ['Location'] +test_dependencies = ['Location', 'Cost Center', 'Department'] class TestAccountingDimensionFilter(unittest.TestCase): def setUp(self): diff --git a/erpnext/accounts/doctype/accounting_period/test_accounting_period.py b/erpnext/accounts/doctype/accounting_period/test_accounting_period.py index 10cd939894..3b4f138495 100644 --- a/erpnext/accounts/doctype/accounting_period/test_accounting_period.py +++ b/erpnext/accounts/doctype/accounting_period/test_accounting_period.py @@ -10,6 +10,8 @@ from erpnext.accounts.general_ledger import ClosedAccountingPeriod from erpnext.accounts.doctype.accounting_period.accounting_period import OverlapError from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice +test_dependencies = ['Item'] + class TestAccountingPeriod(unittest.TestCase): def test_overlap(self): ap1 = create_accounting_period(start_date = "2018-04-01", @@ -38,7 +40,7 @@ def create_accounting_period(**args): accounting_period.start_date = args.start_date or nowdate() accounting_period.end_date = args.end_date or add_months(nowdate(), 1) accounting_period.company = args.company or "_Test Company" - accounting_period.period_name =args.period_name or "_Test_Period_Name_1" + accounting_period.period_name = args.period_name or "_Test_Period_Name_1" accounting_period.append("closed_documents", { "document_type": 'Sales Invoice', "closed": 1 }) diff --git a/erpnext/tests/__init__.py b/erpnext/tests/__init__.py index 593bc7c71b..a504340d40 100644 --- a/erpnext/tests/__init__.py +++ b/erpnext/tests/__init__.py @@ -1 +1 @@ -global_test_dependencies = ['User', 'Company', 'Cost Center', 'Account', 'Warehouse', 'Item'] +global_test_dependencies = ['User', 'Company', 'Item'] From a70e11450e9e17cc81ff47ffba967a6b76c1fb61 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sun, 9 May 2021 14:38:54 +0530 Subject: [PATCH 17/31] ci: Check limits --- .github/workflows/server-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/server-tests.yml b/.github/workflows/server-tests.yml index 0e638104c8..e7830c07f6 100644 --- a/.github/workflows/server-tests.yml +++ b/.github/workflows/server-tests.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: - container: [1, 2, 3] + container: [1, 2, 3, 4] name: Server Tests @@ -30,7 +30,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: 3.6 - name: Add to Hosts run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts From 19c5fd72d65e92da553c58c4712ab200bd3174aa Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 10 May 2021 09:18:25 +0530 Subject: [PATCH 18/31] refactor: Rename assertEquals to assertEqual to avoid deprecation warnings --- erpnext/accounts/doctype/dunning/test_dunning.py | 2 +- erpnext/accounts/doctype/pricing_rule/pricing_rule.py | 2 +- erpnext/assets/doctype/asset/test_asset.py | 2 +- .../doctype/mpesa_settings/test_mpesa_settings.py | 4 ++-- erpnext/healthcare/doctype/therapy_plan/test_therapy_plan.py | 2 +- erpnext/regional/india/utils.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/dunning/test_dunning.py b/erpnext/accounts/doctype/dunning/test_dunning.py index c5ce514cdd..e2d4d82e41 100644 --- a/erpnext/accounts/doctype/dunning/test_dunning.py +++ b/erpnext/accounts/doctype/dunning/test_dunning.py @@ -29,7 +29,7 @@ class TestDunning(unittest.TestCase): self.assertEqual(round(amounts.get('interest_amount'), 2), 0.44) self.assertEqual(round(amounts.get('dunning_amount'), 2), 20.44) self.assertEqual(round(amounts.get('grand_total'), 2), 120.44) - + def test_gl_entries(self): dunning = create_dunning() dunning.submit() diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index aedf1c6f1a..556f49d34c 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -152,7 +152,7 @@ class PricingRule(Document): frappe.throw(_("Valid from date must be less than valid upto date")) def validate_condition(self): - if self.condition and ("=" in self.condition) and re.match("""[\w\.:_]+\s*={1}\s*[\w\.@'"]+""", self.condition): + if self.condition and ("=" in self.condition) and re.match(r'[\w\.:_]+\s*={1}\s*[\w\.@\'"]+', self.condition): frappe.throw(_("Invalid condition expression")) #-------------------------------------------------------------------------------- diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index 30a270c204..3cd4b802c1 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -566,7 +566,7 @@ class TestAsset(unittest.TestCase): doc = make_invoice(pr.name) self.assertEqual('Asset Received But Not Billed - _TC', doc.items[0].expense_account) - + def test_asset_cwip_toggling_cases(self): cwip = frappe.db.get_value("Asset Category", "Computers", "enable_cwip_accounting") name = frappe.db.get_value("Asset Category Account", filters={"parent": "Computers"}, fieldname=["name"]) diff --git a/erpnext/erpnext_integrations/doctype/mpesa_settings/test_mpesa_settings.py b/erpnext/erpnext_integrations/doctype/mpesa_settings/test_mpesa_settings.py index d370fbcda7..3c2e59ab82 100644 --- a/erpnext/erpnext_integrations/doctype/mpesa_settings/test_mpesa_settings.py +++ b/erpnext/erpnext_integrations/doctype/mpesa_settings/test_mpesa_settings.py @@ -81,7 +81,7 @@ class TestMpesaSettings(unittest.TestCase): integration_request.reload() self.assertEqual(pos_invoice.mpesa_receipt_number, "LGR7OWQX0R") self.assertEqual(integration_request.status, "Completed") - + frappe.db.set_value("Customer", "_Test Customer", "default_currency", "") integration_request.delete() pr.reload() @@ -139,7 +139,7 @@ class TestMpesaSettings(unittest.TestCase): pr.cancel() pr.delete() pos_invoice.delete() - + def test_processing_of_only_one_succes_callback_payload(self): create_mpesa_settings(payment_gateway_name="Payment") mpesa_account = frappe.db.get_value("Payment Gateway Account", {"payment_gateway": 'Mpesa-Payment'}, "payment_account") diff --git a/erpnext/healthcare/doctype/therapy_plan/test_therapy_plan.py b/erpnext/healthcare/doctype/therapy_plan/test_therapy_plan.py index d079bedb42..113fa513f9 100644 --- a/erpnext/healthcare/doctype/therapy_plan/test_therapy_plan.py +++ b/erpnext/healthcare/doctype/therapy_plan/test_therapy_plan.py @@ -29,7 +29,7 @@ class TestTherapyPlan(unittest.TestCase): self.assertEqual(frappe.db.get_value('Therapy Plan', plan.name, 'status'), 'Completed') patient, medical_department, practitioner = create_healthcare_docs() - appointment = create_appointment(patient, practitioner, nowdate()) + appointment = create_appointment(patient, practitioner, nowdate()) session = make_therapy_session(plan.name, plan.patient, 'Basic Rehab', '_Test Company', appointment.name) session = frappe.get_doc(session) session.submit() diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py index fc227defbf..075c698fea 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -500,7 +500,7 @@ def download_ewb_json(): if not isinstance(docname, list): # removes characters not allowed in a filename (https://stackoverflow.com/a/38766141/4767738) - filename_prefix = re.sub('[^\w_.)( -]', '', docname) + filename_prefix = re.sub(r'[^\w_.)( -]', '', docname) frappe.local.response.filename = '{0}_e-WayBill_Data_{1}.json'.format(filename_prefix, frappe.utils.random_string(5)) From b3e647fecace96eb3c817c5dcf9241a5ebc3a3a4 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 10 May 2021 16:13:43 +0530 Subject: [PATCH 19/31] fix: Pass ORCHESTRATOR_URL via secrets --- .github/workflows/server-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/server-tests.yml b/.github/workflows/server-tests.yml index e7830c07f6..0acafcab43 100644 --- a/.github/workflows/server-tests.yml +++ b/.github/workflows/server-tests.yml @@ -76,6 +76,7 @@ jobs: env: TYPE: server CI_BUILD_ID: ${{ github.run_id }} + ORCHESTRATOR_URL: ${{ secrets.ORCHESTRATOR_URL }} - name: Upload Coverage Data run: | From a891d6eed2894c776d91a9a3995d8a3d8de11fe5 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 10 May 2021 17:25:21 +0530 Subject: [PATCH 20/31] fix: allow_zero_valuation_rate for rejected qty --- .../doctype/purchase_invoice/test_purchase_invoice.py | 7 ++++--- .../doctype/stock_ledger_entry/test_stock_ledger_entry.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index 66be11ff23..53db689c84 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -636,8 +636,8 @@ class TestPurchaseInvoice(unittest.TestCase): def test_rejected_serial_no(self): pi = make_purchase_invoice(item_code="_Test Serialized Item With Series", received_qty=2, qty=1, - rejected_qty=1, rate=500, update_stock=1, - rejected_warehouse = "_Test Rejected Warehouse - _TC") + rejected_qty=1, rate=500, update_stock=1, rejected_warehouse = "_Test Rejected Warehouse - _TC", + allow_zero_valuation_rate=1) self.assertEqual(frappe.db.get_value("Serial No", pi.get("items")[0].serial_no, "warehouse"), pi.get("items")[0].warehouse) @@ -994,7 +994,8 @@ def make_purchase_invoice(**args): "project": args.project, "rejected_warehouse": args.rejected_warehouse or "", "rejected_serial_no": args.rejected_serial_no or "", - "asset_location": args.location or "" + "asset_location": args.location or "", + "allow_zero_valuation_rate": args.get("allow_zero_valuation_rate") or 0 }) if args.get_taxes_and_charges: diff --git a/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py index 3296f5ba4a..a1f1897041 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py +++ b/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py @@ -15,10 +15,12 @@ from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_pu from erpnext.stock.doctype.landed_cost_voucher.test_landed_cost_voucher import create_landed_cost_voucher from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note from erpnext.stock.doctype.stock_ledger_entry.stock_ledger_entry import BackDatedStockTransaction +from frappe.core.page.permission_manager.permission_manager import reset class TestStockLedgerEntry(unittest.TestCase): def setUp(self): items = create_items() + reset('Stock Entry') # delete SLE and BINs for all items frappe.db.sql("delete from `tabStock Ledger Entry` where item_code in (%s)" % (', '.join(['%s']*len(items))), items) From d1a13ec0504e39edfb7de193539ba2c94f5b52b9 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 10 May 2021 17:37:44 +0530 Subject: [PATCH 21/31] test: Fix valuation rate for raw materials --- .../stock/doctype/purchase_receipt/test_purchase_receipt.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index e5ef978ca3..5095a80214 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -297,6 +297,8 @@ class TestPurchaseReceipt(unittest.TestCase): item_code = "Test Extra Item 1", qty=10, basic_rate=100) se2 = make_stock_entry(target="_Test Warehouse - _TC", item_code = "_Test FG Item", qty=1, basic_rate=100) + se3 = make_stock_entry(target="_Test Warehouse - _TC", + item_code = "Test Extra Item 2", qty=1, basic_rate=100) rm_items = [ { "item_code": item_code, @@ -331,6 +333,7 @@ class TestPurchaseReceipt(unittest.TestCase): se.cancel() se1.cancel() se2.cancel() + se3.cancel() po.reload() po.cancel() From d48ea663d9c458a20b30f7a8f3dc6f639406c4b7 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 10 May 2021 18:01:53 +0530 Subject: [PATCH 22/31] test: Fix test name - Rename TestSubcontractedItemToBeReceived > TestSubcontractedItemToBeTransferred --- ...t_subcontracted_raw_materials_to_be_transferred.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py index 6900938236..c1fc6fb82f 100644 --- a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py +++ b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py @@ -9,12 +9,12 @@ from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry from erpnext.buying.report.subcontracted_raw_materials_to_be_transferred.subcontracted_raw_materials_to_be_transferred import execute import json, frappe, unittest -class TestSubcontractedItemToBeReceived(unittest.TestCase): +class TestSubcontractedItemToBeTransferred(unittest.TestCase): - def test_pending_and_received_qty(self): + def test_pending_and_transferred_qty(self): po = create_purchase_order(item_code='_Test FG Item', is_subcontracted='Yes') - make_stock_entry(item_code='_Test Item', target='_Test Warehouse 1 - _TC', qty=100, basic_rate=100) - make_stock_entry(item_code='_Test Item Home Desktop 100', target='_Test Warehouse 1 - _TC', qty=100, basic_rate=100) + make_stock_entry(item_code='_Test Item', target='_Test Warehouse - _TC', qty=100, basic_rate=100) + make_stock_entry(item_code='_Test Item Home Desktop 100', target='_Test Warehouse - _TC', qty=100, basic_rate=100) transfer_subcontracted_raw_materials(po.name) col, data = execute(filters=frappe._dict({'supplier': po.supplier, 'from_date': frappe.utils.get_datetime(frappe.utils.add_to_date(po.transaction_date, days=-10)), @@ -38,7 +38,8 @@ def transfer_subcontracted_raw_materials(po): 'warehouse': '_Test Warehouse - _TC', 'rate': 100, 'amount': 200, 'stock_uom': 'Nos'}] rm_item_string = json.dumps(rm_item) se = frappe.get_doc(make_rm_stock_entry(po, rm_item_string)) + se.from_warehouse = '_Test Warehouse 1 - _TC' se.to_warehouse = '_Test Warehouse 1 - _TC' se.stock_entry_type = 'Send to Subcontractor' se.save() - se.submit() \ No newline at end of file + se.submit() From 54354a84e1c15c8fadf836865d8bc0b5405321c9 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 10 May 2021 18:39:09 +0530 Subject: [PATCH 23/31] test: Fix permission error --- .../doctype/stock_ledger_entry/test_stock_ledger_entry.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py index a1f1897041..ba31ad7b06 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py +++ b/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py @@ -316,10 +316,11 @@ class TestStockLedgerEntry(unittest.TestCase): # Set User with Stock User role but not Stock Manager try: user = frappe.get_doc("User", "test@example.com") - frappe.set_user(user.name) user.add_roles("Stock User") user.remove_roles("Stock Manager") + frappe.set_user(user.name) + stock_entry_on_today = make_stock_entry(target="_Test Warehouse - _TC", qty=10, basic_rate=100) back_dated_se_1 = make_stock_entry(target="_Test Warehouse - _TC", qty=10, basic_rate=100, posting_date=add_days(today(), -1), do_not_submit=True) From 273589e835342ea364c3d096a1fd327769df98c8 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 10 May 2021 20:33:47 +0530 Subject: [PATCH 24/31] test: Fix a case where test used to fail due to holiday list - fixes: "Please set a default Holiday List for Employee EMP-00009 or Company Wind Power LLC" error --- .../hr/doctype/upload_attendance/test_upload_attendance.py | 7 +++++++ .../payroll/doctype/payroll_entry/test_payroll_entry.py | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/erpnext/hr/doctype/upload_attendance/test_upload_attendance.py b/erpnext/hr/doctype/upload_attendance/test_upload_attendance.py index 6e151d0e3c..03b0cf3da2 100644 --- a/erpnext/hr/doctype/upload_attendance/test_upload_attendance.py +++ b/erpnext/hr/doctype/upload_attendance/test_upload_attendance.py @@ -5,11 +5,18 @@ from __future__ import unicode_literals import frappe import unittest +import erpnext from frappe.utils import getdate from erpnext.hr.doctype.upload_attendance.upload_attendance import get_data from erpnext.hr.doctype.employee.test_employee import make_employee +test_dependencies = ['Holiday List'] + class TestUploadAttendance(unittest.TestCase): + @classmethod + def setUpClass(cls): + frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", '_Test Holiday List') + def test_date_range(self): employee = make_employee("test_employee@company.com") employee_doc = frappe.get_doc("Employee", employee) diff --git a/erpnext/payroll/doctype/payroll_entry/test_payroll_entry.py b/erpnext/payroll/doctype/payroll_entry/test_payroll_entry.py index 7528bf7a7f..b80b32061f 100644 --- a/erpnext/payroll/doctype/payroll_entry/test_payroll_entry.py +++ b/erpnext/payroll/doctype/payroll_entry/test_payroll_entry.py @@ -15,7 +15,13 @@ from erpnext.payroll.doctype.salary_structure.test_salary_structure import make_ from erpnext.loan_management.doctype.loan.test_loan import create_loan, make_loan_disbursement_entry, create_loan_type, create_loan_accounts from erpnext.loan_management.doctype.process_loan_interest_accrual.process_loan_interest_accrual import process_loan_interest_accrual_for_term_loans +test_dependencies = ['Holiday List'] + class TestPayrollEntry(unittest.TestCase): + @classmethod + def setUpClass(cls): + frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", '_Test Holiday List') + def setUp(self): for dt in ["Salary Slip", "Salary Component", "Salary Component Account", "Payroll Entry", "Salary Structure", "Salary Structure Assignment", "Payroll Employee Detail", "Additional Salary"]: From 96542c3d043a2865af4f77ab6da754eb62bebdc4 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 10 May 2021 20:49:07 +0530 Subject: [PATCH 25/31] style: Fix sider issues --- .../doctype/accounting_period/test_accounting_period.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/accounting_period/test_accounting_period.py b/erpnext/accounts/doctype/accounting_period/test_accounting_period.py index 3b4f138495..dc472c7695 100644 --- a/erpnext/accounts/doctype/accounting_period/test_accounting_period.py +++ b/erpnext/accounts/doctype/accounting_period/test_accounting_period.py @@ -40,7 +40,7 @@ def create_accounting_period(**args): accounting_period.start_date = args.start_date or nowdate() accounting_period.end_date = args.end_date or add_months(nowdate(), 1) accounting_period.company = args.company or "_Test Company" - accounting_period.period_name = args.period_name or "_Test_Period_Name_1" + accounting_period.period_name = args.period_name or "_Test_Period_Name_1" accounting_period.append("closed_documents", { "document_type": 'Sales Invoice', "closed": 1 }) From b9a8afc234b2a1647bc66e647d136b87d684f22a Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 10 May 2021 23:48:37 +0530 Subject: [PATCH 26/31] ci: Add test orchestrator URL --- .github/workflows/server-tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/server-tests.yml b/.github/workflows/server-tests.yml index 0acafcab43..bd60081064 100644 --- a/.github/workflows/server-tests.yml +++ b/.github/workflows/server-tests.yml @@ -76,7 +76,7 @@ jobs: env: TYPE: server CI_BUILD_ID: ${{ github.run_id }} - ORCHESTRATOR_URL: ${{ secrets.ORCHESTRATOR_URL }} + ORCHESTRATOR_URL: http://test-orchestrator.frappe.io - name: Upload Coverage Data run: | @@ -87,7 +87,6 @@ jobs: coveralls env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} COVERALLS_FLAG_NAME: run-${{ matrix.container }} COVERALLS_SERVICE_NAME: ${{ github.event_name == 'pull_request' && 'github' || 'github-actions' }} COVERALLS_PARALLEL: true From 77f2686142568b12dcbea50db03928f6b8ec5673 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Tue, 11 May 2021 10:09:06 +0530 Subject: [PATCH 27/31] ci: Use only 3 containers for now --- .github/workflows/server-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/server-tests.yml b/.github/workflows/server-tests.yml index bd60081064..6597048bc7 100644 --- a/.github/workflows/server-tests.yml +++ b/.github/workflows/server-tests.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: - container: [1, 2, 3, 4] + container: [1, 2, 3] name: Server Tests From 113a6f3d80b95fd249dbe95224f0be197d533c86 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Tue, 11 May 2021 10:59:16 +0530 Subject: [PATCH 28/31] fix: Use frappe.safe_eval instead of eval --- erpnext/setup/doctype/email_digest/email_digest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py index 5db54eeee1..340d89bdf8 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.py +++ b/erpnext/setup/doctype/email_digest/email_digest.py @@ -249,7 +249,7 @@ class EmailDigest(Document): card = cache.get(cache_key) if card: - card = eval(card) + card = frappe.safe_eval(card) else: card = frappe._dict(getattr(self, "get_" + key)()) From 6da2212e2d4f1eba80a4a5d845d515f62a1eaf62 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Wed, 12 May 2021 18:14:22 +0530 Subject: [PATCH 29/31] ci: Update frappe branch --- .github/helper/install.sh | 2 +- .github/workflows/server-tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/helper/install.sh b/.github/helper/install.sh index 44659f22fa..7b0f944c66 100644 --- a/.github/helper/install.sh +++ b/.github/helper/install.sh @@ -12,7 +12,7 @@ sudo apt install npm pip install frappe-bench -git clone https://github.com/surajshetty3416/frappe --branch "python-distributed-testing" --depth 1 +git clone https://github.com/frappe/frappe --branch "${GITHUB_BASE_REF:-${GITHUB_REF##*/}}" --depth 1 bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench mkdir ~/frappe-bench/sites/test_site diff --git a/.github/workflows/server-tests.yml b/.github/workflows/server-tests.yml index 6597048bc7..6f831ac3d1 100644 --- a/.github/workflows/server-tests.yml +++ b/.github/workflows/server-tests.yml @@ -12,7 +12,7 @@ jobs: matrix: container: [1, 2, 3] - name: Server Tests + name: Python Unit Tests services: mysql: From 85aeca14432ecbec86c88549358eac338298eaa4 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Wed, 12 May 2021 23:13:11 +0530 Subject: [PATCH 30/31] ci: Update Python version to 3.7 --- .github/workflows/server-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/server-tests.yml b/.github/workflows/server-tests.yml index 6f831ac3d1..92685e2177 100644 --- a/.github/workflows/server-tests.yml +++ b/.github/workflows/server-tests.yml @@ -30,7 +30,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v2 with: - python-version: 3.6 + python-version: 3.7 - name: Add to Hosts run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts From bcf116422a2d7ed1a4ea33eda1a894b055bbf5b0 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 28 May 2021 09:12:24 +0530 Subject: [PATCH 31/31] ci: Do not generate coverage report for hotfix branch --- .github/workflows/server-tests.yml | 31 ------------------------------ 1 file changed, 31 deletions(-) diff --git a/.github/workflows/server-tests.yml b/.github/workflows/server-tests.yml index 92685e2177..de5cc61d1e 100644 --- a/.github/workflows/server-tests.yml +++ b/.github/workflows/server-tests.yml @@ -77,34 +77,3 @@ jobs: TYPE: server CI_BUILD_ID: ${{ github.run_id }} ORCHESTRATOR_URL: http://test-orchestrator.frappe.io - - - name: Upload Coverage Data - run: | - cp ~/frappe-bench/sites/.coverage ${GITHUB_WORKSPACE} - cd ${GITHUB_WORKSPACE} - pip3 install coverage==5.5 - pip3 install coveralls==3.0.1 - coveralls - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_FLAG_NAME: run-${{ matrix.container }} - COVERALLS_SERVICE_NAME: ${{ github.event_name == 'pull_request' && 'github' || 'github-actions' }} - COVERALLS_PARALLEL: true - - coveralls: - name: Coverage Wrap Up - needs: test - container: python:3-slim - runs-on: ubuntu-18.04 - steps: - - name: Clone - uses: actions/checkout@v2 - - - name: Coveralls Finished - run: | - cd ${GITHUB_WORKSPACE} - pip3 install coverage==5.5 - pip3 install coveralls==3.0.1 - coveralls --finish - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}