Commit 84d21e29 authored by Julien Muchembled's avatar Julien Muchembled

* Move check_stock alarm from erp5_core to erp5_administration.

* Fix check_catalog and check_stock alarm to pass 'fixit' parameter.
* More unit tests to check_stock & ERP5Site_checkCatalogTable.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26863 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 16a7e6fe
......@@ -29,7 +29,15 @@
</item>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_activateCheckStockTable</string> </value>
<value> <string>Alarm_checkStockTable</string> </value>
</item>
<item>
<key> <string>alarm_notification_mode</string> </key>
<value>
<tuple>
<string>problem</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>active_process = context.newActiveProcess()\n
result = context.Alarm_checkStockTable(active_process=\'/\'.join(active_process.getPhysicalPath()))\n
active_process.postResult(result)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>_getattr_</string>
<string>context</string>
<string>active_process</string>
<string>result</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_activateCheckStockTable</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -53,8 +53,10 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>context.ERP5Site_checkCatalogTable(\n
<value> <string>return context.ERP5Site_checkCatalogTable(\n
active_process=context.newActiveProcess().getPath(),\n
activity_count=activity_count,\n
bundle_object_count=bundle_object_count,\n
**kw)\n
</string> </value>
</item>
......@@ -66,7 +68,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
<value> <string>activity_count=1, bundle_object_count=100, **kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -86,12 +88,14 @@
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>0</int> </value>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>activity_count</string>
<string>bundle_object_count</string>
<string>kw</string>
<string>_apply_</string>
<string>_getattr_</string>
......@@ -107,7 +111,10 @@
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
<tuple>
<int>1</int>
<int>100</int>
</tuple>
</value>
</item>
<item>
......
......@@ -54,11 +54,13 @@
<item>
<key> <string>_body</string> </key>
<value> <string>catalog_kw = {\'select_dict\': {\'quantity\':\'stock.quantity\'}, \'stock.quantity\': \'!=0\' }\n
return context.ERP5Site_checkCatalogTable(bundle_object_count=bundle_object_count,\n
bundle_offset=bundle_offset,\n
return context.ERP5Site_checkCatalogTable(\n
active_process=context.newActiveProcess().getPath(),\n
activity_count=activity_count,\n
bundle_object_count=bundle_object_count,\n
catalog_kw=catalog_kw,\n
property_override_method_id=\'ERP5Site_getStockTableFilterDict\',\n
active_process=active_process,\n
catalog_kw=catalog_kw)\n
**kw)\n
</string> </value>
</item>
<item>
......@@ -69,7 +71,7 @@ return context.ERP5Site_checkCatalogTable(bundle_object_count=bundle_object_coun
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>bundle_object_count=100, bundle_offset=0, active_process=None</string> </value>
<value> <string>activity_count=1, bundle_object_count=100, **kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -89,16 +91,17 @@ return context.ERP5Site_checkCatalogTable(bundle_object_count=bundle_object_coun
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>3</int> </value>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>activity_count</string>
<string>bundle_object_count</string>
<string>bundle_offset</string>
<string>active_process</string>
<string>kw</string>
<string>catalog_kw</string>
<string>_apply_</string>
<string>_getattr_</string>
<string>context</string>
</tuple>
......@@ -113,9 +116,8 @@ return context.ERP5Site_checkCatalogTable(bundle_object_count=bundle_object_coun
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<int>1</int>
<int>100</int>
<int>0</int>
<none/>
</tuple>
</value>
</item>
......
62
\ No newline at end of file
63
\ No newline at end of file
portal_alarms/check_catalog
portal_alarms/check_folder_handler
portal_alarms/check_stock
\ No newline at end of file
1193
\ No newline at end of file
1194
\ No newline at end of file
portal_alarms/check_stock
portal_alarms/expired_password_alarm
portal_caches/erp5_content_long
portal_caches/erp5_content_long/default_ram_cache
......
......@@ -28,7 +28,7 @@
##############################################################################
import unittest
import transaction
from Products.ERP5.tests.testInventoryAPI import InventoryAPITestCase
class TestERP5Administration(InventoryAPITestCase):
......@@ -49,21 +49,35 @@ class TestERP5Administration(InventoryAPITestCase):
between the predicate table and zodb objects
"""
portal = self.getPortal()
mvt = self._makeMovement(quantity=100)
get_transaction().commit()
self.tic()
sql_test = portal.erp5_sql_connection.manage_test
alarm = portal.portal_alarms.check_stock
alarm.activeSense()
get_transaction().commit()
def checkActiveProcess(failed):
transaction.get().commit()
self.tic()
last_active_process = alarm.getLastActiveProcess()
self.assertFalse(last_active_process.ActiveProcess_sense())
portal.erp5_sql_connection.manage_test("update stock set quantity=5")
self.assertEqual(alarm.getLastActiveProcess().ActiveProcess_sense(),
failed)
def checkStock(row_count):
alarm.activeSense()
get_transaction().commit()
checkActiveProcess(1)
alarm.solve()
checkActiveProcess(1)
alarm.activeSense()
checkActiveProcess(0)
self.assertEqual(row_count, sql_test("select count(*) from stock")[0][0])
alarm.setAlarmNotificationMode('never')
mvt = self._makeMovement(quantity=1.23)
transaction.get().commit()
self.tic()
last_active_process = alarm.getLastActiveProcess()
self.assertTrue(last_active_process.ActiveProcess_sense())
alarm.activeSense()
checkActiveProcess(0)
row_count = sql_test("select count(*) from stock")[0][0]
sql_test("update stock set quantity=5")
checkStock(row_count) # alarm.solve will reindex 'mvt'
mvt.getParentValue()._delOb(mvt.getId())
checkStock(row_count-2) # alarm.solve will unindex 'mvt'
def test_suite():
suite = unittest.TestSuite()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment