<commit_before># Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals

import frappe
import unittest

from frappe.test_runner import make_test_records

test_ignore = ["Price List"]

test_records = frappe.get_test_records('Customer')

class TestCustomer(unittest.TestCase):
	def test_party_details(self):
		from erpnext.accounts.party import get_party_details

		to_check = {
			'selling_price_list': None,
			'customer_group': '_Test Customer Group',
			'contact_designation': None,
			'customer_address': '_Test Address-Office',
			'contact_department': None,
			'contact_email': '<EMAIL>',
			'contact_mobile': None,
			'sales_team': [],
			'contact_display': '_Test Contact For _Test Customer',
			'contact_person': '_Test Contact For _Test Customer-_Test Customer',
			'territory': u'_Test Territory',
			'contact_phone': '+91 0000000000',
			'customer_name': '_Test Customer'
		}

		make_test_records("Address")
		make_test_records("Contact")

		details = get_party_details("_Test Customer")

		for key, value in to_check.iteritems():
			self.assertEquals(value, details.get(key))

	def test_rename(self):
		frappe.rename_doc("Customer", "_Test Customer 1", "_Test Customer 1 Renamed")

		self.assertTrue(frappe.db.exists("Customer", "_Test Customer 1 Renamed"))
		self.assertFalse(frappe.db.exists("Customer", "_Test Customer 1"))

		frappe.rename_doc("Customer", "_Test Customer 1 Renamed", "_Test Customer 1")

<commit_msg>Improved test_rename: check if comments are also moved on rename<commit_after># Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals

import frappe
import unittest

from frappe.test_runner import make_test_records

test_ignore = ["Price List"]

test_records = frappe.get_test_records('Customer')

class TestCustomer(unittest.TestCase):
	def test_party_details(self):
		from erpnext.accounts.party import get_party_details

		to_check = {
			'selling_price_list': None,
			'customer_group': '_Test Customer Group',
			'contact_designation': None,
			'customer_address': '_Test Address-Office',
			'contact_department': None,
			'contact_email': '<EMAIL>',
			'contact_mobile': None,
			'sales_team': [],
			'contact_display': '_Test Contact For _Test Customer',
			'contact_person': '_Test Contact For _Test Customer-_Test Customer',
			'territory': u'_Test Territory',
			'contact_phone': '+91 0000000000',
			'customer_name': '_Test Customer'
		}

		make_test_records("Address")
		make_test_records("Contact")

		details = get_party_details("_Test Customer")

		for key, value in to_check.iteritems():
			self.assertEquals(value, details.get(key))

	def test_rename(self):
		comment = frappe.new_doc("Comment")
		comment.update({
			"comment": "Test Comment for Rename",
			"comment_doctype": "Customer",
			"comment_docname": "_Test Customer 1"
		})
		comment.insert()

		frappe.rename_doc("Customer", "_Test Customer 1", "_Test Customer 1 Renamed")

		self.assertTrue(frappe.db.exists("Customer", "_Test Customer 1 Renamed"))
		self.assertFalse(frappe.db.exists("Customer", "_Test Customer 1"))

		# test that comment gets renamed
		self.assertEquals(frappe.db.get_value("Comment",
			{"comment_doctype": "Customer", "comment_docname": "Test Customer 1 Renamed"}), comment.name)

		frappe.rename_doc("Customer", "_Test Customer 1 Renamed", "_Test Customer 1")


{'fraction_non_alphanumeric': 0.12134958888573859, 'fraction_numerical': 0.013609299688120215, 'mean_word_length': 5.497237569060774, 'pattern_counts': {'":': 5, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6640200', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1088, 'n_words': 286}