[Minor] Fix Crop Cycle test record (#14901)

* fix crop cycle test record

* load crop cycle doc if not yet loaded

* create test records for location

* land unit -> location , update in patch for tree index
This commit is contained in:
Zarrar 2018-07-15 20:04:24 +05:30 committed by Nabin Hait
parent 03b597418a
commit f579a2bd5d
5 changed files with 12 additions and 8 deletions

View File

@ -2,8 +2,8 @@
{ {
"doctype": "Crop Cycle", "doctype": "Crop Cycle",
"title": "Basil from seed 2017", "title": "Basil from seed 2017",
"linked_land_unit": [{ "linked_location": [{
"land_unit": "Basil Farm" "location": "Basil Farm"
}], }],
"crop": "Basil from seed", "crop": "Basil from seed",
"start_date": "2017-11-11", "start_date": "2017-11-11",

View File

@ -8,6 +8,7 @@ import unittest
import frappe import frappe
test_records = frappe.get_test_records('Location')
class TestLocation(unittest.TestCase): class TestLocation(unittest.TestCase):
def runTest(self): def runTest(self):
@ -25,7 +26,7 @@ class TestLocation(unittest.TestCase):
formatted_locations.extend(temp['features']) formatted_locations.extend(temp['features'])
formatted_location_string = str(formatted_locations) formatted_location_string = str(formatted_locations)
test_location = frappe.get_doc('Location', 'Test Location') test_location = frappe.get_doc('Location', 'Test Location Area')
self.assertEqual(formatted_location_string, str(json.loads(test_location.get('location'))['features'])) self.assertEqual(formatted_location_string, str(json.loads(test_location.get('location'))['features']))
self.assertEqual(area, test_location.get('area')) self.assertEqual(area, test_location.get('area'))

View File

@ -1,7 +1,7 @@
[ [
{ {
"doctype": "Location", "doctype": "Location",
"location_name": "Test Location", "location_name": "Test Location Area",
"is_group": 1, "is_group": 1,
"is_container": 1 "is_container": 1
}, },
@ -9,8 +9,8 @@
"doctype": "Location", "doctype": "Location",
"location_name": "Basil Farm", "location_name": "Basil Farm",
"location": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"point_type\":\"circle\",\"radius\":884.5625420736483},\"geometry\":{\"type\":\"Point\",\"coordinates\":[72.875834,19.100566]}}]}", "location": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"point_type\":\"circle\",\"radius\":884.5625420736483},\"geometry\":{\"type\":\"Point\",\"coordinates\":[72.875834,19.100566]}}]}",
"parent_location": "Test Location", "parent_location": "Test Location Area",
"parent": "Test Location", "parent": "Test Location Area",
"is_group": 1, "is_group": 1,
"is_container": 1 "is_container": 1
}, },

View File

@ -4,7 +4,7 @@
import frappe import frappe
def execute(): def execute():
frappe.reload_doc("agriculture", "doctype", "land_unit") frappe.reload_doc("agriculture", "doctype", "Location")
for dt in ("Account", "Cost Center", "File", "Employee", "Land Unit", "Task", "Customer Group", "Sales Person", "Territory"): for dt in ("Account", "Cost Center", "File", "Employee", "Location", "Task", "Customer Group", "Sales Person", "Territory"):
frappe.reload_doctype(dt) frappe.reload_doctype(dt)
frappe.get_doc("DocType", dt).run_module_method("on_doctype_update") frappe.get_doc("DocType", dt).run_module_method("on_doctype_update")

View File

@ -20,6 +20,9 @@ def execute():
frappe.reload_doc('assets', 'doctype', 'linked_location') frappe.reload_doc('assets', 'doctype', 'linked_location')
if not frappe.db.table_exists('Crop Cycle'):
frappe.reload_doc('agriculture', 'doctype', 'crop_cycle')
# Rename the fields in related doctypes # Rename the fields in related doctypes
if 'linked_land_unit' in frappe.db.get_table_columns('Crop Cycle'): if 'linked_land_unit' in frappe.db.get_table_columns('Crop Cycle'):
rename_field('Crop Cycle', 'linked_land_unit', 'linked_location') rename_field('Crop Cycle', 'linked_land_unit', 'linked_location')