<commit_before># Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt

"""Use blog post test to test user permissions logic"""

import frappe
import frappe.defaults
import unittest
import json

from frappe.core.doctype.event.event import get_events

test_records = frappe.get_test_records('Event')

class TestEvent(unittest.TestCase):
	# def setUp(self):
	# 	user = frappe.get_doc("User", "<EMAIL>")
	# 	user.add_roles("Website Manager")

	def tearDown(self):
		frappe.set_user("Administrator")

	def test_allowed_public(self):
		frappe.set_user("<EMAIL>")
		doc = frappe.get_doc("Event", frappe.db.get_value("Event", {"subject":"_Test Event 1"}))
		self.assertTrue(frappe.has_permission("Event", doc=doc))

	def test_not_allowed_private(self):
		frappe.set_user("<EMAIL>")
		doc = frappe.get_doc("Event", frappe.db.get_value("Event", {"subject":"_Test Event 2"}))
		self.assertFalse(frappe.has_permission("Event", doc=doc))

	def test_allowed_private_if_in_event_user(self):
		frappe.set_user("<EMAIL>")
		doc = frappe.get_doc("Event", frappe.db.get_value("Event", {"subject":"_Test Event 3"}))
		self.assertTrue(frappe.has_permission("Event", doc=doc))

	def test_event_list(self):<commit_msg>[fix] for tests<commit_after># Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt

"""Use blog post test to test user permissions logic"""

import frappe
import frappe.defaults
import unittest
import json

from frappe.desk.doctype.event.event import get_events

test_records = frappe.get_test_records('Event')

class TestEvent(unittest.TestCase):
	# def setUp(self):
	# 	user = frappe.get_doc("User", "<EMAIL>")
	# 	user.add_roles("Website Manager")

	def tearDown(self):
		frappe.set_user("Administrator")

	def test_allowed_public(self):
		frappe.set_user("<EMAIL>")
		doc = frappe.get_doc("Event", frappe.db.get_value("Event", {"subject":"_Test Event 1"}))
		self.assertTrue(frappe.has_permission("Event", doc=doc))

	def test_not_allowed_private(self):
		frappe.set_user("<EMAIL>")
		doc = frappe.get_doc("Event", frappe.db.get_value("Event", {"subject":"_Test Event 2"}))
		self.assertFalse(frappe.has_permission("Event", doc=doc))

	def test_allowed_private_if_in_event_user(self):
		frappe.set_user("<EMAIL>")
		doc = frappe.get_doc("Event", frappe.db.get_value("Event", {"subject":"_Test Event 3"}))
		self.assertTrue(frappe.has_permission("Event", doc=doc))

	def test_event_list(self):
{'fraction_non_alphanumeric': 0.1527331189710611, 'fraction_numerical': 0.005627009646302251, 'mean_word_length': 6.474474474474475, 'pattern_counts': {'":': 6, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '1674992', 'n_tokens_mistral': 904, 'n_tokens_neox': 898, 'n_words': 171}