Exemplo n.º 1
0
	def test_custom_report(self):
		reset_customization('User')
		custom_report_name = save_report(
			'Permitted Documents For User',
			'Permitted Documents For User Custom',
			json.dumps([{
				'fieldname': 'email',
				'fieldtype': 'Data',
				'label': 'Email',
				'insert_after_index': 0,
				'link_field': 'name',
				'doctype': 'User',
				'options': 'Email',
				'width': 100,
				'id':'email',
				'name': 'Email'
			}]))
		custom_report = frappe.get_doc('Report', custom_report_name)
		columns, result = custom_report.run_query_report(
			filters={
				'user': '******',
				'doctype': 'User'
			}, user=frappe.session.user)

		self.assertListEqual(['email'], [column.get('fieldname') for column in columns])
		admin_dict = frappe.core.utils.find(result, lambda d: d['name'] == 'Administrator')
		self.assertDictEqual({'name': 'Administrator', 'user_type': 'System User', 'email': '*****@*****.**'}, admin_dict)
Exemplo n.º 2
0
    def test_custom_report(self):
        reset_customization("User")
        custom_report_name = save_report(
            "Permitted Documents For User",
            "Permitted Documents For User Custom",
            json.dumps([{
                "fieldname": "email",
                "fieldtype": "Data",
                "label": "Email",
                "insert_after_index": 0,
                "link_field": "name",
                "doctype": "User",
                "options": "Email",
                "width": 100,
                "id": "email",
                "name": "Email",
            }]),
        )
        custom_report = frappe.get_doc("Report", custom_report_name)
        columns, result = custom_report.run_query_report(
            filters={
                "user": "******",
                "doctype": "User"
            },
            user=frappe.session.user)

        self.assertListEqual(["email"],
                             [column.get("fieldname") for column in columns])
        admin_dict = frappe.core.utils.find(
            result, lambda d: d["name"] == "Administrator")
        self.assertDictEqual(
            {
                "name": "Administrator",
                "user_type": "System User",
                "email": "*****@*****.**"
            }, admin_dict)