[tests] update travis.yml to run ui-tests (#9748)
* [tests] update travis.yml to run ui-tests * [tests] update travis.yml to run ui-tests * [test] fix item_group.py * [test] fix item_group.py * [check] daily work summary fails? * [check] daily work summary fails? * [check] daily work summary fails? * [check] daily work summary fails? * [check] daily work summary fails? * [check] daily work summary fails? * [check] no scheduled jobs for tests * [check] daily work summary fails? * [check] daily work summary fails?
This commit is contained in:
parent
f7d2a59c18
commit
4a7b4efbec
50
.travis.yml
50
.travis.yml
@ -1,6 +1,12 @@
|
|||||||
language: python
|
language: python
|
||||||
dist: trusty
|
dist: trusty
|
||||||
group: deprecated-2017Q2
|
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- google-chrome
|
||||||
|
packages:
|
||||||
|
- google-chrome-stable
|
||||||
|
|
||||||
python:
|
python:
|
||||||
- "2.7"
|
- "2.7"
|
||||||
@ -8,43 +14,43 @@ python:
|
|||||||
services:
|
services:
|
||||||
- mysql
|
- mysql
|
||||||
|
|
||||||
before_install:
|
|
||||||
- "export DISPLAY=:99.0"
|
|
||||||
- "sh -e /etc/init.d/xvfb start"
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
- sudo rm /etc/apt/sources.list.d/docker.list
|
||||||
- sudo apt-get purge -y mysql-common mysql-server mysql-client
|
- sudo apt-get purge -y mysql-common mysql-server mysql-client
|
||||||
- nvm install v7.10.0
|
- nvm install v7.10.0
|
||||||
# - wget https://raw.githubusercontent.com/frappe/bench/master/install_scripts/setup_frappe.sh
|
|
||||||
# - sudo bash setup_frappe.sh --skip-setup-bench --mysql-root-password travis --bench-branch develop
|
|
||||||
- wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py
|
- wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py
|
||||||
- sudo python install.py --develop --user travis --without-bench-setup
|
- sudo python install.py --develop --user travis --without-bench-setup
|
||||||
- sudo pip install -e ~/bench
|
- sudo pip install -e ~/bench
|
||||||
|
|
||||||
# - sudo pip install --upgrade pip
|
|
||||||
- rm $TRAVIS_BUILD_DIR/.git/shallow
|
- rm $TRAVIS_BUILD_DIR/.git/shallow
|
||||||
- bash $TRAVIS_BUILD_DIR/travis/bench_init.sh
|
- bash $TRAVIS_BUILD_DIR/travis/bench_init.sh
|
||||||
- cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/
|
- cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/
|
||||||
|
|
||||||
script:
|
before_script:
|
||||||
|
- wget http://chromedriver.storage.googleapis.com/2.27/chromedriver_linux64.zip
|
||||||
|
- unzip chromedriver_linux64.zip
|
||||||
|
- sudo apt-get install libnss3
|
||||||
|
- sudo apt-get --only-upgrade install google-chrome-stable
|
||||||
|
- sudo cp chromedriver /usr/local/bin/.
|
||||||
|
- sudo chmod +x /usr/local/bin/chromedriver
|
||||||
|
- export DISPLAY=:99.0
|
||||||
|
- sh -e /etc/init.d/xvfb start
|
||||||
|
- sleep 3
|
||||||
|
- 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
|
||||||
|
|
||||||
- cd ~/frappe-bench
|
- cd ~/frappe-bench
|
||||||
- bench get-app erpnext $TRAVIS_BUILD_DIR
|
- bench get-app erpnext $TRAVIS_BUILD_DIR
|
||||||
- bench use test_site
|
- bench use test_site
|
||||||
- bench reinstall --yes
|
- bench reinstall --yes
|
||||||
- bench build
|
- bench build
|
||||||
|
- bench scheduler disable
|
||||||
- bench start &
|
- bench start &
|
||||||
- sleep 10
|
- sleep 10
|
||||||
- bench --verbose run-tests --driver Firefox
|
|
||||||
|
|
||||||
before_script:
|
script:
|
||||||
- mysql -u root -ptravis -e 'create database test_frappe'
|
- set -e
|
||||||
- echo "USE mysql;\nCREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe';\nFLUSH PRIVILEGES;\n" | mysql -u root -ptravis
|
- bench --verbose run-tests
|
||||||
- echo "USE mysql;\nGRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost';\n" | mysql -u root -ptravis
|
- sleep 5
|
||||||
|
- bench --verbose run-tests --ui-tests
|
||||||
notifications:
|
|
||||||
webhooks:
|
|
||||||
urls:
|
|
||||||
- https://webhooks.gitter.im/e/92b3bea86d8c5397beef
|
|
||||||
on_success: always
|
|
||||||
on_failure: always
|
|
||||||
on_start: never
|
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Series",
|
"label": "Series",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
@ -88,7 +88,7 @@
|
|||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Opportunity From",
|
"label": "Opportunity From",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
@ -277,8 +277,8 @@
|
|||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 0,
|
||||||
"label": "Opportunity Type",
|
"label": "Opportunity Type",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
@ -310,7 +310,7 @@
|
|||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Status",
|
"label": "Status",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
@ -1189,7 +1189,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2017-06-13 14:29:07.077697",
|
"modified": "2017-07-10 15:29:23.921967",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "CRM",
|
"module": "CRM",
|
||||||
"name": "Opportunity",
|
"name": "Opportunity",
|
||||||
|
@ -12,32 +12,31 @@ import frappe.utils
|
|||||||
|
|
||||||
class TestDailyWorkSummary(unittest.TestCase):
|
class TestDailyWorkSummary(unittest.TestCase):
|
||||||
def test_email_trigger(self):
|
def test_email_trigger(self):
|
||||||
settings, employees, emails = self.setup_and_prepare_test()
|
self.setup_and_prepare_test()
|
||||||
|
for d in self.employees:
|
||||||
for d in employees:
|
|
||||||
# check that email is sent to this employee
|
# check that email is sent to this employee
|
||||||
self.assertTrue(d.user_id in [d.recipient for d in emails
|
self.assertTrue(d.user_id in [d.recipient for d in self.emails
|
||||||
if settings.subject in d.message])
|
if self.settings.subject in d.message])
|
||||||
|
|
||||||
def test_email_trigger_failed(self):
|
def test_email_trigger_failed(self):
|
||||||
hour = '00'
|
hour = '00'
|
||||||
if frappe.utils.nowtime().split(':')[0]=='00':
|
if frappe.utils.nowtime().split(':')[0]=='00':
|
||||||
hour = '01'
|
hour = '01'
|
||||||
|
|
||||||
settings, employees, emails = self.setup_and_prepare_test(hour)
|
self.setup_and_prepare_test(hour)
|
||||||
|
|
||||||
for d in employees:
|
for d in self.employees:
|
||||||
# check that email is sent to this employee
|
# check that email is sent to this employee
|
||||||
self.assertFalse(d.user_id in [d.recipient for d in emails
|
self.assertFalse(d.user_id in [d.recipient for d in self.emails
|
||||||
if settings.subject in d.message])
|
if self.settings.subject in d.message])
|
||||||
|
|
||||||
def test_incoming(self):
|
def test_incoming(self):
|
||||||
settings, employees, emails = self.setup_and_prepare_test()
|
|
||||||
|
|
||||||
# get test mail with message-id as in-reply-to
|
# get test mail with message-id as in-reply-to
|
||||||
|
self.setup_and_prepare_test()
|
||||||
|
|
||||||
with open(os.path.join(os.path.dirname(__file__), "test_data", "test-reply.raw"), "r") as f:
|
with open(os.path.join(os.path.dirname(__file__), "test_data", "test-reply.raw"), "r") as f:
|
||||||
test_mails = [f.read().replace('{{ sender }}', employees[-1].user_id)\
|
test_mails = [f.read().replace('{{ sender }}', self.employees[-1].user_id)\
|
||||||
.replace('{{ message_id }}', emails[-1].message_id)]
|
.replace('{{ message_id }}', self.emails[-1].message_id)]
|
||||||
|
|
||||||
# pull the mail
|
# pull the mail
|
||||||
email_account = frappe.get_doc("Email Account", "_Test Email Account 1")
|
email_account = frappe.get_doc("Email Account", "_Test Email Account 1")
|
||||||
@ -52,30 +51,34 @@ class TestDailyWorkSummary(unittest.TestCase):
|
|||||||
self.assertTrue('I built Daily Work Summary!' in summary)
|
self.assertTrue('I built Daily Work Summary!' in summary)
|
||||||
|
|
||||||
def setup_and_prepare_test(self, hour=None):
|
def setup_and_prepare_test(self, hour=None):
|
||||||
if not hour:
|
|
||||||
hour = frappe.utils.nowtime().split(':')[0]
|
|
||||||
frappe.db.sql('delete from `tabDaily Work Summary`')
|
frappe.db.sql('delete from `tabDaily Work Summary`')
|
||||||
frappe.db.sql('delete from `tabEmail Queue`')
|
frappe.db.sql('delete from `tabEmail Queue`')
|
||||||
frappe.db.sql('delete from `tabEmail Queue Recipient`')
|
frappe.db.sql('delete from `tabEmail Queue Recipient`')
|
||||||
frappe.db.sql('delete from `tabCommunication`')
|
frappe.db.sql('delete from `tabCommunication`')
|
||||||
|
|
||||||
# setup email to trigger at this our
|
self.setup_settings(hour)
|
||||||
settings = frappe.get_doc('Daily Work Summary Settings')
|
|
||||||
settings.companies = []
|
|
||||||
|
|
||||||
settings.append('companies', dict(company='_Test Company',
|
|
||||||
send_emails_at=hour + ':00'))
|
|
||||||
settings.test_subject = 'this is a subject for testing summary emails'
|
|
||||||
settings.save()
|
|
||||||
|
|
||||||
from erpnext.hr.doctype.daily_work_summary_settings.daily_work_summary_settings \
|
from erpnext.hr.doctype.daily_work_summary_settings.daily_work_summary_settings \
|
||||||
import trigger_emails
|
import trigger_emails
|
||||||
trigger_emails()
|
trigger_emails()
|
||||||
|
|
||||||
# check if emails are created
|
# check if emails are created
|
||||||
employees = frappe.get_all('Employee', fields = ['user_id'],
|
self.employees = frappe.get_all('Employee', fields = ['user_id'],
|
||||||
filters=dict(company='_Test Company', status='Active'))
|
filters=dict(company='_Test Company', status='Active', user_id=('!=', 'test@example.com')))
|
||||||
|
|
||||||
emails = frappe.db.sql("""select r.recipient, q.message, q.message_id from `tabEmail Queue` as q, `tabEmail Queue Recipient` as r where q.name = r.parent""", as_dict=1)
|
self.emails = frappe.db.sql("""select r.recipient, q.message, q.message_id from `tabEmail Queue` as q, `tabEmail Queue Recipient` as r where q.name = r.parent""", as_dict=1)
|
||||||
|
|
||||||
|
frappe.db.commit()
|
||||||
|
|
||||||
|
def setup_settings(self, hour=None):
|
||||||
|
# setup email to trigger at this our
|
||||||
|
if not hour:
|
||||||
|
hour = frappe.utils.nowtime().split(':')[0]
|
||||||
|
self.settings = frappe.get_doc('Daily Work Summary Settings')
|
||||||
|
self.settings.companies = []
|
||||||
|
|
||||||
|
self.settings.append('companies', dict(company='_Test Company',
|
||||||
|
send_emails_at=hour + ':00'))
|
||||||
|
self.settings.test_subject = 'this is a subject for testing summary emails'
|
||||||
|
self.settings.save()
|
||||||
|
|
||||||
return settings, employees, emails
|
|
@ -147,7 +147,6 @@ def invalidate_cache_for(doc, item_group=None):
|
|||||||
item_group = doc.name
|
item_group = doc.name
|
||||||
|
|
||||||
for d in get_parent_item_groups(item_group):
|
for d in get_parent_item_groups(item_group):
|
||||||
if frappe.db.exists("Item Group", d.get("name")):
|
item_group_name = frappe.db.get_value("Item Group", d.get('name'))
|
||||||
d = frappe.get_doc("Item Group", d.get("name"))
|
if item_group_name:
|
||||||
if d.route:
|
clear_cache(frappe.db.get_value('Item Group', item_group_name, 'route'))
|
||||||
clear_cache(d.route)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user