From 14600e6a3e10b1c3f6ad1500a471a482302e01d7 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Wed, 24 Jul 2019 15:18:52 +0530 Subject: [PATCH 01/28] fix(travis): Remove unnecessary commands --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index a8a0d82614..ace0bfb243 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,12 +14,6 @@ services: install: # fix mongodb travis error - - sudo rm /etc/apt/sources.list.d/mongodb*.list - - pip install flake8==3.3.0 - - flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics - - sudo rm /etc/apt/sources.list.d/docker.list - - sudo apt-get install hhvm && rm -rf /home/travis/.kiex/ - - sudo apt-get purge -y mysql-common mysql-server mysql-client - nvm install 10 - pip install python-coveralls - wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py From 7204bcb932bc6f00b6aa041d0d3958f9f509db61 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 13:42:43 +0530 Subject: [PATCH 02/28] fix(travis): Restructure build matrix --- .travis.yml | 36 +++++++++++++++++++++++++----------- travis/run-tests.sh | 12 ------------ 2 files changed, 25 insertions(+), 23 deletions(-) delete mode 100755 travis/run-tests.sh diff --git a/.travis.yml b/.travis.yml index ace0bfb243..0660779b2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,34 @@ -language: python dist: trusty -python: - - "2.7" - - "3.6" - -env: - - TEST_TYPE="Server Side Test" - - TEST_TYPE="Patch Test" +language: python services: - mysql +jobs: + include: + - name: "Python 2.7 Server Side Test" + python: 2.7 + script: bench run-tests --app erpnext --coverage + + - name: "Python 3.6 Server Side Test" + python: 3.6 + script: bench run-tests --app erpnext --coverage + + - name: "Python 2.7 Patch Test" + python: 2.7 + before_script: + - wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz + - bench --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz --mariadb-root-password travis + script: bench migrate + + - name: "Python 3.6 Patch Test" + python: 3.6 + before_script: + - wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz + - bench --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz --mariadb-root-password travis + script: bench migrate + install: # fix mongodb travis error - nvm install 10 @@ -38,8 +55,5 @@ before_script: - bench start & - sleep 10 -script: - - bash $TRAVIS_BUILD_DIR/travis/run-tests.sh - after_script: - coveralls -b apps/erpnext -d ../../sites/.coverage diff --git a/travis/run-tests.sh b/travis/run-tests.sh deleted file mode 100755 index 7cfd64833b..0000000000 --- a/travis/run-tests.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -e - -if [[ $TEST_TYPE == 'Server Side Test' ]]; then - bench run-tests --app erpnext --coverage - -elif [[ $TEST_TYPE == 'Patch Test' ]]; then - wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz - bench --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz --mariadb-root-password travis - bench migrate -fi From 828699f26a29cd5e4af29b86b6eb10755aed2985 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:09:34 +0530 Subject: [PATCH 03/28] fix(travis): Use MariaDB 10.3 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0660779b2d..1561d6ca0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,8 @@ dist: trusty language: python -services: - - mysql +addons: + mariadb: 10.3 jobs: include: From c49d45497c86e0bc16c72494c055e63d0d292e1d Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:10:06 +0530 Subject: [PATCH 04/28] fix(travis): Install coverall after tests --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1561d6ca0f..c51c6b078e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,9 +30,7 @@ jobs: script: bench migrate install: - # fix mongodb travis error - nvm install 10 - - pip install python-coveralls - wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py - sudo python install.py --develop --user travis --without-bench-setup - sudo pip install -e ~/bench @@ -56,4 +54,5 @@ before_script: - sleep 10 after_script: + - pip install python-coveralls - coveralls -b apps/erpnext -d ../../sites/.coverage From 306a410b773ed9e7ffc426576630dc427dabae67 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:11:18 +0530 Subject: [PATCH 05/28] fix(travis): Do not execute install.py --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c51c6b078e..047a98640f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,10 +30,11 @@ jobs: script: bench migrate install: + - cd ~ - nvm install 10 - - wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py - - sudo python install.py --develop --user travis --without-bench-setup - - sudo pip install -e ~/bench + + - git clone https://github.com/frappe/bench --depth 1 + - pip install -e ./bench - rm $TRAVIS_BUILD_DIR/.git/shallow - bash $TRAVIS_BUILD_DIR/travis/bench_init.sh From ac185989ff9b41fe9abede23757163af4d4ea79e Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:15:30 +0530 Subject: [PATCH 06/28] fix(travis): Remove travis/bench_init.sh --- .travis.yml | 5 +++-- travis/bench_init.sh | 8 -------- 2 files changed, 3 insertions(+), 10 deletions(-) delete mode 100755 travis/bench_init.sh diff --git a/.travis.yml b/.travis.yml index 047a98640f..e0a2ead3d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,8 +36,9 @@ install: - git clone https://github.com/frappe/bench --depth 1 - pip install -e ./bench - - rm $TRAVIS_BUILD_DIR/.git/shallow - - bash $TRAVIS_BUILD_DIR/travis/bench_init.sh + - git clone https://github.com/frappe/frappe --branch $TRAVIS_BRANCH --depth 1 + - bench init --frappe-path ~/frappe --python $(which python) frappe-bench + - cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/ before_script: diff --git a/travis/bench_init.sh b/travis/bench_init.sh deleted file mode 100755 index f96269b919..0000000000 --- a/travis/bench_init.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -cd ~/ -curl -I https://github.com/frappe/frappe/tree/$TRAVIS_BRANCH | head -n 1 | cut -d $' ' -f2 | ( - read response; - [ $response == '200' ] && branch=$TRAVIS_BRANCH || branch='develop'; - bench init frappe-bench --frappe-path https://github.com/frappe/frappe.git --frappe-branch $branch --python $(which python) -) From 06ca6f7705675752540b05481056b686bc5c4dfb Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:18:05 +0530 Subject: [PATCH 07/28] fix(travis): Remove unused files --- .travis.yml | 3 ++- {test_sites/test_site => .travis}/site_config.json | 3 +-- test_sites/apps.txt | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) rename {test_sites/test_site => .travis}/site_config.json (81%) delete mode 100644 test_sites/apps.txt diff --git a/.travis.yml b/.travis.yml index e0a2ead3d5..108df91e40 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,8 @@ install: - git clone https://github.com/frappe/frappe --branch $TRAVIS_BRANCH --depth 1 - bench init --frappe-path ~/frappe --python $(which python) frappe-bench - - cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/ + - mkdir ~/frappe-bench/sites/test_site + - cp -r $TRAVIS_BUILD_DIR/.travis/site_config.json ~/frappe-bench/sites/test_site/ before_script: - mysql -u root -ptravis -e 'create database test_frappe' diff --git a/test_sites/test_site/site_config.json b/.travis/site_config.json similarity index 81% rename from test_sites/test_site/site_config.json rename to .travis/site_config.json index 7a4d106508..695f6c3517 100644 --- a/test_sites/test_site/site_config.json +++ b/.travis/site_config.json @@ -6,8 +6,7 @@ "mail_login": "test@example.com", "mail_password": "test", "admin_password": "admin", - "run_selenium_tests": 1, "root_password": "travis", - "host_name": "http://localhost:8000", + "host_name": "http://test_site:8000", "install_apps": ["erpnext"] } \ No newline at end of file diff --git a/test_sites/apps.txt b/test_sites/apps.txt deleted file mode 100644 index ee6454915c..0000000000 --- a/test_sites/apps.txt +++ /dev/null @@ -1 +0,0 @@ -erpnext \ No newline at end of file From 8005022508d9c2fb718449ceb5aa7bcc3aabaca6 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:19:30 +0530 Subject: [PATCH 08/28] fix(travis): Setup MariaDB --- .travis.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 108df91e40..5ecede08e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,9 +43,15 @@ install: - cp -r $TRAVIS_BUILD_DIR/.travis/site_config.json ~/frappe-bench/sites/test_site/ before_script: - - mysql -u root -ptravis -e 'create database test_frappe' - - echo "USE mysql;\nCREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe';\nFLUSH PRIVILEGES;\n" | mysql -u root -ptravis - - echo "USE mysql;\nGRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost';\n" | mysql -u root -ptravis + - mysql -u root -e "SET GLOBAL character_set_server = 'utf8mb4'" + - mysql -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'" + + - mysql -u root -e "CREATE DATABASE test_frappe" + - mysql -u root -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'" + - mysql -u root -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'" + + - mysql -u root -e "UPDATE mysql.user SET Password=PASSWORD('travis') WHERE User='root'" + - mysql -u root -e "FLUSH PRIVILEGES" - cd ~/frappe-bench - bench get-app erpnext $TRAVIS_BUILD_DIR From 6f025e7b4fc5360febaeb09b0af8b65e44c0bfa4 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:21:19 +0530 Subject: [PATCH 09/28] fix(travis): Do not use use_site --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5ecede08e8..9840ad5e15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,31 +3,32 @@ dist: trusty language: python addons: + hosts: test_site mariadb: 10.3 jobs: include: - name: "Python 2.7 Server Side Test" python: 2.7 - script: bench run-tests --app erpnext --coverage + script: bench --site test_site run-tests --app erpnext --coverage - name: "Python 3.6 Server Side Test" python: 3.6 - script: bench run-tests --app erpnext --coverage + script: bench --site test_site run-tests --app erpnext --coverage - name: "Python 2.7 Patch Test" python: 2.7 before_script: - wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz - bench --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz --mariadb-root-password travis - script: bench migrate + script: bench --site test_site migrate - name: "Python 3.6 Patch Test" python: 3.6 before_script: - wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz - - bench --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz --mariadb-root-password travis - script: bench migrate + - bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz --mariadb-root-password travis + script: bench --site test_site migrate install: - cd ~ @@ -55,9 +56,8 @@ before_script: - cd ~/frappe-bench - bench get-app erpnext $TRAVIS_BUILD_DIR - - bench use test_site - - bench reinstall --mariadb-root-username root --mariadb-root-password travis --yes - - bench scheduler disable + - bench --site test_site reinstall --mariadb-root-username root --mariadb-root-password travis --yes + - bench --site test_site scheduler disable - sed -i 's/9000/9001/g' sites/common_site_config.json - bench start & - sleep 10 From 6e2fa02c56bdfca84c2505abaeb4a6eaf36b1a51 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:21:54 +0530 Subject: [PATCH 10/28] fix(travis): Do not disable scheduler using CLI --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9840ad5e15..cd593a8aed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,7 +57,6 @@ before_script: - cd ~/frappe-bench - bench get-app erpnext $TRAVIS_BUILD_DIR - bench --site test_site reinstall --mariadb-root-username root --mariadb-root-password travis --yes - - bench --site test_site scheduler disable - sed -i 's/9000/9001/g' sites/common_site_config.json - bench start & - sleep 10 From 97ad6352afe91febc06b5daf2d6385a8ead5cd11 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:23:24 +0530 Subject: [PATCH 11/28] fix(travis): Execute get-app and reinstall after bench start --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd593a8aed..d3581e2b8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,11 +55,11 @@ before_script: - mysql -u root -e "FLUSH PRIVILEGES" - cd ~/frappe-bench - - bench get-app erpnext $TRAVIS_BUILD_DIR - - bench --site test_site reinstall --mariadb-root-username root --mariadb-root-password travis --yes - sed -i 's/9000/9001/g' sites/common_site_config.json - bench start & - sleep 10 + - bench get-app erpnext $TRAVIS_BUILD_DIR + - bench --site test_site reinstall --mariadb-root-username root --mariadb-root-password travis --yes after_script: - pip install python-coveralls From 6f978d2497553ce78c89aaf701e505a8582e4233 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:23:43 +0530 Subject: [PATCH 12/28] perf(travis): Do not waste 10 seconds --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d3581e2b8d..23627f51f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,7 +57,6 @@ before_script: - cd ~/frappe-bench - sed -i 's/9000/9001/g' sites/common_site_config.json - bench start & - - sleep 10 - bench get-app erpnext $TRAVIS_BUILD_DIR - bench --site test_site reinstall --mariadb-root-username root --mariadb-root-password travis --yes From 543996652baae9e992d21f28b63c79d397c8647f Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:25:53 +0530 Subject: [PATCH 13/28] fix(travis): Use MariaDB credentials from site_config.json --- .travis.yml | 2 +- .travis/site_config.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 23627f51f0..54d77db7c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,7 +58,7 @@ before_script: - sed -i 's/9000/9001/g' sites/common_site_config.json - bench start & - bench get-app erpnext $TRAVIS_BUILD_DIR - - bench --site test_site reinstall --mariadb-root-username root --mariadb-root-password travis --yes + - bench --site test_site reinstall --yes after_script: - pip install python-coveralls diff --git a/.travis/site_config.json b/.travis/site_config.json index 695f6c3517..dae80095d4 100644 --- a/.travis/site_config.json +++ b/.travis/site_config.json @@ -6,6 +6,7 @@ "mail_login": "test@example.com", "mail_password": "test", "admin_password": "admin", + "root_login": "root", "root_password": "travis", "host_name": "http://test_site:8000", "install_apps": ["erpnext"] From 13919440a7afdce366e38925e3638eab71b00d78 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:27:20 +0530 Subject: [PATCH 14/28] perf(travis): Remove unnecessary processes from Procfile --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 54d77db7c6..2637d978e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,7 +55,12 @@ before_script: - mysql -u root -e "FLUSH PRIVILEGES" - cd ~/frappe-bench - - sed -i 's/9000/9001/g' sites/common_site_config.json + + - sed -i 's/watch:/# watch:/g' Procfile + - sed -i 's/schedule:/# schedule:/g' Procfile + - sed -i 's/socketio:/# socketio:/g' Procfile + - sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile + - bench start & - bench get-app erpnext $TRAVIS_BUILD_DIR - bench --site test_site reinstall --yes From 1de45877b116ed33bbdf55222c2e4e1da63ea709 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:28:15 +0530 Subject: [PATCH 15/28] perf(travis): Do not build assets --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2637d978e4..e3d432a5ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ install: - pip install -e ./bench - git clone https://github.com/frappe/frappe --branch $TRAVIS_BRANCH --depth 1 - - bench init --frappe-path ~/frappe --python $(which python) frappe-bench + - bench init --skip-assets --frappe-path ~/frappe --python $(which python) frappe-bench - mkdir ~/frappe-bench/sites/test_site - cp -r $TRAVIS_BUILD_DIR/.travis/site_config.json ~/frappe-bench/sites/test_site/ From 5542af9be8af5f5397a771ad7086fcc59755de12 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:36:22 +0530 Subject: [PATCH 16/28] perf(travis): Use travis optimizations --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index e3d432a5ae..ee385d0e08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,12 @@ dist: trusty language: python +git: + depth: 1 + +cache: + - pip + addons: hosts: test_site mariadb: 10.3 From 4b680178be72dd0ce129ba5e771184c21db0c273 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:38:07 +0530 Subject: [PATCH 17/28] fix(travis): Execute get-app before bench start --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ee385d0e08..2f7637372e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,8 +67,8 @@ before_script: - sed -i 's/socketio:/# socketio:/g' Procfile - sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile - - bench start & - bench get-app erpnext $TRAVIS_BUILD_DIR + - bench start & - bench --site test_site reinstall --yes after_script: From 6002fd7820c08c7a75b1d7560ef01229ab9dd6f7 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:39:30 +0530 Subject: [PATCH 18/28] fix(travis): Merge install and before_script --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2f7637372e..fb941f3ff3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,7 +49,6 @@ install: - mkdir ~/frappe-bench/sites/test_site - cp -r $TRAVIS_BUILD_DIR/.travis/site_config.json ~/frappe-bench/sites/test_site/ -before_script: - mysql -u root -e "SET GLOBAL character_set_server = 'utf8mb4'" - mysql -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'" From dac46ed6e1278fed1274ab14d336fbaef0091283 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:50:46 +0530 Subject: [PATCH 19/28] fix(travis): Use --site parameter --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fb941f3ff3..9b51c85eca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ jobs: python: 2.7 before_script: - wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz - - bench --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz --mariadb-root-password travis + - bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz --mariadb-root-password travis script: bench --site test_site migrate - name: "Python 3.6 Patch Test" From fdb395c9776459aa7e48580f55a5bf800cb94f74 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 21:51:12 +0530 Subject: [PATCH 20/28] fix(travis): Remove redundant arguments --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9b51c85eca..53c67fe15d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,14 +26,14 @@ jobs: python: 2.7 before_script: - 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 --mariadb-root-password travis + - bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz script: bench --site test_site migrate - name: "Python 3.6 Patch Test" python: 3.6 before_script: - 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 --mariadb-root-password travis + - bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz script: bench --site test_site migrate install: From a630a24040f039fae82f65741895c96b3ef09fe9 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 22:40:26 +0530 Subject: [PATCH 21/28] fix(travis): Install wkhtmltopdf --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 53c67fe15d..40afeee8d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,6 +59,11 @@ install: - mysql -u root -e "UPDATE mysql.user SET Password=PASSWORD('travis') WHERE User='root'" - mysql -u root -e "FLUSH PRIVILEGES" + - wget -O /tmp/wkhtmltox.tar.xz https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz + - tar -xf /tmp/wkhtmltox.tar.xz -C /tmp + - sudo mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf + - sudo chmod o+x /usr/local/bin/wkhtmltopdf + - cd ~/frappe-bench - sed -i 's/watch:/# watch:/g' Procfile From 6a5b7f751cd8c2cb4b335c683e69bd7cff102f2e Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 25 Jul 2019 23:37:43 +0530 Subject: [PATCH 22/28] perf(tests): Use setUpClass and tearDownClass instead of setUp and tearDown --- .../doctype/purchase_invoice/test_purchase_invoice.py | 7 +++++-- .../accounts/doctype/sales_invoice/test_sales_invoice.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index b4d584fbde..6deee38148 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -20,11 +20,13 @@ test_dependencies = ["Item", "Cost Center", "Payment Term", "Payment Terms Templ test_ignore = ["Serial No"] class TestPurchaseInvoice(unittest.TestCase): - def setUp(self): + @classmethod + def setUpClass(self): unlink_payment_on_cancel_of_invoice() frappe.db.set_value("Buying Settings", None, "allow_multiple_items", 1) - def tearDown(self): + @classmethod + def tearDownClass(self): unlink_payment_on_cancel_of_invoice(0) def test_gl_entries_without_perpetual_inventory(self): @@ -91,6 +93,7 @@ class TestPurchaseInvoice(unittest.TestCase): pi_doc = frappe.get_doc('Purchase Invoice', pi_doc.name) self.assertRaises(frappe.LinkExistsError, pi_doc.cancel) + unlink_payment_on_cancel_of_invoice() def test_purchase_invoice_for_blocked_supplier(self): supplier = frappe.get_doc('Supplier', '_Test Supplier') diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 52470fde95..dff55947df 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -29,10 +29,12 @@ class TestSalesInvoice(unittest.TestCase): w.submit() return w - def setUp(self): + @classmethod + def setUpClass(self): unlink_payment_on_cancel_of_invoice() - def tearDown(self): + @classmethod + def tearDownClass(self): unlink_payment_on_cancel_of_invoice(0) def test_timestamp_change(self): @@ -135,6 +137,7 @@ class TestSalesInvoice(unittest.TestCase): unlink_payment_on_cancel_of_invoice(0) si = frappe.get_doc('Sales Invoice', si.name) self.assertRaises(frappe.LinkExistsError, si.cancel) + unlink_payment_on_cancel_of_invoice() def test_sales_invoice_calculation_export_currency(self): si = frappe.copy_doc(test_records[2]) From 0ae786adec215f25fd60f20b11b7ff8503322eae Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Fri, 26 Jul 2019 00:38:51 +0530 Subject: [PATCH 23/28] perf(tests): Do not unnecessarily create companies --- erpnext/tests/test_notifications.py | 44 ++++++++++------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/erpnext/tests/test_notifications.py b/erpnext/tests/test_notifications.py index 596bc80dee..1fd90beef0 100644 --- a/erpnext/tests/test_notifications.py +++ b/erpnext/tests/test_notifications.py @@ -2,45 +2,31 @@ # MIT License. See license.txt from __future__ import unicode_literals +import frappe import unittest from frappe.desk import notifications from frappe.test_runner import make_test_objects class TestNotifications(unittest.TestCase): - def setUp(self): - test_records_company = [ - { - "abbr": "_TC6", - "company_name": "_Test Company 6", - "country": "India", - "default_currency": "INR", - "doctype": "Company", - "domain": "Manufacturing", - "monthly_sales_target": 2000, - "chart_of_accounts": "Standard" - }, - { - "abbr": "_TC7", - "company_name": "_Test Company 7", - "country": "United States", - "default_currency": "USD", - "doctype": "Company", - "domain": "Retail", - "monthly_sales_target": 10000, - "total_monthly_sales": 1000, - "chart_of_accounts": "Standard" - }, - ] - - make_test_objects('Company', test_records=test_records_company, reset=True) - def test_get_notifications_for_targets(self): ''' Test notification config entries for targets as percentages ''' + company = frappe.get_all("Company")[0] + frappe.db.set_value("Company", company.name, "monthly_sales_target", 10000) + frappe.db.set_value("Company", company.name, "total_monthly_sales", 1000) + config = notifications.get_notification_config() doc_target_percents = notifications.get_notifications_for_targets(config, {}) - self.assertEqual(doc_target_percents['Company']['_Test Company 7'], 10) - self.assertEqual(doc_target_percents['Company']['_Test Company 6'], 0) + + self.assertEqual(doc_target_percents['Company'][company.name], 10) + + frappe.db.set_value("Company", company.name, "monthly_sales_target", 2000) + frappe.db.set_value("Company", company.name, "total_monthly_sales", 0) + + config = notifications.get_notification_config() + doc_target_percents = notifications.get_notifications_for_targets(config, {}) + + self.assertEqual(doc_target_percents['Company'][company.name], 0) From 0f072d7d40ff820ebd237a02b96e81f629661854 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Fri, 26 Jul 2019 01:09:01 +0530 Subject: [PATCH 24/28] perf(tests): Use country with lesser fixtures --- .../report/procurement_tracker/test_procurement_tracker.py | 2 +- erpnext/hr/doctype/staffing_plan/test_staffing_plan.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py index 4a13f385bb..bebf0ccec5 100644 --- a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py +++ b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py @@ -30,7 +30,7 @@ class TestProcurementTracker(unittest.TestCase): company_name="_Test Procurement Company", abbr="_TPC", default_currency="INR", - country="India" + country="Pakistan" )).insert() warehouse = create_warehouse("_Test Procurement Warehouse", company="_Test Procurement Company") mr = make_material_request(company="_Test Procurement Company", warehouse=warehouse) diff --git a/erpnext/hr/doctype/staffing_plan/test_staffing_plan.py b/erpnext/hr/doctype/staffing_plan/test_staffing_plan.py index 4a0ce1800a..9ba6d5e63f 100644 --- a/erpnext/hr/doctype/staffing_plan/test_staffing_plan.py +++ b/erpnext/hr/doctype/staffing_plan/test_staffing_plan.py @@ -92,5 +92,5 @@ def make_company(): company.abbr = "_TC10" company.parent_company = "_Test Company" company.default_currency = "INR" - company.country = "India" + company.country = "Pakistan" company.insert() \ No newline at end of file From 6bc2988623a273eeb8379719c31bdf22b0164def Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Fri, 26 Jul 2019 03:05:40 +0530 Subject: [PATCH 25/28] fix(stock): Fix travis builds --- .../stock/doctype/stock_reconciliation/stock_reconciliation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index d9e62c7931..98a8c59483 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -327,7 +327,8 @@ class StockReconciliation(StockController): if sl_entries: sl_entries.reverse() - self.make_sl_entries(sl_entries) + allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock") + self.make_sl_entries(sl_entries, allow_negative_stock=allow_negative_stock) # repost future entries for selected item_code, warehouse for entries in existing_entries: From ff79463e36cf4ebbe751dc356f7075f22265ac42 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Fri, 26 Jul 2019 03:06:23 +0530 Subject: [PATCH 26/28] perf(travis): Use setUpClass instead of setUp --- .../test_stock_reconciliation.py | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py index f0c71cf39a..ededc4d8b4 100644 --- a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py @@ -17,10 +17,11 @@ from erpnext.stock.utils import get_stock_balance, get_incoming_rate, get_availa from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos class TestStockReconciliation(unittest.TestCase): - def setUp(self): + @classmethod + def setUpClass(self): create_batch_or_serial_no_items() frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1) - self.insert_existing_sle() + insert_existing_sle() def test_reco_for_fifo(self): self._test_reco_sle_gle("FIFO") @@ -97,18 +98,6 @@ class TestStockReconciliation(unittest.TestCase): self.assertEqual(["_Test Stock Reco Item", "_Test Warehouse Ledger 1 - _TC", 100], [items[0]["item_code"], items[0]["warehouse"], items[0]["qty"]]) - def insert_existing_sle(self): - from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry - - make_stock_entry(posting_date="2012-12-15", posting_time="02:00", item_code="_Test Item", - target="_Test Warehouse - _TC", qty=10, basic_rate=700) - - make_stock_entry(posting_date="2012-12-25", posting_time="03:00", item_code="_Test Item", - source="_Test Warehouse - _TC", qty=15) - - make_stock_entry(posting_date="2013-01-05", posting_time="07:00", item_code="_Test Item", - target="_Test Warehouse - _TC", qty=15, basic_rate=1200) - def test_stock_reco_for_serialized_item(self): set_perpetual_inventory() @@ -218,6 +207,18 @@ class TestStockReconciliation(unittest.TestCase): for d in to_delete_records: frappe.delete_doc("Stock Reconciliation", d) +def insert_existing_sle(): + from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry + + make_stock_entry(posting_date="2012-12-15", posting_time="02:00", item_code="_Test Item", + target="_Test Warehouse - _TC", qty=10, basic_rate=700) + + make_stock_entry(posting_date="2012-12-25", posting_time="03:00", item_code="_Test Item", + source="_Test Warehouse - _TC", qty=15) + + make_stock_entry(posting_date="2013-01-05", posting_time="07:00", item_code="_Test Item", + target="_Test Warehouse - _TC", qty=15, basic_rate=1200) + def create_batch_or_serial_no_items(): create_warehouse("_Test Warehouse for Stock Reco1", {"is_group": 0, "parent_warehouse": "_Test Warehouse Group - _TC"}) From 1e82638ae894da7e4b922985e476d522e6a6bb4b Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Fri, 26 Jul 2019 03:51:45 +0530 Subject: [PATCH 27/28] perf(tests): Remove unnecessary tearDown code --- .../doctype/stock_settings/test_stock_settings.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/erpnext/stock/doctype/stock_settings/test_stock_settings.py b/erpnext/stock/doctype/stock_settings/test_stock_settings.py index 1e83ec2f49..42a78f723d 100644 --- a/erpnext/stock/doctype/stock_settings/test_stock_settings.py +++ b/erpnext/stock/doctype/stock_settings/test_stock_settings.py @@ -8,16 +8,7 @@ import unittest class TestStockSettings(unittest.TestCase): def setUp(self): - settings = frappe.get_single('Stock Settings') - settings.clean_description_html = 0 - settings.save() - - frappe.delete_doc('Item', 'Item for description test') - - def tearDown(self): - settings = frappe.get_single('Stock Settings') - settings.clean_description_html = 1 - settings.save() + frappe.db.set_value("Stock Settings", None, "clean_description_html", 0) def test_settings(self): item = frappe.get_doc(dict( From 96eec7e2cd01885a91dbbc2fff20ae5830055e43 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Fri, 26 Jul 2019 05:06:42 +0530 Subject: [PATCH 28/28] chore: Empty commit