예제 #1
0
	def test_assignment_count(self):
		frappe.db.sql('delete from tabToDo')

		if not frappe.db.exists("User", "*****@*****.**"):
			frappe.get_doc({"doctype":"User", "email":"*****@*****.**", "first_name":"Test", "roles": [{"role": "System Manager"}]}).insert()

		if not frappe.db.exists("User", "*****@*****.**"):
			frappe.get_doc({"doctype":"User", "email":"*****@*****.**", "first_name":"Test", "roles": [{"role": "System Manager"}]}).insert()

		note = make_note()
		assign(note, "*****@*****.**")

		note = make_note(dict(public=1))
		assign(note, "*****@*****.**")

		note = make_note(dict(public=1))
		assign(note, "*****@*****.**")

		note = make_note()
		assign(note, "*****@*****.**")

		data = {d.name: d.count for d in get_group_by_count('Note', '[]', 'assigned_to')}

		self.assertTrue('*****@*****.**' in data)
		self.assertEqual(data['*****@*****.**'], 1)
		self.assertEqual(data['*****@*****.**'], 3)

		data = {d.name: d.count for d in get_group_by_count('Note', '[{"public": 1}]', 'assigned_to')}

		self.assertFalse('*****@*****.**' in data)
		self.assertEqual(data['*****@*****.**'], 2)

		frappe.db.rollback()
예제 #2
0
	def test_list_view_child_table_filter_with_created_by_filter(self):
		if frappe.db.exists("Note", "Test created by filter with child table filter"):
			frappe.delete_doc("Note", "Test created by filter with child table filter")

		doc = frappe.get_doc({"doctype": "Note", "title": "Test created by filter with child table filter", "public": 1})
		doc.append("seen_by", {"user": "******"})
		doc.insert()

		data = {d.name: d.count for d in get_group_by_count('Note', '[["Note Seen By","user","=","Administrator"]]', 'owner')}
		self.assertEqual(data['Administrator'], 1)