started client side testing using selenium and other related and unrelated fixes

This commit is contained in:
Rushabh Mehta 2014-04-30 19:38:28 +05:30
parent b85a9108eb
commit a15164750d
18 changed files with 176 additions and 180 deletions

View File

@ -19,12 +19,12 @@ install:
script:
cd ./test_sites/ &&
frappe --reinstall test_site &&
frappe --install_app erpnext test_site --verbose &&
frappe --request '?cmd=erpnext.setup.page.setup_wizard.setup_wizard.setup_account&currency=USD&first_name=Test&last_name=User&company_name=Wind+Power+LLC&timezone=America/New_York&company_abbr=WP&industry=Manufacturing&country=United States&fy_start_date=2014-01-01&fy_end_date=2014-12-31&language=english&company_tagline=Testing&email=test@erpnext.com&password=test' test_site &&
frappe --verbose --run_tests test_site --app erpnext
frappe --use test_site &&
frappe --reinstall &&
frappe --install_app erpnext --verbose &&
frappe --verbose --run_tests --app erpnext
before_script:
- mysql -e 'create database travis' &&
- echo "USE mysql;\nUPDATE user SET password=PASSWORD('travis') WHERE user='travis';\nFLUSH PRIVILEGES;\n" | mysql -u root
- mysql -e 'create database test_site' &&
- echo "USE mysql;\nUPDATE user SET password=PASSWORD('test_site') WHERE user='test_site';\nFLUSH PRIVILEGES;\n" | mysql -u root

View File

@ -33,7 +33,6 @@ class Account(Document):
def validate(self):
self.validate_master_name()
self.validate_parent()
self.validate_duplicate_account()
self.validate_root_details()
self.validate_mandatory()
self.validate_warehouse_account()
@ -61,12 +60,6 @@ class Account(Document):
if par["report_type"]:
self.report_type = par["report_type"]
def validate_duplicate_account(self):
if self.get('__islocal') or not self.name:
company_abbr = frappe.db.get_value("Company", self.company, "abbr")
if frappe.db.exists("Account", (self.account_name + " - " + company_abbr)):
throw(_("Account {0} already exists").format(self.account_name))
def validate_root_details(self):
#does not exists parent
if frappe.db.exists("Account", self.name):

View File

@ -61,15 +61,6 @@ class CostCenter(NestedSet):
check_acc_list.append([d.account, d.fiscal_year])
def validate(self):
"""
Cost Center name must be unique
"""
if ((self.get("__islocal") or not self.name) and
frappe.db.sql("select name from `tabCost Center` where cost_center_name=%s and company=%s",
(self.cost_center_name, self.company))
):
msgprint(_("Cost Center Name already exists"), raise_exception=1)
self.validate_mandatory()
self.validate_budget_details()

View File

@ -8,7 +8,7 @@
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"income_account": "Sales - _TC",
"name": "_Test POS Setting",
"naming_series": "_T-Sales Invoice-",
"naming_series": "_T-POS Setting-",
"selling_price_list": "_Test Price List",
"territory": "_Test Territory",
"warehouse": "_Test Warehouse - _TC"

View File

@ -21,6 +21,7 @@ update_website_context = erpnext.startup.webutils.update_website_context
mail_footer = erpnext.startup.mail_footer
on_session_creation = erpnext.startup.event_handlers.on_session_creation
before_tests = erpnext.setup.utils.before_tests
# Bean Events
# -------------------------

View File

@ -1,62 +1,37 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
// ****************************************** onload ********************************************************
cur_frm.cscript.onload = function(doc, dt, dn) {
if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
}
// ************************************** client triggers ***************************************************
// ---------
// employee
// ---------
cur_frm.add_fetch('employee','employee_name','employee_name');
cur_frm.cscript.employee = function(doc, dt, dn) {
calculate_total_leaves_allocated(doc, dt, dn);
}
// -----------
// leave type
// -----------
cur_frm.cscript.leave_type = function(doc, dt, dn) {
calculate_total_leaves_allocated(doc, dt, dn);
}
// ------------
// fiscal year
// ------------
cur_frm.cscript.fiscal_year = function(doc, dt, dn) {
calculate_total_leaves_allocated(doc, dt, dn);
}
// -------------------------------
// include previous leave balance
// -------------------------------
cur_frm.cscript.carry_forward = function(doc, dt, dn) {
calculate_total_leaves_allocated(doc, dt, dn);
}
// -----------------------
// previous balance leaves
// -----------------------
cur_frm.cscript.carry_forwarded_leaves = function(doc, dt, dn) {
set_multiple(dt,dn,{total_leaves_allocated : flt(doc.carry_forwarded_leaves)+flt(doc.new_leaves_allocated)});
}
// ---------------------
// new leaves allocated
// ---------------------
cur_frm.cscript.new_leaves_allocated = function(doc, dt, dn) {
set_multiple(dt,dn,{total_leaves_allocated : flt(doc.carry_forwarded_leaves)+flt(doc.new_leaves_allocated)});
}
// ****************************************** utilities ******************************************************
// ---------------------------------
// calculate total leaves allocated
// ---------------------------------
calculate_total_leaves_allocated = function(doc, dt, dn) {
if(cint(doc.carry_forward) == 1 && doc.leave_type && doc.fiscal_year && doc.employee){
return get_server_fields('get_carry_forwarded_leaves','','', doc, dt, dn, 1);

View File

@ -0,0 +1,3 @@
import frappe
test_records = frappe.get_test_records('Leave Allocation')

View File

@ -0,0 +1,18 @@
[
{
"docstatus": 1,
"doctype": "Leave Allocation",
"employee": "_T-Employee-0001",
"fiscal_year": "_Test Fiscal Year 2013",
"leave_type": "_Test Leave Type",
"new_leaves_allocated": 15
},
{
"docstatus": 1,
"doctype": "Leave Allocation",
"employee": "_T-Employee-0002",
"fiscal_year": "_Test Fiscal Year 2013",
"leave_type": "_Test Leave Type",
"new_leaves_allocated": 15
}
]

View File

@ -6,6 +6,42 @@ import unittest
from erpnext.hr.doctype.leave_application.leave_application import LeaveDayBlockedError, OverlapError
test_dependencies = ["Leave Allocation", "Leave Block List"]
_test_records = [
{
"company": "_Test Company",
"doctype": "Leave Application",
"employee": "_T-Employee-0001",
"fiscal_year": "_Test Fiscal Year 2013",
"from_date": "2013-05-01",
"leave_type": "_Test Leave Type",
"posting_date": "2013-01-02",
"to_date": "2013-05-05"
},
{
"company": "_Test Company",
"doctype": "Leave Application",
"employee": "_T-Employee-0002",
"fiscal_year": "_Test Fiscal Year 2013",
"from_date": "2013-05-01",
"leave_type": "_Test Leave Type",
"posting_date": "2013-01-02",
"to_date": "2013-05-05"
},
{
"company": "_Test Company",
"doctype": "Leave Application",
"employee": "_T-Employee-0001",
"fiscal_year": "_Test Fiscal Year 2013",
"from_date": "2013-01-15",
"leave_type": "_Test Leave Type LWP",
"posting_date": "2013-01-02",
"to_date": "2013-01-15"
}
]
class TestLeaveApplication(unittest.TestCase):
def tearDown(self):
frappe.set_user("Administrator")
@ -46,7 +82,7 @@ class TestLeaveApplication(unittest.TestCase):
frappe.db.set_value("Department", "_Test Department",
"leave_block_list", "_Test Leave Block List")
application = self.get_application(test_records[1])
application = self.get_application(_test_records[0])
application.insert()
application.status = "Approved"
self.assertRaises(LeaveDayBlockedError, application.submit)
@ -56,7 +92,7 @@ class TestLeaveApplication(unittest.TestCase):
# clear other applications
frappe.db.sql("delete from `tabLeave Application`")
application = self.get_application(test_records[1])
application = self.get_application(_test_records[0])
self.assertTrue(application.insert())
def test_overlap(self):
@ -68,11 +104,11 @@ class TestLeaveApplication(unittest.TestCase):
add_role("test2@example.com", "Leave Approver")
frappe.set_user("test@example.com")
application = self.get_application(test_records[1])
application = self.get_application(_test_records[0])
application.leave_approver = "test2@example.com"
application.insert()
application = self.get_application(test_records[1])
application = self.get_application(_test_records[0])
application.leave_approver = "test2@example.com"
self.assertRaises(OverlapError, application.insert)
@ -82,8 +118,9 @@ class TestLeaveApplication(unittest.TestCase):
from frappe.utils.user import add_role
add_role("test1@example.com", "Employee")
add_role("test@example.com", "Leave Approver")
add_role("test@example.com", "HR Manager")
application = self.get_application(test_records[3])
application = self.get_application(_test_records[1])
application.leave_approver = "test@example.com"
frappe.db.set_value("Leave Block List", "_Test Leave Block List",
@ -119,7 +156,7 @@ class TestLeaveApplication(unittest.TestCase):
# create leave application as Employee
frappe.set_user("test@example.com")
application = self.get_application(test_records[1])
application = self.get_application(_test_records[0])
application.leave_approver = "test1@example.com"
application.insert()
@ -140,7 +177,7 @@ class TestLeaveApplication(unittest.TestCase):
self._add_employee_leave_approver("_T-Employee-0001", "test2@example.com")
# TODO - add test2@example.com leave approver in employee's leave approvers list
application = self.get_application(test_records[1])
application = self.get_application(_test_records[0])
frappe.set_user("test@example.com")
application.leave_approver = "test1@example.com"
@ -156,7 +193,7 @@ class TestLeaveApplication(unittest.TestCase):
# create leave application as employee
# but submit as invalid leave approver - should raise exception
frappe.set_user("test@example.com")
application = self.get_application(test_records[1])
application = self.get_application(_test_records[0])
application.leave_approver = "test2@example.com"
application.insert()
frappe.set_user("test1@example.com")
@ -176,7 +213,7 @@ class TestLeaveApplication(unittest.TestCase):
frappe.db.set_value("Employee", "_T-Employee-0001", "department", None)
frappe.set_user("test@example.com")
application = self.get_application(test_records[1])
application = self.get_application(_test_records[0])
application.leave_approver = "test2@example.com"
application.insert()
@ -191,7 +228,3 @@ class TestLeaveApplication(unittest.TestCase):
"_T-Employee-0001")
frappe.db.set_value("Employee", "_T-Employee-0001", "department", original_department)
test_dependencies = ["Leave Block List"]
test_records = frappe.get_test_records('Leave Application')

View File

@ -1,48 +0,0 @@
[
{
"docstatus": 1,
"doctype": "Leave Allocation",
"employee": "_T-Employee-0001",
"fiscal_year": "_Test Fiscal Year 2013",
"leave_type": "_Test Leave Type",
"new_leaves_allocated": 15
},
{
"company": "_Test Company",
"doctype": "Leave Application",
"employee": "_T-Employee-0001",
"fiscal_year": "_Test Fiscal Year 2013",
"from_date": "2013-05-01",
"leave_type": "_Test Leave Type",
"posting_date": "2013-01-02",
"to_date": "2013-05-05"
},
{
"docstatus": 1,
"doctype": "Leave Allocation",
"employee": "_T-Employee-0002",
"fiscal_year": "_Test Fiscal Year 2013",
"leave_type": "_Test Leave Type",
"new_leaves_allocated": 15
},
{
"company": "_Test Company",
"doctype": "Leave Application",
"employee": "_T-Employee-0002",
"fiscal_year": "_Test Fiscal Year 2013",
"from_date": "2013-05-01",
"leave_type": "_Test Leave Type",
"posting_date": "2013-01-02",
"to_date": "2013-05-05"
},
{
"company": "_Test Company",
"doctype": "Leave Application",
"employee": "_T-Employee-0001",
"fiscal_year": "_Test Fiscal Year 2013",
"from_date": "2013-01-15",
"leave_type": "_Test Leave Type LWP",
"posting_date": "2013-01-02",
"to_date": "2013-01-15"
}
]

View File

@ -9,7 +9,7 @@ class TestSalarySlip(unittest.TestCase):
frappe.db.sql("""delete from `tabLeave Application`""")
frappe.db.sql("""delete from `tabSalary Slip`""")
from erpnext.hr.doctype.leave_application.test_leave_application import test_records as leave_applications
la = frappe.copy_doc(leave_applications[4])
la = frappe.copy_doc(leave_applications[2])
la.insert()
la.status = "Approved"
la.submit()

View File

@ -3,8 +3,7 @@
from __future__ import unicode_literals
import frappe
from frappe import _, msgprint, throw
import json
from frappe import _, throw
def get_company_currency(company):
currency = frappe.db.get_value("Company", company, "default_currency")
@ -38,3 +37,30 @@ def get_price_list_currency(price_list):
throw(_("Price List {0} is disabled").format(price_list))
else:
return {"price_list_currency": price_list_currency}
def before_tests():
# complete setup if missing
from erpnext.setup.page.setup_wizard.setup_wizard import setup_account
if not frappe.get_list("Item Group"):
setup_account({
"currency" :"USD",
"first_name" :"Test",
"last_name" :"User",
"company_name" :"Wind Power LLC",
"timezone" :"America/New_York",
"company_abbr" :"WP",
"industry" :"Manufacturing",
"country" :"United States",
"fy_start_date" :"2014-01-01",
"fy_end_date" :"2014-12-31",
"language" :"english",
"company_tagline" :"Testing",
"email" :"test@erpnext.com",
"password" :"test"
})
frappe.db.sql("delete from `tabLeave Allocation`")
frappe.db.sql("delete from `tabLeave Application`")
frappe.db.sql("delete from `tabSalary Slip`")
frappe.db.sql("delete from `tabItem Price`")
frappe.db.commit()

View File

@ -27,6 +27,8 @@ class Item(WebsiteGenerator):
def validate(self):
if not self.stock_uom:
msgprint(_("Please enter default Unit of Measure"), raise_exception=1)
if self.image and not self.website_image:
self.website_image = self.image
self.check_warehouse_is_set_for_stock_item()
self.check_stock_uom_with_bin()
@ -131,6 +133,7 @@ class Item(WebsiteGenerator):
bom = frappe.db.sql("""select name from `tabBOM` where item = %s
and is_active = 1""", (self.name,))
if bom and bom[0][0]:
print self.name
frappe.throw(_("""Allow Bill of Materials should be 'Yes'. Because one or many active BOMs present for this item"""))
def fill_customer_code(self):

View File

@ -190,6 +190,7 @@ class TestStockReconciliation(unittest.TestCase):
})
stock_reco.insert()
stock_reco.submit()
frappe.db.commit()
return stock_reco
def insert_existing_sle(self, valuation_method):

View File

@ -56,7 +56,7 @@ class Warehouse(Document):
ac_doc.ignore_permissions = True
ac_doc.insert()
msgprint(_("Account head {0} created"))
msgprint(_("Account head {0} created").format(ac_doc.name))
def validate_parent_account(self):
if not self.create_account_under:

View File

@ -1,6 +1,6 @@
<div class="col-sm-3">
<div style="height: 120px; overflow: hidden;">
<a href="{{ page_name }}">
<a href="{{ route or page_name }}">
{%- if website_image -%}
<img class="product-image" style="width: 80%; margin: auto;" src="{{ website_image }}">
{%- else -%}

View File

@ -1,7 +1,7 @@
<!-- TODO product listing -->
<div class="container content">
<div style="height: 120px; overflow: hidden;">
<a href="{{ page_name }}">
<a href="{{ route or page_name }}">
{%- if website_image -%}
<img class="product-image" style="width: 80%; margin: auto;" src="{{ website_image }}">
{%- else -%}
@ -10,6 +10,6 @@
</a>
</div>
<div style="height: 100px; overflow: hidden; font-size: 80%;">
<div><a href="{{ page_name }}">{{ item_name }}</a></div>
<div><a href="{{ route or page_name }}">{{ item_name }}</a></div>
</div>
</div>

View File

@ -1,5 +1,5 @@
{
"db_name": "travis",
"db_password": "travis",
"db_name": "test_frappe",
"db_password": "test_frappe",
"mute_emails": 1
}