seitime-frappe/frappe/tests/test_seen.py
Gavin D'souza 3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30

45 lines
1.1 KiB
Python

# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE
import frappe, unittest, json
class TestSeen(unittest.TestCase):
def tearDown(self):
frappe.set_user('Administrator')
def test_if_user_is_added(self):
ev = frappe.get_doc({
'doctype': 'Event',
'subject': 'test event for seen',
'starts_on': '2016-01-01 10:10:00',
'event_type': 'Public'
}).insert()
frappe.set_user('test@example.com')
from frappe.desk.form.load import getdoc
# load the form
getdoc('Event', ev.name)
# reload the event
ev = frappe.get_doc('Event', ev.name)
self.assertTrue('test@example.com' in json.loads(ev._seen))
# test another user
frappe.set_user('test1@example.com')
# load the form
getdoc('Event', ev.name)
# reload the event
ev = frappe.get_doc('Event', ev.name)
self.assertTrue('test@example.com' in json.loads(ev._seen))
self.assertTrue('test1@example.com' in json.loads(ev._seen))
ev.save()
ev = frappe.get_doc('Event', ev.name)
self.assertFalse('test@example.com' in json.loads(ev._seen))
self.assertTrue('test1@example.com' in json.loads(ev._seen))