<s> from __future__ import unicode_literals <EOL> import frappe , frappe . utils , frappe . utils . scheduler <EOL> import unittest <EOL> test_records = frappe . get_test_records ( '<STR_LIT>' ) <EOL> class TestEmailAlert ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> frappe . db . sql ( """<STR_LIT>""" ) <EOL> frappe . set_user ( "<STR_LIT>" ) <EOL> def tearDown ( self ) : <EOL> frappe . set_user ( "<STR_LIT>" ) <EOL> def test_new_and_save ( self ) : <EOL> communication = frappe . new_doc ( "<STR_LIT>" ) <EOL> communication . communication_type = '<STR_LIT>' <EOL> communication . subject = "<STR_LIT:test>" <EOL> communication . content = "<STR_LIT:test>" <EOL> communication . insert ( ignore_permissions = True ) <EOL> self . assertTrue ( frappe . db . get_value ( "<STR_LIT>" , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : communication . name , "<STR_LIT:status>" : "<STR_LIT>" } ) ) <EOL> frappe . db . sql ( """<STR_LIT>""" ) <EOL> communication . content = "<STR_LIT>" <EOL> communication . save ( ) <EOL> self . assertTrue ( frappe . db . get_value ( "<STR_LIT>" , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : communication . name , "<STR_LIT:status>" : "<STR_LIT>" } ) ) <EOL> def test_condition ( self ) : <EOL> event = frappe . new_doc ( "<STR_LIT>" ) <EOL> event . subject = "<STR_LIT:test>" , <EOL> event . event_type = "<STR_LIT>" <EOL> event . starts_on = "<STR_LIT>" <EOL> event . insert ( ) <EOL> self . assertFalse ( frappe . db . get_value ( "<STR_LIT>" , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : event . name , "<STR_LIT:status>" : "<STR_LIT>" } ) ) <EOL> event . event_type = "<STR_LIT>" <EOL> event . save ( ) <EOL> self . assertTrue ( frappe . db . get_value ( "<STR_LIT>" , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : event . name , "<STR_LIT:status>" : "<STR_LIT>" } ) ) <EOL> def test_value_changed ( self ) : <EOL> event = frappe . new_doc ( "<STR_LIT>" ) <EOL> event . subject = "<STR_LIT:test>" , <EOL> event . event_type = "<STR_LIT>" <EOL> event . starts_on = "<STR_LIT>" <EOL> event . insert ( ) <EOL> self . assertFalse ( frappe . db . get_value ( "<STR_LIT>" , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : event . name , "<STR_LIT:status>" : "<STR_LIT>" } ) ) <EOL> event . subject = "<STR_LIT>" <EOL> event . save ( ) <EOL> self . assertFalse ( frappe . db . get_value ( "<STR_LIT>" , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : event . name , "<STR_LIT:status>" : "<STR_LIT>" } ) ) <EOL> event . description = "<STR_LIT:test>" <EOL> event . save ( ) <EOL> self . assertTrue ( frappe . db . get_value ( "<STR_LIT>" , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : event . name , "<STR_LIT:status>" : "<STR_LIT>" } ) ) <EOL> def test_date_changed ( self ) : <EOL> event = frappe . new_doc ( "<STR_LIT>" ) <EOL> event . subject = "<STR_LIT:test>" , <EOL> event . event_type = "<STR_LIT>" <EOL> event . starts_on = "<STR_LIT>" <EOL> event . insert ( ) <EOL> self . assertFalse ( frappe . db . get_value ( "<STR_LIT>" , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : event . name , "<STR_LIT:status>" : "<STR_LIT>" } ) ) <EOL> frappe . utils . scheduler . trigger ( frappe . local . site , "<STR_LIT>" , now = True ) <EOL> self . assertFalse ( frappe . db . get_value ( "<STR_LIT>" , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : event . name , "<STR_LIT:status>" : "<STR_LIT>" } ) ) <EOL> event . starts_on = frappe . utils . add_days ( frappe . utils . nowdate ( ) , <NUM_LIT:2> ) + "<STR_LIT>" <EOL> event . save ( ) <EOL> self . assertFalse ( frappe . db . get_value ( "<STR_LIT>" , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : event . name , "<STR_LIT:status>" : "<STR_LIT>" } ) ) <EOL> frappe . utils . scheduler . trigger ( frappe . local . site , "<STR_LIT>" , now = True ) <EOL> self . assertTrue ( frappe . db . get_value ( "<STR_LIT>" , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : event . name , "<STR_LIT:status>" : "<STR_LIT>" } ) ) </s>
