From 8ab708cac8dd3cf70aca9eb6e9431bbe53b3f8af Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Tue, 15 Jan 2008 17:43:04 +0000
Subject: [PATCH] Check that deleting an alarm uncatalogs it.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18722 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/tests/testAlarm.py | 37 +++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/product/ERP5/tests/testAlarm.py b/product/ERP5/tests/testAlarm.py
index 785632b743..6ea7c63e15 100644
--- a/product/ERP5/tests/testAlarm.py
+++ b/product/ERP5/tests/testAlarm.py
@@ -452,6 +452,43 @@ class TestAlarm(ERP5TypeTestCase):
     # Chen that the second alarm execution did happen
     self.assertNotEquals(alarm.getLastActiveProcess(), None)
 
+  def test_16_uncatalog(self, quiet=0, run=run_all_test):
+    """
+    Check that deleting a alarm uncatalogs it.
+    """
+    if not run: return
+    if not quiet:
+      message = 'Test Uncatalog'
+      ZopeTestCase._print('\n%s ' % message)
+      LOG('Testing... ', 0, message)
+    alarm = self.newAlarm()
+    get_transaction().commit()
+    self.tic()
+
+    now = DateTime()
+    date = addToDate(now, day=1)
+    alarm.setPeriodicityStartDate(date)
+    get_transaction().commit()
+    self.tic()
+    self.assertEquals(alarm.getAlarmDate(), date)
+
+    # This should not do change the alarm date
+    alarm.setNextAlarmDate(current_date=now)
+    get_transaction().commit()
+    self.tic()
+    self.assertEquals(alarm.getAlarmDate(), date)
+
+    # Delete the alarm
+    a_tool = self.getAlarmTool()
+    alarm_uid = alarm.getUid()
+    a_tool.manage_delObjects(uids=[alarm_uid])
+    get_transaction().commit()
+    self.tic()
+    # Check that related entry was removed
+    sql_connection = self.getSQLConnection()
+    sql = 'select * from alarm where uid=%s' % alarm_uid
+    result = sql_connection.manage_test(sql)
+    self.assertEquals(0, len(result))
 
 def test_suite():
   suite = unittest.TestSuite()
-- 
2.30.9