Commit 44493e2e authored by Rafael Monnerat's avatar Rafael Monnerat

SlapOSMixin: Move part of this mixin into portal_components to speed up development.

  Include SlapOSTestCaseMixin on portal_components and update the tests to use
  it instead directly use SlapOSMixin from SlapOS Product
parent adea5daf
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
import transaction import transaction
from functools import wraps from functools import wraps
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin, withAbort
testSlapOSMixin, withAbort
import os import os
import tempfile import tempfile
from DateTime import DateTime from DateTime import DateTime
...@@ -83,7 +83,7 @@ if context.getTitle() == 'Not visited by %s': ...@@ -83,7 +83,7 @@ if context.getTitle() == 'Not visited by %s':
return wrapped return wrapped
return wrapper return wrapper
class TestInstanceInvoicingAlarm(testSlapOSMixin): class TestInstanceInvoicingAlarm(SlapOSTestCaseMixin):
@withAbort @withAbort
def test_noSaleOrderPackingList_newSoftwareInstance(self): def test_noSaleOrderPackingList_newSoftwareInstance(self):
""" """
...@@ -275,7 +275,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin): ...@@ -275,7 +275,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
self.assertEqual(2, instance.getInvoicingSynchronizationPointer()) self.assertEqual(2, instance.getInvoicingSynchronizationPointer())
delivery = instance.getCausalityValue() delivery = instance.getCausalityValue()
setup_line, update_line, destroy_line =\ setup_line, _, destroy_line =\
self.check_instance_delivery(delivery, start_date, stop_date, person, 2) self.check_instance_delivery(delivery, start_date, stop_date, person, 2)
self.check_instance_movement(setup_line, instance, subscription, 1) self.check_instance_movement(setup_line, instance, subscription, 1)
self.check_instance_movement(destroy_line, instance, subscription, 1) self.check_instance_movement(destroy_line, instance, subscription, 1)
...@@ -347,7 +347,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin): ...@@ -347,7 +347,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
self.assertEqual(2, instance.getInvoicingSynchronizationPointer()) self.assertEqual(2, instance.getInvoicingSynchronizationPointer())
delivery = instance.getCausalityValue() delivery = instance.getCausalityValue()
setup_line, update_line, destroy_line =\ setup_line, update_line, _ =\
self.check_instance_delivery(delivery, start_date, stop_date, person, 1) self.check_instance_delivery(delivery, start_date, stop_date, person, 1)
self.check_instance_movement(setup_line, instance, subscription, 1) self.check_instance_movement(setup_line, instance, subscription, 1)
...@@ -404,7 +404,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin): ...@@ -404,7 +404,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
self.assertEqual(4, instance.getInvoicingSynchronizationPointer()) self.assertEqual(4, instance.getInvoicingSynchronizationPointer())
delivery = instance.getCausalityValue() delivery = instance.getCausalityValue()
setup_line, update_line, destroy_line =\ setup_line, update_line, _ =\
self.check_instance_delivery(delivery, start_date, stop_date, person, 2) self.check_instance_delivery(delivery, start_date, stop_date, person, 2)
self.check_instance_movement(setup_line, instance, subscription, 1) self.check_instance_movement(setup_line, instance, subscription, 1)
self.check_instance_movement(update_line, instance, subscription, 2) self.check_instance_movement(update_line, instance, subscription, 2)
...@@ -525,7 +525,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin): ...@@ -525,7 +525,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
self.assertEqual(4, instance.getInvoicingSynchronizationPointer()) self.assertEqual(4, instance.getInvoicingSynchronizationPointer())
delivery = instance.getCausalityValue() delivery = instance.getCausalityValue()
setup_line, update_line, destroy_line =\ _, update_line, destroy_line =\
self.check_instance_delivery(delivery, start_date, stop_date, person, 1) self.check_instance_delivery(delivery, start_date, stop_date, person, 1)
self.check_instance_movement(update_line, instance, subscription, 2) self.check_instance_movement(update_line, instance, subscription, 2)
...@@ -646,7 +646,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin): ...@@ -646,7 +646,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
self.assertEqual(4, instance.getInvoicingSynchronizationPointer()) self.assertEqual(4, instance.getInvoicingSynchronizationPointer())
delivery = instance.getCausalityValue() delivery = instance.getCausalityValue()
setup_line, update_line, destroy_line =\ setup_line, update_line, _ =\
self.check_instance_delivery(delivery, start_date, stop_date, person, 1) self.check_instance_delivery(delivery, start_date, stop_date, person, 1)
self.check_instance_movement(update_line, instance, subscription, 2) self.check_instance_movement(update_line, instance, subscription, 2)
...@@ -689,7 +689,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin): ...@@ -689,7 +689,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
self.check_instance_delivery(delivery, stop_date, stop_date, person, 1) self.check_instance_delivery(delivery, stop_date, stop_date, person, 1)
self.check_instance_movement(update_line, instance, subscription, 1) self.check_instance_movement(update_line, instance, subscription, 1)
class TestOpenSaleOrderAlarm(testSlapOSMixin): class TestOpenSaleOrderAlarm(SlapOSTestCaseMixin):
def test_noOSO_newPerson(self): def test_noOSO_newPerson(self):
person = self.portal.person_module.template_member\ person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1) .Base_createCloneDocument(batch_mode=1)
...@@ -743,7 +743,7 @@ class TestOpenSaleOrderAlarm(testSlapOSMixin): ...@@ -743,7 +743,7 @@ class TestOpenSaleOrderAlarm(testSlapOSMixin):
'Visited by HostingSubscription_requestUpdateOpenSaleOrder', 'Visited by HostingSubscription_requestUpdateOpenSaleOrder',
subscription.workflow_history['edit_workflow'][-1]['comment']) subscription.workflow_history['edit_workflow'][-1]['comment'])
class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin): class TestHostingSubscription_requestUpdateOpenSaleOrder(SlapOSTestCaseMixin):
def test_REQUEST_disallowed(self): def test_REQUEST_disallowed(self):
subscription = self.portal.hosting_subscription_module\ subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1) .template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
...@@ -1291,7 +1291,7 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin): ...@@ -1291,7 +1291,7 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
self.assertTrue(new_effective_date > effective_date, self.assertTrue(new_effective_date > effective_date,
"%s <= %s" % (new_effective_date, effective_date)) "%s <= %s" % (new_effective_date, effective_date))
class TestSlapOSTriggerBuildAlarm(testSlapOSMixin): class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin):
@simulateByTitlewMark('SimulationMovement_buildSlapOS') @simulateByTitlewMark('SimulationMovement_buildSlapOS')
def test_SimulationMovement_withoutDelivery(self): def test_SimulationMovement_withoutDelivery(self):
applied_rule = self.portal.portal_simulation.newContent( applied_rule = self.portal.portal_simulation.newContent(
...@@ -1475,7 +1475,7 @@ class TestSlapOSTriggerBuildAlarm(testSlapOSMixin): ...@@ -1475,7 +1475,7 @@ class TestSlapOSTriggerBuildAlarm(testSlapOSMixin):
if os.path.exists(activate_simulator): if os.path.exists(activate_simulator):
os.unlink(activate_simulator) os.unlink(activate_simulator)
class TestSlapOSManageBuildingCalculatingDeliveryAlarm(testSlapOSMixin): class TestSlapOSManageBuildingCalculatingDeliveryAlarm(SlapOSTestCaseMixin):
@simulateByTitlewMark('Delivery_manageBuildingCalculatingDelivery') @simulateByTitlewMark('Delivery_manageBuildingCalculatingDelivery')
def _test(self, state, message): def _test(self, state, message):
delivery = self.portal.sale_packing_list_module.newContent( delivery = self.portal.sale_packing_list_module.newContent(
...@@ -1656,7 +1656,7 @@ class TestSlapOSConfirmedDeliveryMixin: ...@@ -1656,7 +1656,7 @@ class TestSlapOSConfirmedDeliveryMixin:
'confirmed', True) 'confirmed', True)
class TestSlapOSStartConfirmedAggregatedSalePackingListAlarm( class TestSlapOSStartConfirmedAggregatedSalePackingListAlarm(
testSlapOSMixin, TestSlapOSConfirmedDeliveryMixin): SlapOSTestCaseMixin, TestSlapOSConfirmedDeliveryMixin):
destination_state = 'started' destination_state = 'started'
script = 'Delivery_startConfirmedAggregatedSalePackingList' script = 'Delivery_startConfirmedAggregatedSalePackingList'
portal_type = 'Sale Packing List' portal_type = 'Sale Packing List'
...@@ -1692,7 +1692,7 @@ class TestSlapOSStartConfirmedAggregatedSalePackingListAlarm( ...@@ -1692,7 +1692,7 @@ class TestSlapOSStartConfirmedAggregatedSalePackingListAlarm(
destination_decision='organisation_module/slapos', destination_decision='organisation_module/slapos',
price_currency='currency_module/EUR', price_currency='currency_module/EUR',
) )
movement = delivery.newContent( delivery.newContent(
portal_type="Sale Packing List Line", portal_type="Sale Packing List Line",
resource='service_module/slapos_instance_setup', resource='service_module/slapos_instance_setup',
quantity=0, quantity=0,
...@@ -1708,7 +1708,7 @@ class TestSlapOSStartConfirmedAggregatedSalePackingListAlarm( ...@@ -1708,7 +1708,7 @@ class TestSlapOSStartConfirmedAggregatedSalePackingListAlarm(
self.assertEquals(delivery.getSimulationState(), 'started') self.assertEquals(delivery.getSimulationState(), 'started')
class TestSlapOSDeliverStartedAggregatedSalePackingListAlarm( class TestSlapOSDeliverStartedAggregatedSalePackingListAlarm(
testSlapOSMixin): SlapOSTestCaseMixin):
destination_state = 'delivered' destination_state = 'delivered'
script = 'Delivery_deliverStartedAggregatedSalePackingList' script = 'Delivery_deliverStartedAggregatedSalePackingList'
portal_type = 'Sale Packing List' portal_type = 'Sale Packing List'
...@@ -1805,13 +1805,13 @@ class TestSlapOSDeliverStartedAggregatedSalePackingListAlarm( ...@@ -1805,13 +1805,13 @@ class TestSlapOSDeliverStartedAggregatedSalePackingListAlarm(
'started', True) 'started', True)
class TestSlapOSStopConfirmedAggregatedSaleInvoiceTransactionAlarm( class TestSlapOSStopConfirmedAggregatedSaleInvoiceTransactionAlarm(
testSlapOSMixin, TestSlapOSConfirmedDeliveryMixin): SlapOSTestCaseMixin, TestSlapOSConfirmedDeliveryMixin):
destination_state = 'stopped' destination_state = 'stopped'
script = 'Delivery_stopConfirmedAggregatedSaleInvoiceTransaction' script = 'Delivery_stopConfirmedAggregatedSaleInvoiceTransaction'
portal_type = 'Sale Invoice Transaction' portal_type = 'Sale Invoice Transaction'
alarm = 'slapos_stop_confirmed_aggregated_sale_invoice_transaction' alarm = 'slapos_stop_confirmed_aggregated_sale_invoice_transaction'
class TestSlapOSUpdateOpenSaleOrderPeriod(testSlapOSMixin): class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
def createOpenOrder(self): def createOpenOrder(self):
open_order = self.portal.open_sale_order_module\ open_order = self.portal.open_sale_order_module\
...@@ -1947,7 +1947,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by O ...@@ -1947,7 +1947,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by O
'Visited by OpenSaleOrder_updatePeriod', 'Visited by OpenSaleOrder_updatePeriod',
open_order.workflow_history['edit_workflow'][-1]['comment']) open_order.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSReindexOpenSaleOrder(testSlapOSMixin): class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin):
def createOpenOrder(self): def createOpenOrder(self):
open_order = self.portal.open_sale_order_module\ open_order = self.portal.open_sale_order_module\
...@@ -2004,7 +2004,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by O ...@@ -2004,7 +2004,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by O
'Visited by OpenSaleOrder_reindexIfIndexedBeforeLine', 'Visited by OpenSaleOrder_reindexIfIndexedBeforeLine',
open_order.workflow_history['edit_workflow'][-1]['comment']) open_order.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSGeneratePackingListFromTioXML(testSlapOSMixin): class TestSlapOSGeneratePackingListFromTioXML(SlapOSTestCaseMixin):
def createTioXMLFile(self): def createTioXMLFile(self):
document = self.portal.consumption_document_module.newContent( document = self.portal.consumption_document_module.newContent(
......
...@@ -47,14 +47,9 @@ ...@@ -47,14 +47,9 @@
<value> <value>
<tuple> <tuple>
<string>W: 30, 10: Use of eval (eval-used)</string> <string>W: 30, 10: Use of eval (eval-used)</string>
<string>W:278, 16: Unused variable \'update_line\' (unused-variable)</string>
<string>W:350, 16: Unused variable \'update_line\' (unused-variable)</string> <string>W:350, 16: Unused variable \'update_line\' (unused-variable)</string>
<string>W:350, 29: Unused variable \'destroy_line\' (unused-variable)</string> <string>W:528, 20: Unused variable \'destroy_line\' (unused-variable)</string>
<string>W:407, 29: Unused variable \'destroy_line\' (unused-variable)</string>
<string>W:528, 29: Unused variable \'destroy_line\' (unused-variable)</string>
<string>W:528, 4: Unused variable \'setup_line\' (unused-variable)</string>
<string>W:588, 4: Unused variable \'setup_line\' (unused-variable)</string> <string>W:588, 4: Unused variable \'setup_line\' (unused-variable)</string>
<string>W:649, 29: Unused variable \'destroy_line\' (unused-variable)</string>
<string>W:649, 4: Unused variable \'setup_line\' (unused-variable)</string> <string>W:649, 4: Unused variable \'setup_line\' (unused-variable)</string>
<string>W:688, 29: Unused variable \'destroy_line\' (unused-variable)</string> <string>W:688, 29: Unused variable \'destroy_line\' (unused-variable)</string>
<string>W:688, 4: Unused variable \'setup_line\' (unused-variable)</string> <string>W:688, 4: Unused variable \'setup_line\' (unused-variable)</string>
...@@ -68,7 +63,6 @@ ...@@ -68,7 +63,6 @@
<string>W:1463, 23: Use of eval (eval-used)</string> <string>W:1463, 23: Use of eval (eval-used)</string>
<string>W:1526, 35: Use of eval (eval-used)</string> <string>W:1526, 35: Use of eval (eval-used)</string>
<string>W:1527, 31: Use of eval (eval-used)</string> <string>W:1527, 31: Use of eval (eval-used)</string>
<string>W:1695, 4: Unused variable \'movement\' (unused-variable)</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -5,15 +5,13 @@ ...@@ -5,15 +5,13 @@
# #
############################################################################## ##############################################################################
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
testSlapOSMixin
from DateTime import DateTime from DateTime import DateTime
import transaction
def convertCategoryList(base, l): def convertCategoryList(base, l):
return ['%s/%s' % (base, q) for q in l] return ['%s/%s' % (base, q) for q in l]
class TestSlapOSSalePackingListBuilder(testSlapOSMixin): class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
def checkSimulationMovement(self, simulation_movement): def checkSimulationMovement(self, simulation_movement):
self.assertEqual(1.0, simulation_movement.getDeliveryRatio()) self.assertEqual(1.0, simulation_movement.getDeliveryRatio())
self.assertEqual(0.0, simulation_movement.getDeliveryError()) self.assertEqual(0.0, simulation_movement.getDeliveryError())
...@@ -1210,7 +1208,7 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis ...@@ -1210,7 +1208,7 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
self.assertEqual(invoice_2.getRelativeUrl(), self.assertEqual(invoice_2.getRelativeUrl(),
model_line_2_tax_bis.getParentValue().getRelativeUrl()) model_line_2_tax_bis.getParentValue().getRelativeUrl())
class TestSlapOSAggregatedDeliveryBuilder(testSlapOSMixin): class TestSlapOSAggregatedDeliveryBuilder(SlapOSTestCaseMixin):
def emptyBuild(self, **kw): def emptyBuild(self, **kw):
delivery_list = self._build(**kw) delivery_list = self._build(**kw)
self.assertSameSet([], delivery_list) self.assertSameSet([], delivery_list)
......
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSAccountingBuilder</string> </value> <value> <string>testSlapOSAccountingBuilder</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSAccountingBuilder</string> </value> <value> <string>test.erp5.testSlapOSAccountingBuilder</string> </value>
...@@ -33,9 +45,7 @@ ...@@ -33,9 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 11, 0: Unused import transaction (unused-import)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -45,13 +55,28 @@ ...@@ -45,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -64,7 +89,7 @@ ...@@ -64,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -73,7 +98,7 @@ ...@@ -73,7 +98,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
############################################################################## ##############################################################################
from erp5.component.test.testSlapOSCloudConstraint import TestSlapOSConstraintMixin from erp5.component.test.testSlapOSCloudConstraint import TestSlapOSConstraintMixin
from Products.ERP5Type.Base import WorkflowMethod from Products.ERP5Type.Base import WorkflowMethod
from Products.SlapOS.tests.testSlapOSMixin import withAbort from erp5.component.test.SlapOSTestCaseMixin import withAbort
from unittest import skip from unittest import skip
import transaction import transaction
......
# Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
testSlapOSMixin
import transaction import transaction
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.DateUtils import addToDate
class TestSlapOSAccountingInteractionWorkflow(testSlapOSMixin): class TestSlapOSAccountingInteractionWorkflow(SlapOSTestCaseMixin):
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() transaction.abort()
......
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSAccountingInteractionWorkflow</string> </value> <value> <string>testSlapOSAccountingInteractionWorkflow</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSAccountingInteractionWorkflow</string> </value> <value> <string>test.erp5.testSlapOSAccountingInteractionWorkflow</string> </value>
...@@ -33,9 +45,7 @@ ...@@ -33,9 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 7, 0: Unused import addToDate (unused-import)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -45,13 +55,28 @@ ...@@ -45,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -64,7 +89,7 @@ ...@@ -64,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -73,7 +98,7 @@ ...@@ -73,7 +98,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
......
...@@ -4,9 +4,8 @@ ...@@ -4,9 +4,8 @@
# Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved.
# #
############################################################################## ##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin, withAbort
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin, withAbort
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.DateUtils import addToDate from Products.ERP5Type.DateUtils import addToDate
from Products.ERP5.Document.SimulationMovement import SimulationMovement from Products.ERP5.Document.SimulationMovement import SimulationMovement
...@@ -27,7 +26,7 @@ def getSimulationStatePlannedDelivered(self, *args, **kwargs): ...@@ -27,7 +26,7 @@ def getSimulationStatePlannedDelivered(self, *args, **kwargs):
return 'delivered' return 'delivered'
return 'planned' return 'planned'
class TestDefaultInvoiceTransactionRule(testSlapOSMixin): class TestDefaultInvoiceTransactionRule(SlapOSTestCaseMixin):
@withAbort @withAbort
def test_simulation(self): def test_simulation(self):
SimulationMovement.original_getSimulationState = SimulationMovement\ SimulationMovement.original_getSimulationState = SimulationMovement\
...@@ -159,7 +158,7 @@ class TestDefaultInvoiceTransactionRule(testSlapOSMixin): ...@@ -159,7 +158,7 @@ class TestDefaultInvoiceTransactionRule(testSlapOSMixin):
.original_getSimulationState .original_getSimulationState
class TestDefaultInvoiceRule(testSlapOSMixin): class TestDefaultInvoiceRule(SlapOSTestCaseMixin):
@withAbort @withAbort
def test_simulation(self): def test_simulation(self):
SimulationMovement.original_getSimulationState = SimulationMovement\ SimulationMovement.original_getSimulationState = SimulationMovement\
...@@ -233,7 +232,7 @@ class TestDefaultInvoiceRule(testSlapOSMixin): ...@@ -233,7 +232,7 @@ class TestDefaultInvoiceRule(testSlapOSMixin):
.original_getSimulationState .original_getSimulationState
class TestDefaultInvoicingRule(testSlapOSMixin): class TestDefaultInvoicingRule(SlapOSTestCaseMixin):
@withAbort @withAbort
def test_simulation(self): def test_simulation(self):
SimulationMovement.original_getSimulationState = SimulationMovement\ SimulationMovement.original_getSimulationState = SimulationMovement\
...@@ -353,7 +352,7 @@ class TestDefaultInvoicingRule(testSlapOSMixin): ...@@ -353,7 +352,7 @@ class TestDefaultInvoicingRule(testSlapOSMixin):
SimulationMovement.getSimulationState = SimulationMovement\ SimulationMovement.getSimulationState = SimulationMovement\
.original_getSimulationState .original_getSimulationState
class TestDefaultPaymentRule(testSlapOSMixin): class TestDefaultPaymentRule(SlapOSTestCaseMixin):
@withAbort @withAbort
def test_simulation(self): def test_simulation(self):
SimulationMovement.original_getSimulationState = SimulationMovement\ SimulationMovement.original_getSimulationState = SimulationMovement\
...@@ -418,7 +417,7 @@ class TestDefaultPaymentRule(testSlapOSMixin): ...@@ -418,7 +417,7 @@ class TestDefaultPaymentRule(testSlapOSMixin):
SimulationMovement.getSimulationState = SimulationMovement\ SimulationMovement.getSimulationState = SimulationMovement\
.original_getSimulationState .original_getSimulationState
class TestHostingSubscriptionSimulation(testSlapOSMixin): class TestHostingSubscriptionSimulation(SlapOSTestCaseMixin):
def _prepare(self): def _prepare(self):
person = self.portal.person_module.template_member\ person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1) .Base_createCloneDocument(batch_mode=1)
...@@ -666,7 +665,7 @@ class TestHostingSubscriptionSimulation(testSlapOSMixin): ...@@ -666,7 +665,7 @@ class TestHostingSubscriptionSimulation(testSlapOSMixin):
SimulationMovement.isFrozen = SimulationMovement.originalIsFrozen SimulationMovement.isFrozen = SimulationMovement.originalIsFrozen
delattr(SimulationMovement, 'originalIsFrozen') delattr(SimulationMovement, 'originalIsFrozen')
class TestDefaultTradeModelRule(testSlapOSMixin): class TestDefaultTradeModelRule(SlapOSTestCaseMixin):
@withAbort @withAbort
def test_simulation(self): def test_simulation(self):
SimulationMovement.original_getSimulationState = SimulationMovement\ SimulationMovement.original_getSimulationState = SimulationMovement\
...@@ -779,7 +778,7 @@ class TestDefaultTradeModelRule(testSlapOSMixin): ...@@ -779,7 +778,7 @@ class TestDefaultTradeModelRule(testSlapOSMixin):
SimulationMovement.getSimulationState = SimulationMovement\ SimulationMovement.getSimulationState = SimulationMovement\
.original_getSimulationState .original_getSimulationState
class TestDefaultDeliveryRule(testSlapOSMixin): class TestDefaultDeliveryRule(SlapOSTestCaseMixin):
trade_condition = 'sale_trade_condition_module/slapos_aggregated_trade_condition' trade_condition = 'sale_trade_condition_module/slapos_aggregated_trade_condition'
def test(self): def test(self):
def newArrow(): def newArrow():
...@@ -867,7 +866,7 @@ class TestDefaultDeliveryRule(testSlapOSMixin): ...@@ -867,7 +866,7 @@ class TestDefaultDeliveryRule(testSlapOSMixin):
self.assertSameSet(['default_invoicing_rule'], [q.getSpecialiseReference() self.assertSameSet(['default_invoicing_rule'], [q.getSpecialiseReference()
for q in simulation_movement.contentValues(portal_type='Applied Rule')]) for q in simulation_movement.contentValues(portal_type='Applied Rule')])
class TestDefaultDeliveryRuleConsumption(testSlapOSMixin): class TestDefaultDeliveryRuleConsumption(SlapOSTestCaseMixin):
def test(self): def test(self):
def newArrow(): def newArrow():
return self.portal.organisation_module.newContent( return self.portal.organisation_module.newContent(
...@@ -907,6 +906,6 @@ class TestDefaultDeliveryRuleConsumption(testSlapOSMixin): ...@@ -907,6 +906,6 @@ class TestDefaultDeliveryRuleConsumption(testSlapOSMixin):
applied_rule_list = delivery.getCausalityRelatedValueList() applied_rule_list = delivery.getCausalityRelatedValueList()
self.assertEqual(0, len(applied_rule_list)) self.assertEqual(0, len(applied_rule_list))
class TestDefaultDeliveryRuleSubscription(testSlapOSMixin): class TestDefaultDeliveryRuleSubscription(SlapOSTestCaseMixin):
trade_condition = 'sale_trade_condition_module/slapos_subscr'\ trade_condition = 'sale_trade_condition_module/slapos_subscr'\
'iption_trade_condition' 'iption_trade_condition'
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSAccountingRule</string> </value> <value> <string>testSlapOSAccountingRule</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSAccountingRule</string> </value> <value> <string>test.erp5.testSlapOSAccountingRule</string> </value>
...@@ -33,9 +45,7 @@ ...@@ -33,9 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 22, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -45,13 +55,28 @@ ...@@ -45,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -64,7 +89,7 @@ ...@@ -64,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -73,7 +98,7 @@ ...@@ -73,7 +98,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
......
...@@ -4,14 +4,13 @@ ...@@ -4,14 +4,13 @@
# Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved.
# #
############################################################################## ##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin, withAbort
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin, withAbort
from zExceptions import Unauthorized from zExceptions import Unauthorized
from DateTime import DateTime from DateTime import DateTime
import time import time
class TestSlapOSAccounting(testSlapOSMixin): class TestSlapOSAccounting(SlapOSTestCaseMixin):
def createHostingSubscription(self): def createHostingSubscription(self):
new_id = self.generateNewId() new_id = self.generateNewId()
......
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSAccountingSkins</string> </value> <value> <string>testSlapOSAccountingSkins</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSAccountingSkins</string> </value> <value> <string>test.erp5.testSlapOSAccountingSkins</string> </value>
...@@ -34,7 +46,7 @@ ...@@ -34,7 +46,7 @@
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple>
<string>W:174, 4: Unused variable \'line\' (unused-variable)</string> <string>W:173, 4: Unused variable \'line\' (unused-variable)</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -45,13 +57,28 @@ ...@@ -45,13 +57,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -64,7 +91,7 @@ ...@@ -64,7 +91,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -73,7 +100,7 @@ ...@@ -73,7 +100,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
......
...@@ -6,14 +6,11 @@ ...@@ -6,14 +6,11 @@
############################################################################## ##############################################################################
import transaction import transaction
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import \
testSlapOSMixin, withAbort, simulate SlapOSTestCaseMixinWithAbort, SlapOSTestCaseMixin, simulate
from zExceptions import Unauthorized from zExceptions import Unauthorized
class TestSlapOSComputer_reportComputerConsumption(testSlapOSMixin): class TestSlapOSComputer_reportComputerConsumption(SlapOSTestCaseMixinWithAbort):
def beforeTearDown(self):
transaction.abort()
def createComputer(self): def createComputer(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -128,10 +125,7 @@ class TestSlapOSComputer_reportComputerConsumption(testSlapOSMixin): ...@@ -128,10 +125,7 @@ class TestSlapOSComputer_reportComputerConsumption(testSlapOSMixin):
self.assertEquals(document2.getValidationState(), "submitted") self.assertEquals(document2.getValidationState(), "submitted")
self.assertEquals(document2.getContributor(), computer.getRelativeUrl()) self.assertEquals(document2.getContributor(), computer.getRelativeUrl())
class TestSlapOSComputerConsumptionTioXMLFile_parseXml(testSlapOSMixin): class TestSlapOSComputerConsumptionTioXMLFile_parseXml(SlapOSTestCaseMixinWithAbort):
def beforeTearDown(self):
transaction.abort()
def createTioXMLFile(self): def createTioXMLFile(self):
document = self.portal.consumption_document_module.newContent( document = self.portal.consumption_document_module.newContent(
...@@ -261,7 +255,7 @@ class TestSlapOSComputerConsumptionTioXMLFile_parseXml(testSlapOSMixin): ...@@ -261,7 +255,7 @@ class TestSlapOSComputerConsumptionTioXMLFile_parseXml(testSlapOSMixin):
}) })
class TestSlapOSComputerConsumptionTioXMLFile_solveInvoicingGeneration( class TestSlapOSComputerConsumptionTioXMLFile_solveInvoicingGeneration(
testSlapOSMixin): SlapOSTestCaseMixin):
def createTioXMLFile(self): def createTioXMLFile(self):
document = self.portal.consumption_document_module.newContent( document = self.portal.consumption_document_module.newContent(
......
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSConsumptionSkins</string> </value> <value> <string>testSlapOSConsumptionSkins</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSConsumptionSkins</string> </value> <value> <string>test.erp5.testSlapOSConsumptionSkins</string> </value>
...@@ -33,9 +45,7 @@ ...@@ -33,9 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 9, 0: Unused import withAbort (unused-import)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -45,13 +55,28 @@ ...@@ -45,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -64,7 +89,7 @@ ...@@ -64,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -73,7 +98,7 @@ ...@@ -73,7 +98,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
......
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction import transaction
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
testSlapOSMixin
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestSlapOSRequestValidationPayment(testSlapOSMixin): class TestSlapOSRequestValidationPayment(SlapOSTestCaseMixin):
def _makeSlaveTree(self, requested_template_id='template_slave_instance'): def _makeSlaveTree(self, requested_template_id='template_slave_instance'):
super(TestSlapOSRequestValidationPayment, self).\ SlapOSTestCaseMixin.\
_makeTree(requested_template_id=requested_template_id) _makeTree(self, requested_template_id=requested_template_id)
def _simulateSoftwareInstance_requestValidationPayment(self): def _simulateSoftwareInstance_requestValidationPayment(self):
script_name = 'SoftwareInstance_requestValidationPayment' script_name = 'SoftwareInstance_requestValidationPayment'
......
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSContractAlarm</string> </value> <value> <string>testSlapOSContractAlarm</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSContractAlarm</string> </value> <value> <string>test.erp5.testSlapOSContractAlarm</string> </value>
...@@ -43,13 +55,28 @@ ...@@ -43,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -62,7 +89,7 @@ ...@@ -62,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -71,7 +98,7 @@ ...@@ -71,7 +98,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
......
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from zExceptions import Unauthorized from zExceptions import Unauthorized
from DateTime import DateTime from DateTime import DateTime
from functools import wraps
from Products.ERP5Type.tests.utils import createZODBPythonScript
import difflib
class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
def beforeTearDown(self): class TestSlapOSSoftwareInstance_requestValidationPayment(SlapOSTestCaseMixinWithAbort):
transaction.abort()
def createCloudContract(self): def createCloudContract(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -62,23 +55,23 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin): ...@@ -62,23 +55,23 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
return person, instance, subscription return person, instance, subscription
def test_requestValidationPayment_REQUEST_disallowed(self): def test_requestValidationPayment_REQUEST_disallowed(self):
person, instance, subscription = self.createNeededDocuments() _, instance, _ = self.createNeededDocuments()
self.assertRaises( self.assertRaises(
Unauthorized, Unauthorized,
instance.SoftwareInstance_requestValidationPayment, instance.SoftwareInstance_requestValidationPayment,
REQUEST={}) REQUEST={})
def test_prevent_concurrency(self): def test_prevent_concurrency(self):
person, instance, subscription = self.createNeededDocuments() person, instance, _ = self.createNeededDocuments()
tag = "%s_requestValidationPayment_inProgress" % person.getUid() tag = "%s_requestValidationPayment_inProgress" % person.getUid()
person.reindexObject(activate_kw={'tag': tag}) person.reindexObject(activate_kw={'tag': tag})
transaction.commit() self.commit()
result = instance.SoftwareInstance_requestValidationPayment() result = instance.SoftwareInstance_requestValidationPayment()
self.assertEquals(result, None) self.assertEquals(result, None)
def test_addCloudContract(self): def test_addCloudContract(self):
person, instance, subscription = self.createNeededDocuments() person, instance, _ = self.createNeededDocuments()
contract = instance.SoftwareInstance_requestValidationPayment() contract = instance.SoftwareInstance_requestValidationPayment()
# Default property # Default property
...@@ -89,34 +82,34 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin): ...@@ -89,34 +82,34 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
'Contract for "%s"' % person.getTitle()) 'Contract for "%s"' % person.getTitle())
def test_addCloudContract_do_not_duplicate_contract_if_not_reindexed(self): def test_addCloudContract_do_not_duplicate_contract_if_not_reindexed(self):
person, instance, subscription = self.createNeededDocuments() _, instance, _ = self.createNeededDocuments()
contract = instance.SoftwareInstance_requestValidationPayment() contract = instance.SoftwareInstance_requestValidationPayment()
transaction.commit() self.commit()
contract2 = instance.SoftwareInstance_requestValidationPayment() contract2 = instance.SoftwareInstance_requestValidationPayment()
self.assertNotEquals(contract, None) self.assertNotEquals(contract, None)
self.assertEquals(contract2, None) self.assertEquals(contract2, None)
def test_addCloudContract_existing_invalidated_contract(self): def test_addCloudContract_existing_invalidated_contract(self):
person, instance, subscription = self.createNeededDocuments() _, instance, _ = self.createNeededDocuments()
contract = instance.SoftwareInstance_requestValidationPayment() contract = instance.SoftwareInstance_requestValidationPayment()
transaction.commit() self.commit()
self.tic() self.tic()
contract2 = instance.SoftwareInstance_requestValidationPayment() contract2 = instance.SoftwareInstance_requestValidationPayment()
self.assertNotEquals(contract, None) self.assertNotEquals(contract, None)
self.assertEquals(contract2.getRelativeUrl(), contract.getRelativeUrl()) self.assertEquals(contract2.getRelativeUrl(), contract.getRelativeUrl())
def test_addCloudContract_existing_validated_contract(self): def test_addCloudContract_existing_validated_contract(self):
person, instance, subscription = self.createNeededDocuments() _, instance, _ = self.createNeededDocuments()
contract = instance.SoftwareInstance_requestValidationPayment() contract = instance.SoftwareInstance_requestValidationPayment()
contract.validate() contract.validate()
transaction.commit() self.commit()
self.tic() self.tic()
contract2 = instance.SoftwareInstance_requestValidationPayment() contract2 = instance.SoftwareInstance_requestValidationPayment()
self.assertNotEquals(contract, None) self.assertNotEquals(contract, None)
self.assertEquals(contract2.getRelativeUrl(), contract.getRelativeUrl()) self.assertEquals(contract2.getRelativeUrl(), contract.getRelativeUrl())
def test_do_nothing_if_validated_contract(self): def test_do_nothing_if_validated_contract(self):
person, instance, subscription = self.createNeededDocuments() person, instance, _ = self.createNeededDocuments()
contract = self.createCloudContract() contract = self.createCloudContract()
contract.edit(destination_section_value=person) contract.edit(destination_section_value=person)
contract.validate() contract.validate()
...@@ -128,7 +121,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin): ...@@ -128,7 +121,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
self.assertEquals(contract2.getValidationState(), "validated") self.assertEquals(contract2.getValidationState(), "validated")
def test_validate_contract_if_payment_found(self): def test_validate_contract_if_payment_found(self):
person, instance, subscription = self.createNeededDocuments() person, instance, _ = self.createNeededDocuments()
contract = self.createCloudContract() contract = self.createCloudContract()
contract.edit(destination_section_value=person) contract.edit(destination_section_value=person)
payment = self.createPaymentTransaction() payment = self.createPaymentTransaction()
...@@ -145,7 +138,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin): ...@@ -145,7 +138,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
self.assertEquals(contract2.getValidationState(), "validated") self.assertEquals(contract2.getValidationState(), "validated")
def test_create_invoice_if_needed_and_no_payment_found(self): def test_create_invoice_if_needed_and_no_payment_found(self):
person, instance, subscription = self.createNeededDocuments() person, instance, _ = self.createNeededDocuments()
contract = self.createCloudContract() contract = self.createCloudContract()
contract.edit(destination_section_value=person) contract.edit(destination_section_value=person)
self.assertEquals(contract.getValidationState(), "invalidated") self.assertEquals(contract.getValidationState(), "invalidated")
...@@ -173,7 +166,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin): ...@@ -173,7 +166,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
self.assertEquals(invoice.getStartDate(), invoice.getStopDate()) self.assertEquals(invoice.getStartDate(), invoice.getStopDate())
def test_do_nothing_if_invoice_is_ongoing(self): def test_do_nothing_if_invoice_is_ongoing(self):
person, instance, subscription = self.createNeededDocuments() person, instance, _ = self.createNeededDocuments()
contract = self.createCloudContract() contract = self.createCloudContract()
invoice = self.createInvoiceTransaction() invoice = self.createInvoiceTransaction()
self.portal.portal_workflow._jumpToStateFor(invoice, 'confirmed') self.portal.portal_workflow._jumpToStateFor(invoice, 'confirmed')
...@@ -190,7 +183,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin): ...@@ -190,7 +183,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
self.assertEquals(contract2.getValidationState(), "invalidated") self.assertEquals(contract2.getValidationState(), "invalidated")
def test_forget_current_cancelled_invoice(self): def test_forget_current_cancelled_invoice(self):
person, instance, subscription = self.createNeededDocuments() person, instance, _ = self.createNeededDocuments()
contract = self.createCloudContract() contract = self.createCloudContract()
invoice = self.createInvoiceTransaction() invoice = self.createInvoiceTransaction()
self.portal.portal_workflow._jumpToStateFor(invoice, 'cancelled') self.portal.portal_workflow._jumpToStateFor(invoice, 'cancelled')
...@@ -207,7 +200,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin): ...@@ -207,7 +200,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
self.assertEquals(contract2.getValidationState(), "invalidated") self.assertEquals(contract2.getValidationState(), "invalidated")
def test_forget_current_grouped_invoice(self): def test_forget_current_grouped_invoice(self):
person, instance, subscription = self.createNeededDocuments() person, instance, _ = self.createNeededDocuments()
contract = self.createCloudContract() contract = self.createCloudContract()
invoice = self.createInvoiceTransaction() invoice = self.createInvoiceTransaction()
line = invoice.newContent( line = invoice.newContent(
...@@ -230,7 +223,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin): ...@@ -230,7 +223,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
self.assertEquals(contract2.getValidationState(), "invalidated") self.assertEquals(contract2.getValidationState(), "invalidated")
def test_do_nothing_if_invoice_is_not_grouped(self): def test_do_nothing_if_invoice_is_not_grouped(self):
person, instance, subscription = self.createNeededDocuments() person, instance, _ = self.createNeededDocuments()
contract = self.createCloudContract() contract = self.createCloudContract()
invoice = self.createInvoiceTransaction() invoice = self.createInvoiceTransaction()
invoice.newContent( invoice.newContent(
...@@ -250,10 +243,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin): ...@@ -250,10 +243,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
self.assertEquals(contract2.getCausality(""), invoice.getRelativeUrl()) self.assertEquals(contract2.getCausality(""), invoice.getRelativeUrl())
self.assertEquals(contract2.getValidationState(), "invalidated") self.assertEquals(contract2.getValidationState(), "invalidated")
class TestSlapOSPerson_isAllowedToAllocate(testSlapOSMixin): class TestSlapOSPerson_isAllowedToAllocate(SlapOSTestCaseMixinWithAbort):
def beforeTearDown(self):
transaction.abort()
def createPerson(self): def createPerson(self):
new_id = self.generateNewId() new_id = self.generateNewId()
......
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSContractSkins</string> </value> <value> <string>testSlapOSContractSkins</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSContractSkins</string> </value> <value> <string>test.erp5.testSlapOSContractSkins</string> </value>
...@@ -33,28 +45,7 @@ ...@@ -33,28 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 65, 4: Unused variable \'person\' (unused-variable)</string>
<string>W: 65, 22: Unused variable \'subscription\' (unused-variable)</string>
<string>W: 72, 22: Unused variable \'subscription\' (unused-variable)</string>
<string>W: 81, 22: Unused variable \'subscription\' (unused-variable)</string>
<string>W: 92, 4: Unused variable \'person\' (unused-variable)</string>
<string>W: 92, 22: Unused variable \'subscription\' (unused-variable)</string>
<string>W:100, 4: Unused variable \'person\' (unused-variable)</string>
<string>W:100, 22: Unused variable \'subscription\' (unused-variable)</string>
<string>W:109, 4: Unused variable \'person\' (unused-variable)</string>
<string>W:109, 22: Unused variable \'subscription\' (unused-variable)</string>
<string>W:119, 22: Unused variable \'subscription\' (unused-variable)</string>
<string>W:131, 22: Unused variable \'subscription\' (unused-variable)</string>
<string>W:148, 22: Unused variable \'subscription\' (unused-variable)</string>
<string>W:176, 22: Unused variable \'subscription\' (unused-variable)</string>
<string>W:193, 22: Unused variable \'subscription\' (unused-variable)</string>
<string>W:210, 22: Unused variable \'subscription\' (unused-variable)</string>
<string>W:233, 22: Unused variable \'subscription\' (unused-variable)</string>
<string>W: 7, 0: Unused import wraps (unused-import)</string>
<string>W: 8, 0: Unused import createZODBPythonScript (unused-import)</string>
<string>W: 9, 0: Unused import difflib (unused-import)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -64,13 +55,28 @@ ...@@ -64,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -83,7 +89,7 @@ ...@@ -83,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -92,7 +98,7 @@ ...@@ -92,7 +98,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
......
##############################################################################
#
# Copyright (c) 2002-2018 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from DateTime import DateTime
from Products.ERP5Type.tests.utils import createZODBPythonScript
import transaction
import functools
from functools import wraps
def changeSkin(skin_name):
def decorator(func):
def wrapped(self, *args, **kwargs):
default_skin = self.portal.portal_skins.default_skin
self.portal.portal_skins.changeSkin(skin_name)
self.app.REQUEST.set('portal_skin', skin_name)
try:
v = func(self, *args, **kwargs)
finally:
self.portal.portal_skins.changeSkin(default_skin)
self.app.REQUEST.set('portal_skin', default_skin)
return v
return wrapped
return decorator
def simulate(script_id, params_string, code_string):
def upperWrap(f):
@wraps(f)
def decorated(self, *args, **kw):
if script_id in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_id)
createZODBPythonScript(self.portal.portal_skins.custom,
script_id, params_string, code_string)
transaction.commit()
try:
result = f(self, *args, **kw)
finally:
if script_id in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_id)
transaction.commit()
return result
return decorated
return upperWrap
def withAbort(func):
@functools.wraps(func)
def wrapped(self, *args, **kwargs):
try:
func(self, *args, **kwargs)
finally:
self.abort()
return wrapped
class SlapOSTestCaseMixin(testSlapOSMixin):
def afterSetUp(self):
testSlapOSMixin.afterSetUp(self)
self.new_id = self.generateNewId()
def makePerson(self, new_id=None, index=True, user=True):
if new_id is None:
new_id = self.generateNewId()
# Clone person document
person_user = self.portal.person_module.template_member.\
Base_createCloneDocument(batch_mode=1)
person_user.edit(
title="live_test_%s" % new_id,
reference="live_test_%s" % new_id,
default_email_text="live_test_%s@example.org" % new_id,
)
person_user.validate()
for assignment in person_user.contentValues(portal_type="Assignment"):
assignment.open()
if user:
login = self._addERP5Login(person_user)
if index:
transaction.commit()
person_user.immediateReindexObject()
if user:
login.immediateReindexObject()
return person_user
def _addERP5Login(self, document):
login = document.newContent(
portal_type="ERP5 Login",
reference=document.getReference())
login.validate()
return login
def _makeTree(self, requested_template_id='template_software_instance'):
new_id = self.generateNewId()
self.request_kw = dict(
software_release=self.generateNewSoftwareReleaseUrl(),
software_title=self.generateNewSoftwareTitle(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateEmptyXml(),
shared=False,
state="started"
)
self.person_user = self.makePerson(new_id=new_id, index=False)
self.commit()
# prepare part of tree
self.hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
self.software_instance = self.portal.software_instance_module\
[requested_template_id].Base_createCloneDocument(batch_mode=1)
self.hosting_subscription.edit(
title=self.request_kw['software_title'],
reference="TESTHS-%s" % new_id,
url_string=self.request_kw['software_release'],
source_reference=self.request_kw['software_type'],
text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'],
root_slave=self.request_kw['shared'],
predecessor=self.software_instance.getRelativeUrl(),
destination_section=self.person_user.getRelativeUrl()
)
self.hosting_subscription.validate()
self.portal.portal_workflow._jumpToStateFor(self.hosting_subscription, 'start_requested')
self.requested_software_instance = self.portal.software_instance_module\
.template_software_instance.Base_createCloneDocument(batch_mode=1)
self.software_instance.edit(
title=self.request_kw['software_title'],
reference="TESTSI-%s" % new_id,
url_string=self.request_kw['software_release'],
source_reference=self.request_kw['software_type'],
text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'],
specialise=self.hosting_subscription.getRelativeUrl(),
predecessor=self.requested_software_instance.getRelativeUrl()
)
self.portal.portal_workflow._jumpToStateFor(self.software_instance, 'start_requested')
self.software_instance.validate()
self.requested_software_instance.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
url_string=self.request_kw['software_release'],
source_reference=self.request_kw['software_type'],
text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'],
specialise=self.hosting_subscription.getRelativeUrl(),
)
self.portal.portal_workflow._jumpToStateFor(self.requested_software_instance, 'start_requested')
self.requested_software_instance.validate()
self.tic()
def _makeComputer(self, owner=None):
self.computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1)
reference = 'TESTCOMP-%s' % self.generateNewId()
self.computer.edit(
allocation_scope='open/public',
capacity_scope='open',
reference=reference,
title=reference
)
self.computer.validate()
reference = 'TESTPART-%s' % self.generateNewId()
self.partition = self.computer.newContent(portal_type='Computer Partition',
reference=reference,
title=reference
)
self.partition.markFree()
self.partition.validate()
self.tic()
if owner is not None:
self.computer.edit(
source_administration_value=owner,
)
return self.computer, self.partition
def _makeComputerNetwork(self):
reference = 'TESTCOMPNETWORK-%s' % self.generateNewId()
self.computer_network = self.portal.computer_network_module.newContent(
portal_type='Computer Network',
reference=reference,
title=reference
)
self.computer_network.validate()
self.tic()
return self.computer_network
def _makeComplexComputer(self, person=None, with_slave=False):
for i in range(1, 5):
id_ = 'partition%s' % i
p = self.computer.newContent(portal_type='Computer Partition',
id=id_,
title=id_,
reference=id_,
default_network_address_ip_address='ip_address_%s' % i,
default_network_address_netmask='netmask_%s' % i)
p.markFree()
p.validate()
self.start_requested_software_installation = self.portal.software_installation_module\
.template_software_installation.Base_createCloneDocument(batch_mode=1)
self.start_requested_software_installation.edit(
url_string=self.generateNewSoftwareReleaseUrl(),
aggregate=self.computer.getRelativeUrl(),
reference='TESTSOFTINST-%s' % self.generateNewId(),
title='Start requested for %s' % self.computer.getTitle()
)
self.start_requested_software_installation.validate()
self.start_requested_software_installation.requestStart()
self.destroy_requested_software_installation = self.portal.software_installation_module\
.template_software_installation.Base_createCloneDocument(batch_mode=1)
self.destroy_requested_software_installation.edit(
url_string=self.generateNewSoftwareReleaseUrl(),
aggregate=self.computer.getRelativeUrl(),
reference='TESTSOFTINST-%s' % self.generateNewId(),
title='Destroy requested for %s' % self.computer.getTitle()
)
self.destroy_requested_software_installation.validate()
self.destroy_requested_software_installation.requestStart()
self.destroy_requested_software_installation.requestDestroy()
self.destroyed_software_installation = self.portal.software_installation_module\
.template_software_installation.Base_createCloneDocument(batch_mode=1)
self.destroyed_software_installation.edit(
url_string=self.generateNewSoftwareReleaseUrl(),
aggregate=self.computer.getRelativeUrl(),
reference='TESTSOFTINST-%s' % self.generateNewId(),
title='Destroyed for %s' % self.computer.getTitle()
)
self.destroyed_software_installation.validate()
self.destroyed_software_installation.requestStart()
self.destroyed_software_installation.requestDestroy()
self.destroyed_software_installation.invalidate()
self.computer.partition1.markBusy()
self.computer.partition2.markBusy()
self.computer.partition3.markBusy()
# prepare some trees
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
destination_section_value=person,
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='started'
)
hosting_subscription.requestStart(**kw)
hosting_subscription.requestInstance(**kw)
self.start_requested_software_instance = hosting_subscription.getPredecessorValue()
self.start_requested_software_instance.edit(aggregate=self.computer.partition1.getRelativeUrl())
if with_slave:
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
destination_section_value=person,
)
slave_kw = dict(
software_release=kw['software_release'],
software_type=kw['software_type'],
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=True,
software_title=hosting_subscription.getTitle(),
state='started'
)
hosting_subscription.requestStart(**slave_kw)
hosting_subscription.requestInstance(**slave_kw)
self.start_requested_slave_instance = hosting_subscription.getPredecessorValue()
self.start_requested_slave_instance.edit(aggregate=self.computer.partition1.getRelativeUrl())
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
destination_section_value=person,
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='stopped'
)
hosting_subscription.requestStop(**kw)
hosting_subscription.requestInstance(**kw)
self.stop_requested_software_instance = hosting_subscription.getPredecessorValue()
self.stop_requested_software_instance.edit(
aggregate=self.computer.partition2.getRelativeUrl()
)
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='stopped'
)
hosting_subscription.requestStop(**kw)
hosting_subscription.requestInstance(**kw)
kw['state'] = 'destroyed'
hosting_subscription.requestDestroy(**kw)
self.destroy_requested_software_instance = hosting_subscription.getPredecessorValue()
self.destroy_requested_software_instance.requestDestroy(**kw)
self.destroy_requested_software_instance.edit(
aggregate=self.computer.partition3.getRelativeUrl()
)
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='stopped'
)
hosting_subscription.requestStop(**kw)
hosting_subscription.requestInstance(**kw)
kw['state'] = 'destroyed'
hosting_subscription.requestDestroy(**kw)
self.destroyed_software_instance = hosting_subscription.getPredecessorValue()
self.destroyed_software_instance.edit(
aggregate=self.computer.partition4.getRelativeUrl()
)
self.destroyed_software_instance.requestDestroy(**kw)
self.destroyed_software_instance.invalidate()
self.tic()
if with_slave:
# as slave is created in non usual way update its local roles
self.start_requested_slave_instance.updateLocalRolesOnSecurityGroups()
self.tic()
self._cleaupREQUEST()
def _makeSoftwareProduct(self, new_id):
software_product = self.portal.software_product_module\
.template_software_product.Base_createCloneDocument(batch_mode=1)
software_product.edit(
reference='TESTSOFTPROD-%s' % new_id,
title='Test software product %s' % new_id
)
software_product.publish()
return software_product
def _makeSoftwareRelease(self, new_id):
software_release = self.portal.software_release_module\
.template_software_release.Base_createCloneDocument(batch_mode=1)
software_release.edit(
url_string=self.generateNewSoftwareReleaseUrl(),
reference='TESTSOFTRELS-%s' % new_id,
title='Start requested for %s' % new_id
)
software_release.release()
return software_release
def generateNewSoftwareReleaseUrl(self):
return 'http://example.org/têst%s.cfg' % self.generateNewId()
def generateNewSoftwareType(self):
return 'Type ë@î %s' % self.generateNewId()
def generateNewSoftwareTitle(self):
return 'Title é#ï %s' % self.generateNewId()
def generateSafeXml(self):
return '<?xml version="1.0" encoding="utf-8"?><instance><parameter '\
'id="%s">%s</parameter></instance>' % \
("paramé".decode("UTF-8").encode("UTF-8"),
self.generateNewId().decode("UTF-8").encode("UTF-8"))
def generateEmptyXml(self):
return '<?xml version="1.0" encoding="utf-8"?><instance></instance>'
def _cleaupREQUEST(self):
self.portal.REQUEST['request_instance'] = None
self.portal.REQUEST.headers = {}
def generateNewId(self):
return "%sö" % self.portal.portal_ids.generateNewId(
id_group=('slapos_core_test'))
def createPaymentTransaction(self):
new_id = self.generateNewId()
return self.portal.accounting_module.newContent(
portal_type='Payment Transaction',
title="Transaction %s" % new_id,
reference="TESTTRANS-%s" % new_id,
)
def createSaleInvoiceTransaction(self):
new_id = self.generateNewId()
return self.portal.accounting_module.newContent(
portal_type='Sale Invoice Transaction',
title="Invoice %s" % new_id,
reference="TESTSIT-%s" % new_id,
)
def createPayzenEvent(self):
return self.portal.system_event_module.newContent(
portal_type='Payzen Event',
reference='PAY-%s' % self.generateNewId())
def createPayzenSaleInvoiceTransaction(self, destination_section=None, price=2):
new_title = self.generateNewId()
new_reference = self.generateNewId()
new_source_reference = self.generateNewId()
new_destination_reference = self.generateNewId()
invoice = self.portal.accounting_module.newContent(
portal_type="Sale Invoice Transaction",
title=new_title,
start_date=DateTime(),
reference=new_reference,
source_reference=new_source_reference,
destination_reference=new_destination_reference,
destination_section=destination_section,
payment_mode="payzen",
specialise="sale_trade_condition_module/slapos_aggregated_trade_condition",
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(invoice, 'stopped')
invoice.newContent(
title="",
portal_type="Invoice Line",
quantity=-2,
price=price,
)
invoice.newContent(
portal_type="Sale Invoice Transaction Line",
source="account_module/receivable",
quantity=-3,
)
payment = self.portal.accounting_module.newContent(
portal_type="Payment Transaction",
payment_mode="payzen",
causality_value=invoice,
destination_section=destination_section,
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
return invoice
def createRegularisationRequest(self):
new_id = self.generateNewId()
return self.portal.regularisation_request_module.newContent(
portal_type='Regularisation Request',
title="Test Reg. Req.%s" % new_id,
reference="TESTREGREQ-%s" % new_id,
resource='foo/bar',
)
class SlapOSTestCaseMixinWithAbort(SlapOSTestCaseMixin):
abort_transaction = 1
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SlapOSTestCaseMixin</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.SlapOSTestCaseMixin</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W:438, 0: Cannot decode using encoding "ascii", unexpected byte at position 32 (invalid-encoded-data)</string>
<string>W:441, 0: Cannot decode using encoding "ascii", unexpected byte at position 17 (invalid-encoded-data)</string>
<string>W:444, 0: Cannot decode using encoding "ascii", unexpected byte at position 18 (invalid-encoded-data)</string>
<string>W:449, 0: Cannot decode using encoding "ascii", unexpected byte at position 13 (invalid-encoded-data)</string>
<string>W:460, 0: Cannot decode using encoding "ascii", unexpected byte at position 14 (invalid-encoded-data)</string>
</tuple>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
import transaction import transaction
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin, simulate
testSlapOSMixin, simulate
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from unittest import skip from unittest import skip
import json import json
...@@ -11,11 +10,11 @@ from DateTime import DateTime ...@@ -11,11 +10,11 @@ from DateTime import DateTime
from Products.ERP5Type.DateUtils import addToDate from Products.ERP5Type.DateUtils import addToDate
from App.Common import rfc1123_date from App.Common import rfc1123_date
class TestSlapOSAllocation(testSlapOSMixin):
class TestSlapOSAllocation(SlapOSTestCaseMixin):
def _makeSlaveTree(self, requested_template_id='template_slave_instance'): def _makeSlaveTree(self, requested_template_id='template_slave_instance'):
super(TestSlapOSAllocation, self).\ SlapOSTestCaseMixin._makeTree(self, requested_template_id=requested_template_id)
_makeTree(requested_template_id=requested_template_id)
def _simulatePerson_isAllowedToAllocate(self): def _simulatePerson_isAllowedToAllocate(self):
script_name = 'Person_isAllowedToAllocate' script_name = 'Person_isAllowedToAllocate'
...@@ -904,11 +903,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -904,11 +903,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
return self.check_allocation_category_sla('storage_redundancy', 'dht', 'raid') return self.check_allocation_category_sla('storage_redundancy', 'dht', 'raid')
class TestSlapOSCoreSlapOSAssertHostingSubscriptionPredecessorAlarm( class TestSlapOSCoreSlapOSAssertHostingSubscriptionPredecessorAlarm(
testSlapOSMixin): SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSCoreSlapOSAssertHostingSubscriptionPredecessorAlarm, SlapOSTestCaseMixin.afterSetUp(self)
self).afterSetUp()
self._makeTree() self._makeTree()
def test_HostingSubscription_assertPredecessor(self): def test_HostingSubscription_assertPredecessor(self):
...@@ -1006,10 +1004,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by H ...@@ -1006,10 +1004,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by H
'Visited by HostingSubscription_assertPredecessor', 'Visited by HostingSubscription_assertPredecessor',
self.hosting_subscription.workflow_history['edit_workflow'][-1]['comment']) self.hosting_subscription.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSFreeComputerPartitionAlarm(testSlapOSMixin): class TestSlapOSFreeComputerPartitionAlarm(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSFreeComputerPartitionAlarm, self).afterSetUp() SlapOSTestCaseMixin.afterSetUp(self)
self._makeTree() self._makeTree()
def test_Instance_tryToUnallocatePartition(self): def test_Instance_tryToUnallocatePartition(self):
...@@ -1145,9 +1143,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by I ...@@ -1145,9 +1143,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by I
'Visited by Instance_tryToUnallocatePartition', 'Visited by Instance_tryToUnallocatePartition',
self.software_instance.workflow_history['edit_workflow'][-1]['comment']) self.software_instance.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSFreeComputerPartitionAlarmWithSlave(testSlapOSMixin): class TestSlapOSFreeComputerPartitionAlarmWithSlave(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSFreeComputerPartitionAlarmWithSlave, self).afterSetUp() SlapOSTestCaseMixin.afterSetUp(self)
self._makeTree(requested_template_id='template_slave_instance') self._makeTree(requested_template_id='template_slave_instance')
def test_Instance_tryToUnallocatePartition(self): def test_Instance_tryToUnallocatePartition(self):
...@@ -1176,10 +1174,10 @@ class TestSlapOSFreeComputerPartitionAlarmWithSlave(testSlapOSMixin): ...@@ -1176,10 +1174,10 @@ class TestSlapOSFreeComputerPartitionAlarmWithSlave(testSlapOSMixin):
self.assertEqual('busy', self.partition.getSlapState()) self.assertEqual('busy', self.partition.getSlapState())
class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(testSlapOSMixin): class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSGarbageCollectDestroyedRootTreeAlarm, self).afterSetUp() SlapOSTestCaseMixin.afterSetUp(self)
self._makeTree() self._makeTree()
def test_Instance_tryToGarbageCollect(self): def test_Instance_tryToGarbageCollect(self):
...@@ -1344,10 +1342,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by I ...@@ -1344,10 +1342,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by I
'Visited by Instance_tryToGarbageCollect', 'Visited by Instance_tryToGarbageCollect',
self.software_instance.workflow_history['edit_workflow'][-1]['comment']) self.software_instance.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSUpdateComputerCapacityScopeAlarm(testSlapOSMixin): class TestSlapOSUpdateComputerCapacityScopeAlarm(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSUpdateComputerCapacityScopeAlarm, self).afterSetUp() SlapOSTestCaseMixin.afterSetUp(self)
self.computer = self.portal.computer_module.template_computer\ self.computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1) .Base_createCloneDocument(batch_mode=1)
self.computer.edit( self.computer.edit(
...@@ -1363,7 +1361,7 @@ class TestSlapOSUpdateComputerCapacityScopeAlarm(testSlapOSMixin): ...@@ -1363,7 +1361,7 @@ class TestSlapOSUpdateComputerCapacityScopeAlarm(testSlapOSMixin):
'text': '#access ok', 'text': '#access ok',
'created_at': rfc1123_date(DateTime()) 'created_at': rfc1123_date(DateTime())
}) })
self.commit() transaction.commit()
def test_Computer_checkAndUpdateCapacityScope(self): def test_Computer_checkAndUpdateCapacityScope(self):
self.computer.Computer_checkAndUpdateCapacityScope() self.computer.Computer_checkAndUpdateCapacityScope()
...@@ -1542,7 +1540,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -1542,7 +1540,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
'Visited by Computer_checkAndUpdateCapacityScope', 'Visited by Computer_checkAndUpdateCapacityScope',
self.computer.workflow_history['edit_workflow'][-1]['comment']) self.computer.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSGarbageCollectStoppedRootTreeAlarm(testSlapOSMixin): class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
def createInstance(self): def createInstance(self):
hosting_subscription = self.portal.hosting_subscription_module\ hosting_subscription = self.portal.hosting_subscription_module\
...@@ -1654,7 +1652,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by I ...@@ -1654,7 +1652,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by I
'Visited by Instance_tryToStopCollect', 'Visited by Instance_tryToStopCollect',
instance.workflow_history['edit_workflow'][-1]['comment']) instance.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(testSlapOSMixin): class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
def createInstance(self): def createInstance(self):
hosting_subscription = self.portal.hosting_subscription_module\ hosting_subscription = self.portal.hosting_subscription_module\
...@@ -1859,7 +1857,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by I ...@@ -1859,7 +1857,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by I
'Visited by Instance_tryToGarbageCollectNonAllocatedRootTree', 'Visited by Instance_tryToGarbageCollectNonAllocatedRootTree',
instance.workflow_history['edit_workflow'][-1]['comment']) instance.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(testSlapOSMixin): class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
def createInstance(self): def createInstance(self):
hosting_subscription = self.portal.hosting_subscription_module\ hosting_subscription = self.portal.hosting_subscription_module\
...@@ -2105,7 +2103,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -2105,7 +2103,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
'Visited by SoftwareInstance_tryToGarbageUnlinkedInstance', 'Visited by SoftwareInstance_tryToGarbageUnlinkedInstance',
slave_instance0.workflow_history['edit_workflow'][-1]['comment']) slave_instance0.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSInvalidateDestroyedInstance(testSlapOSMixin): class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin):
def createSoftwareInstance(self): def createSoftwareInstance(self):
new_id = self.generateNewId() new_id = self.generateNewId()
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
# Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved.
# #
############################################################################## ##############################################################################
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
testSlapOSMixin
import transaction import transaction
class TestSlapOSConstraintMixin(testSlapOSMixin): class TestSlapOSConstraintMixin(SlapOSTestCaseMixin):
@staticmethod @staticmethod
def getMessageList(o): def getMessageList(o):
return [str(q.getMessage()) for q in o.checkConsistency()] return [str(q.getMessage()) for q in o.checkConsistency()]
......
...@@ -29,11 +29,11 @@ ...@@ -29,11 +29,11 @@
import unittest import unittest
import random import random
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from Products.SlapOS.tests.testSlapOSMixin import testSlapOSMixin from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
from Products.PluggableAuthService.interfaces.plugins import\ from Products.PluggableAuthService.interfaces.plugins import\
IAuthenticationPlugin IAuthenticationPlugin
class TestSlapOSSecurityMixin(testSlapOSMixin): class TestSlapOSSecurityMixin(SlapOSTestCaseMixin):
def _generateRandomUniqueUserId(self, portal_type, search_key="user_id"): def _generateRandomUniqueUserId(self, portal_type, search_key="user_id"):
user_id = None user_id = None
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
testSlapOSMixin
import transaction import transaction
from unittest import expectedFailure from unittest import expectedFailure
from Products.ERP5Type.Errors import UnsupportedWorkflowMethod from Products.ERP5Type.Errors import UnsupportedWorkflowMethod
...@@ -8,10 +7,10 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed ...@@ -8,10 +7,10 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed
from AccessControl.SecurityManagement import getSecurityManager, \ from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager setSecurityManager
class TestSlapOSCoreComputerPartitionSlapInterfaceWorkflow(testSlapOSMixin): class TestSlapOSCoreComputerPartitionSlapInterfaceWorkflow(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
self.login() self.login()
super(TestSlapOSCoreComputerPartitionSlapInterfaceWorkflow, self).afterSetUp() SlapOSTestCaseMixin.afterSetUp(self)
# Clone computer document # Clone computer document
self.computer = self.portal.computer_module.template_computer\ self.computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1) .Base_createCloneDocument(batch_mode=1)
...@@ -100,9 +99,9 @@ class TestSlapOSCoreComputerPartitionSlapInterfaceWorkflow(testSlapOSMixin): ...@@ -100,9 +99,9 @@ class TestSlapOSCoreComputerPartitionSlapInterfaceWorkflow(testSlapOSMixin):
self.assertEqual(1, self.portal.portal_catalog.countResults( self.assertEqual(1, self.portal.portal_catalog.countResults(
parent_uid=self.computer.getUid(), free_for_request=1)[0][0]) parent_uid=self.computer.getUid(), free_for_request=1)[0][0])
class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin): class TestSlapOSCoreComputerSlapInterfaceWorkflow(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSCoreComputerSlapInterfaceWorkflow, self).afterSetUp() SlapOSTestCaseMixin.afterSetUp(self)
# Clone computer document # Clone computer document
self.computer = self.portal.computer_module.template_computer\ self.computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1) .Base_createCloneDocument(batch_mode=1)
...@@ -115,7 +114,7 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin): ...@@ -115,7 +114,7 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin):
self.tic() self.tic()
def beforeTearDown(self): def beforeTearDown(self):
super(TestSlapOSCoreComputerSlapInterfaceWorkflow, self).beforeTearDown() SlapOSTestCaseMixin.beforeTearDown(self)
self.portal.REQUEST['computer_key'] = None self.portal.REQUEST['computer_key'] = None
self.portal.REQUEST['computer_certificate'] = None self.portal.REQUEST['computer_certificate'] = None
...@@ -367,10 +366,10 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin): ...@@ -367,10 +366,10 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin):
self.assertEqual(None, self.portal.REQUEST.get('computer_certificate')) self.assertEqual(None, self.portal.REQUEST.get('computer_certificate'))
self.assertEqual(None, self.computer.getDestinationReference()) self.assertEqual(None, self.computer.getDestinationReference())
class TestSlapOSCorePersonComputerSupply(testSlapOSMixin): class TestSlapOSCorePersonComputerSupply(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSCorePersonComputerSupply, self).afterSetUp() SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject() portal = self.getPortalObject()
# Clone computer document # Clone computer document
...@@ -674,9 +673,9 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin): ...@@ -674,9 +673,9 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin):
self.assertEqual('SOFTINSTALL-%s' % (previous_id+2), self.assertEqual('SOFTINSTALL-%s' % (previous_id+2),
software_installation.getReference()) software_installation.getReference())
class TestSlapOSCoreInstanceSlapInterfaceWorkflow(testSlapOSMixin): class TestSlapOSCoreInstanceSlapInterfaceWorkflow(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSCoreInstanceSlapInterfaceWorkflow, self).afterSetUp() SlapOSTestCaseMixin.afterSetUp(self)
hosting_subscription = self.portal.hosting_subscription_module\ hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1) .template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
...@@ -1071,11 +1070,11 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflow(testSlapOSMixin): ...@@ -1071,11 +1070,11 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflow(testSlapOSMixin):
connection_xml="<foo bar /<>") connection_xml="<foo bar /<>")
transaction.abort() transaction.abort()
class TestSlapOSCoreSoftwareInstanceRequest(testSlapOSMixin): class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
"""Tests instance.requestInstance""" """Tests instance.requestInstance"""
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSCoreSoftwareInstanceRequest, self).afterSetUp() SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject() portal = self.getPortalObject()
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -1909,10 +1908,10 @@ class TestSlapOSCoreSoftwareInstanceRequest(testSlapOSMixin): ...@@ -1909,10 +1908,10 @@ class TestSlapOSCoreSoftwareInstanceRequest(testSlapOSMixin):
self.assertEqual(bang_amount+1, self._countBang(self.software_instance)) self.assertEqual(bang_amount+1, self._countBang(self.software_instance))
class TestSlapOSCorePersonRequest(testSlapOSMixin): class TestSlapOSCorePersonRequest(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSCorePersonRequest, self).afterSetUp() SlapOSTestCaseMixin.afterSetUp(self)
person_user = self.makePerson() person_user = self.makePerson()
self.tic() self.tic()
...@@ -2454,13 +2453,13 @@ class TestSlapOSCorePersonRequest(testSlapOSMixin): ...@@ -2454,13 +2453,13 @@ class TestSlapOSCorePersonRequest(testSlapOSMixin):
self.assertNotEquals(hosting_subscription.getRelativeUrl(), self.assertNotEquals(hosting_subscription.getRelativeUrl(),
hosting_subscription2.getRelativeUrl()) hosting_subscription2.getRelativeUrl())
class TestSlapOSCorePersonRequestComputer(testSlapOSMixin): class TestSlapOSCorePersonRequestComputer(SlapOSTestCaseMixin):
def generateNewComputerTitle(self): def generateNewComputerTitle(self):
return 'My Comp %s' % self.generateNewId() return 'My Comp %s' % self.generateNewId()
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSCorePersonRequestComputer, self).afterSetUp() SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject() portal = self.getPortalObject()
person_user = self.makePerson() person_user = self.makePerson()
...@@ -2654,7 +2653,7 @@ class TestSlapOSCorePersonRequestComputer(testSlapOSMixin): ...@@ -2654,7 +2653,7 @@ class TestSlapOSCorePersonRequestComputer(testSlapOSMixin):
self.assertRaises(NotImplementedError, person.requestComputer, self.assertRaises(NotImplementedError, person.requestComputer,
computer_title=computer_title) computer_title=computer_title)
class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin): class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin):
def test_Computer_setSubjectList(self): def test_Computer_setSubjectList(self):
self.person_user = self.makePerson() self.person_user = self.makePerson()
......
...@@ -3,3 +3,4 @@ test.erp5.testSlapOSCloudWorkflow ...@@ -3,3 +3,4 @@ test.erp5.testSlapOSCloudWorkflow
test.erp5.testSlapOSCloudSecurityGroup test.erp5.testSlapOSCloudSecurityGroup
test.erp5.testSlapOSCloudConstraint test.erp5.testSlapOSCloudConstraint
test.erp5.testSlapOSCloudShadow test.erp5.testSlapOSCloudShadow
test.erp5.SlapOSTestCaseMixin
\ No newline at end of file
...@@ -5,14 +5,14 @@ ...@@ -5,14 +5,14 @@
# #
############################################################################## ##############################################################################
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import \
testSlapOSMixin SlapOSTestCaseMixin
import os import os
class TestSlapOSConfigurator(testSlapOSMixin): class TestSlapOSConfigurator(SlapOSTestCaseMixin):
def bootstrapSite(self): def bootstrapSite(self):
super(TestSlapOSConfigurator, self).bootstrapSite() SlapOSTestCaseMixin.bootstrapSite(self)
self.getBusinessConfiguration().BusinessConfiguration_invokeSlapOSMasterPromiseAlarmList() self.getBusinessConfiguration().BusinessConfiguration_invokeSlapOSMasterPromiseAlarmList()
self.tic() self.tic()
......
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction import transaction
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import \
testSlapOSMixin SlapOSTestCaseMixin
from unittest import skip from unittest import skip
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestSlapOSCRMCreateRegularisationRequest(testSlapOSMixin): class TestSlapOSCRMCreateRegularisationRequest(SlapOSTestCaseMixin):
def _simulatePerson_checkToCreateRegularisationRequest(self): def _simulatePerson_checkToCreateRegularisationRequest(self):
script_name = 'Person_checkToCreateRegularisationRequest' script_name = 'Person_checkToCreateRegularisationRequest'
...@@ -92,7 +92,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P ...@@ -92,7 +92,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P
'Visited by Person_checkToCreateRegularisationRequest', 'Visited by Person_checkToCreateRegularisationRequest',
person.workflow_history['edit_workflow'][-1]['comment']) person.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmInvalidateSuspendedRegularisationRequest(testSlapOSMixin): class TestSlapOSCrmInvalidateSuspendedRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() transaction.abort()
...@@ -156,7 +156,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -156,7 +156,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_invalidateIfPersonBalanceIsOk', 'Visited by RegularisationRequest_invalidateIfPersonBalanceIsOk',
ticket.workflow_history['edit_workflow'][-1]['comment']) ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmCancelInvoiceRelatedToSuspendedRegularisationRequest(testSlapOSMixin): class TestSlapOSCrmCancelInvoiceRelatedToSuspendedRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() transaction.abort()
...@@ -220,7 +220,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -220,7 +220,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty', 'Visited by RegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty',
ticket.workflow_history['edit_workflow'][-1]['comment']) ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmTriggerEscalationOnAcknowledgmentRegularisationRequest(testSlapOSMixin): class TestSlapOSCrmTriggerEscalationOnAcknowledgmentRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() transaction.abort()
...@@ -303,7 +303,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -303,7 +303,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_triggerAcknowledgmentEscalation', 'Visited by RegularisationRequest_triggerAcknowledgmentEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment']) ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmTriggerEscalationOnStopReminderRegularisationRequest(testSlapOSMixin): class TestSlapOSCrmTriggerEscalationOnStopReminderRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() transaction.abort()
...@@ -386,7 +386,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -386,7 +386,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_triggerStopReminderEscalation', 'Visited by RegularisationRequest_triggerStopReminderEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment']) ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmTriggerEscalationOnStopAcknowledgmentRegularisationRequest(testSlapOSMixin): class TestSlapOSCrmTriggerEscalationOnStopAcknowledgmentRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() transaction.abort()
...@@ -469,7 +469,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -469,7 +469,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_triggerStopAcknowledgmentEscalation', 'Visited by RegularisationRequest_triggerStopAcknowledgmentEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment']) ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmTriggerEscalationOnDeleteReminderRegularisationRequest(testSlapOSMixin): class TestSlapOSCrmTriggerEscalationOnDeleteReminderRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() transaction.abort()
...@@ -552,7 +552,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -552,7 +552,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_triggerDeleteReminderEscalation', 'Visited by RegularisationRequest_triggerDeleteReminderEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment']) ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmStopHostingSubscription(testSlapOSMixin): class TestSlapOSCrmStopHostingSubscription(SlapOSTestCaseMixin):
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() transaction.abort()
...@@ -654,7 +654,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -654,7 +654,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_stopHostingSubscriptionList', 'Visited by RegularisationRequest_stopHostingSubscriptionList',
ticket.workflow_history['edit_workflow'][-1]['comment']) ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmDeleteHostingSubscription(testSlapOSMixin): class TestSlapOSCrmDeleteHostingSubscription(SlapOSTestCaseMixin):
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() transaction.abort()
...@@ -738,8 +738,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -738,8 +738,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_deleteHostingSubscriptionList', 'Visited by RegularisationRequest_deleteHostingSubscriptionList',
ticket.workflow_history['edit_workflow'][-1]['comment']) ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmMonitoringCheckComputerState(SlapOSTestCaseMixin):
class TestSlapOSCrmMonitoringCheckComputerState(testSlapOSMixin):
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() transaction.abort()
...@@ -825,7 +824,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -825,7 +824,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
allocation_scope='closed/termination') allocation_scope='closed/termination')
class TestSlapOSCrmMonitoringCheckComputerAllocationScope(testSlapOSMixin): class TestSlapOSCrmMonitoringCheckComputerAllocationScope(SlapOSTestCaseMixin):
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() transaction.abort()
...@@ -909,7 +908,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -909,7 +908,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
self.computer.workflow_history['edit_workflow'][-1]['comment']) self.computer.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmMonitoringCheckComputerPersonalAllocationScope(testSlapOSMixin): class TestSlapOSCrmMonitoringCheckComputerPersonalAllocationScope(SlapOSTestCaseMixin):
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() transaction.abort()
...@@ -1007,7 +1006,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -1007,7 +1006,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
self.assertNotEqual('Visited by Computer_checkAndUpdatePersonalAllocationScope', self.assertNotEqual('Visited by Computer_checkAndUpdatePersonalAllocationScope',
self.computer.workflow_history['edit_workflow'][-1]['comment']) self.computer.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmMonitoringCheckInstanceInError(testSlapOSMixin): class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixin):
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() transaction.abort()
...@@ -1089,7 +1088,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by H ...@@ -1089,7 +1088,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by H
self.assertNotEqual('Visited by HostingSubscription_checkSoftwareInstanceState', self.assertNotEqual('Visited by HostingSubscription_checkSoftwareInstanceState',
host_sub.workflow_history['edit_workflow'][-1]['comment']) host_sub.workflow_history['edit_workflow'][-1]['comment'])
class TestSlaposCrmUpdateSupportRequestState(testSlapOSMixin): class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixin):
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() transaction.abort()
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple>
<string>W:1127, 0: Cannot decode using encoding "ascii", unexpected byte at position 32 (invalid-encoded-data)</string> <string>W:1105, 0: Cannot decode using encoding "ascii", unexpected byte at position 32 (invalid-encoded-data)</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction import transaction
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import \
testSlapOSMixin, simulate SlapOSTestCaseMixin,SlapOSTestCaseMixinWithAbort, simulate
from zExceptions import Unauthorized from zExceptions import Unauthorized
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
...@@ -11,12 +11,10 @@ import json ...@@ -11,12 +11,10 @@ import json
def getFakeSlapState(): def getFakeSlapState():
return "destroy_requested" return "destroy_requested"
class TestCRMSkinsMixin(testSlapOSMixin): class TestCRMSkinsMixin(SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def afterSetUp(self): def afterSetUp(self):
super(TestCRMSkinsMixin, self).afterSetUp() SlapOSTestCaseMixinWithAbort.afterSetUp(self)
self.person = self.makePerson(new_id=self.new_id, index=0, user=0) self.person = self.makePerson(new_id=self.new_id, index=0, user=0)
def _cancelTestSupportRequestList(self, title="%"): def _cancelTestSupportRequestList(self, title="%"):
...@@ -315,9 +313,7 @@ class TestSlapOSTicket_getLatestEvent(TestSlapOSTicketEvent): ...@@ -315,9 +313,7 @@ class TestSlapOSTicket_getLatestEvent(TestSlapOSTicketEvent):
self._test_event(ticket) self._test_event(ticket)
class TestSlapOSPerson_checkToCreateRegularisationRequest(testSlapOSMixin): class TestSlapOSPerson_checkToCreateRegularisationRequest(SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
@simulate('Entity_statBalance', '*args, **kwargs', 'return "1"') @simulate('Entity_statBalance', '*args, **kwargs', 'return "1"')
def test_addRegularisationRequest_payment_requested(self): def test_addRegularisationRequest_payment_requested(self):
...@@ -498,9 +494,7 @@ The slapos team ...@@ -498,9 +494,7 @@ The slapos team
class TestSlapOSRegularisationRequest_invalidateIfPersonBalanceIsOk( class TestSlapOSRegularisationRequest_invalidateIfPersonBalanceIsOk(
testSlapOSMixin): SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createRegularisationRequest(self): def createRegularisationRequest(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -554,9 +548,7 @@ class TestSlapOSRegularisationRequest_invalidateIfPersonBalanceIsOk( ...@@ -554,9 +548,7 @@ class TestSlapOSRegularisationRequest_invalidateIfPersonBalanceIsOk(
ticket.RegularisationRequest_invalidateIfPersonBalanceIsOk() ticket.RegularisationRequest_invalidateIfPersonBalanceIsOk()
self.assertEquals(ticket.getSimulationState(), 'suspended') self.assertEquals(ticket.getSimulationState(), 'suspended')
class TestSlapOSRegularisationRequest_checkToSendUniqEvent(testSlapOSMixin): class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
abort_transaction = 1
def createRegularisationRequest(self): def createRegularisationRequest(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -686,9 +678,7 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(testSlapOSMixin): ...@@ -686,9 +678,7 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(testSlapOSMixin):
REQUEST={}) REQUEST={})
class TestSlapOSRegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty( class TestSlapOSRegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty(
testSlapOSMixin): SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createRegularisationRequest(self): def createRegularisationRequest(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -915,9 +905,7 @@ The slapos team ...@@ -915,9 +905,7 @@ The slapos team
self.assertEqual(invoice_list, []) self.assertEqual(invoice_list, [])
class TestSlapOSRegularisationRequest_checkToTriggerNextEscalationStep( class TestSlapOSRegularisationRequest_checkToTriggerNextEscalationStep(
testSlapOSMixin): SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createRegularisationRequest(self): def createRegularisationRequest(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -1112,18 +1100,7 @@ class TestSlapOSRegularisationRequest_checkToTriggerNextEscalationStep( ...@@ -1112,18 +1100,7 @@ class TestSlapOSRegularisationRequest_checkToTriggerNextEscalationStep(
REQUEST={}) REQUEST={})
class TestSlapOSRegularisationRequest_triggerAcknowledgmentEscalation( class TestSlapOSRegularisationRequest_triggerAcknowledgmentEscalation(
testSlapOSMixin): SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createRegularisationRequest(self):
new_id = self.generateNewId()
return self.portal.regularisation_request_module.newContent(
portal_type='Regularisation Request',
title="Test Reg. Req.%s" % new_id,
reference="TESTREGREQ-%s" % new_id,
resource='foo/bar',
)
def test_triggerAcknowledgmentEscalation_REQUEST_disallowed(self): def test_triggerAcknowledgmentEscalation_REQUEST_disallowed(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -1197,18 +1174,7 @@ The slapos team ...@@ -1197,18 +1174,7 @@ The slapos team
ticket.workflow_history['edit_workflow'][-1]['comment']) ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSRegularisationRequest_triggerStopReminderEscalation( class TestSlapOSRegularisationRequest_triggerStopReminderEscalation(
testSlapOSMixin): SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createRegularisationRequest(self):
new_id = self.generateNewId()
return self.portal.regularisation_request_module.newContent(
portal_type='Regularisation Request',
title="Test Reg. Req.%s" % new_id,
reference="TESTREGREQ-%s" % new_id,
resource='foo/bar',
)
def test_triggerStopReminderEscalation_REQUEST_disallowed(self): def test_triggerStopReminderEscalation_REQUEST_disallowed(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -1282,18 +1248,7 @@ The slapos team ...@@ -1282,18 +1248,7 @@ The slapos team
ticket.workflow_history['edit_workflow'][-1]['comment']) ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSRegularisationRequest_triggerStopAcknowledgmentEscalation( class TestSlapOSRegularisationRequest_triggerStopAcknowledgmentEscalation(
testSlapOSMixin): SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createRegularisationRequest(self):
new_id = self.generateNewId()
return self.portal.regularisation_request_module.newContent(
portal_type='Regularisation Request',
title="Test Reg. Req.%s" % new_id,
reference="TESTREGREQ-%s" % new_id,
resource='foo/bar',
)
def test_triggerStopAcknowledgmentEscalation_REQUEST_disallowed(self): def test_triggerStopAcknowledgmentEscalation_REQUEST_disallowed(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -1367,18 +1322,7 @@ The slapos team ...@@ -1367,18 +1322,7 @@ The slapos team
ticket.workflow_history['edit_workflow'][-1]['comment']) ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSRegularisationRequest_triggerDeleteReminderEscalation( class TestSlapOSRegularisationRequest_triggerDeleteReminderEscalation(
testSlapOSMixin): SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createRegularisationRequest(self):
new_id = self.generateNewId()
return self.portal.regularisation_request_module.newContent(
portal_type='Regularisation Request',
title="Test Reg. Req.%s" % new_id,
reference="TESTREGREQ-%s" % new_id,
resource='foo/bar',
)
def test_triggerDeleteReminderEscalation_REQUEST_disallowed(self): def test_triggerDeleteReminderEscalation_REQUEST_disallowed(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -1452,18 +1396,7 @@ The slapos team ...@@ -1452,18 +1396,7 @@ The slapos team
ticket.workflow_history['edit_workflow'][-1]['comment']) ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSRegularisationRequest_stopHostingSubscriptionList( class TestSlapOSRegularisationRequest_stopHostingSubscriptionList(
testSlapOSMixin): SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createRegularisationRequest(self):
new_id = self.generateNewId()
return self.portal.regularisation_request_module.newContent(
portal_type='Regularisation Request',
title="Test Reg. Req.%s" % new_id,
reference="TESTREGREQ-%s" % new_id,
resource='foo/bar',
)
def createHostingSubscription(self): def createHostingSubscription(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -1638,9 +1571,7 @@ class TestSlapOSRegularisationRequest_stopHostingSubscriptionList( ...@@ -1638,9 +1571,7 @@ class TestSlapOSRegularisationRequest_stopHostingSubscriptionList(
self.tic() self.tic()
class TestSlapOSHostingSubscription_stopFromRegularisationRequest( class TestSlapOSHostingSubscription_stopFromRegularisationRequest(
testSlapOSMixin): SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createHostingSubscription(self): def createHostingSubscription(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -1711,9 +1642,7 @@ class TestSlapOSHostingSubscription_stopFromRegularisationRequest( ...@@ -1711,9 +1642,7 @@ class TestSlapOSHostingSubscription_stopFromRegularisationRequest(
'foobar') 'foobar')
class TestSlapOSHostingSubscription_deleteFromRegularisationRequest( class TestSlapOSHostingSubscription_deleteFromRegularisationRequest(
testSlapOSMixin): SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createHostingSubscription(self): def createHostingSubscription(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -1814,9 +1743,7 @@ class TestSlapOSHostingSubscription_deleteFromRegularisationRequest( ...@@ -1814,9 +1743,7 @@ class TestSlapOSHostingSubscription_deleteFromRegularisationRequest(
'foobar') 'foobar')
class TestSlapOSRegularisationRequest_deleteHostingSubscriptionList( class TestSlapOSRegularisationRequest_deleteHostingSubscriptionList(
testSlapOSMixin): SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createRegularisationRequest(self): def createRegularisationRequest(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -1970,11 +1897,11 @@ class TestSlapOSRegularisationRequest_deleteHostingSubscriptionList( ...@@ -1970,11 +1897,11 @@ class TestSlapOSRegularisationRequest_deleteHostingSubscriptionList(
class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin): class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSComputer_notifyWrongAllocationScope, self).afterSetUp() TestCRMSkinsMixin.afterSetUp(self)
self._cancelTestSupportRequestList(title="%%TESTCOMPT-%") self._cancelTestSupportRequestList(title="%%TESTCOMPT-%")
def _makeComputer(self): def _makeComputer(self):
super(TestSlapOSComputer_notifyWrongAllocationScope, self)._makeComputer() TestCRMSkinsMixin._makeComputer(self)
# Clone computer document # Clone computer document
self.computer.edit( self.computer.edit(
...@@ -2142,12 +2069,10 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -2142,12 +2069,10 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin):
self.assertEquals(computer.getAllocationScope(), 'open/friend') self.assertEquals(computer.getAllocationScope(), 'open/friend')
class TestComputer_hasContactedRecently(testSlapOSMixin): class TestComputer_hasContactedRecently(SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def _makeComputer(self): def _makeComputer(self):
super(TestComputer_hasContactedRecently, self)._makeComputer() SlapOSTestCaseMixinWithAbort._makeComputer(self)
return self.computer return self.computer
def createSPL(self, computer): def createSPL(self, computer):
...@@ -2239,7 +2164,7 @@ class TestComputer_hasContactedRecently(testSlapOSMixin): ...@@ -2239,7 +2164,7 @@ class TestComputer_hasContactedRecently(testSlapOSMixin):
has_contacted = computer.Computer_hasContactedRecently() has_contacted = computer.Computer_hasContactedRecently()
self.assertFalse(has_contacted) self.assertFalse(has_contacted)
class TestSlapOSPerson_isServiceProvider(testSlapOSMixin): class TestSlapOSPerson_isServiceProvider(SlapOSTestCaseMixin):
abort_transaction = 1 abort_transaction = 1
...@@ -2268,7 +2193,7 @@ class TestSlapOSPerson_isServiceProvider(testSlapOSMixin): ...@@ -2268,7 +2193,7 @@ class TestSlapOSPerson_isServiceProvider(testSlapOSMixin):
class TestSlapOSisSupportRequestCreationClosed(TestCRMSkinsMixin): class TestSlapOSisSupportRequestCreationClosed(TestCRMSkinsMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSisSupportRequestCreationClosed, self).afterSetUp() TestCRMSkinsMixin.afterSetUp(self)
self._cancelTestSupportRequestList() self._cancelTestSupportRequestList()
def test_ERP5Site_isSupportRequestCreationClosed(self): def test_ERP5Site_isSupportRequestCreationClosed(self):
...@@ -2354,7 +2279,7 @@ class TestSlapOSisSupportRequestCreationClosed(TestCRMSkinsMixin): ...@@ -2354,7 +2279,7 @@ class TestSlapOSisSupportRequestCreationClosed(TestCRMSkinsMixin):
class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin): class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSGenerateSupportRequestForSlapOS, self).afterSetUp() TestCRMSkinsMixin.afterSetUp(self)
self.tic() self.tic()
self._cancelTestSupportRequestList() self._cancelTestSupportRequestList()
...@@ -2390,8 +2315,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin): ...@@ -2390,8 +2315,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin):
hosting_subscription.requestInstance(**kw) hosting_subscription.requestInstance(**kw)
def _makeComputer(self): def _makeComputer(self):
super(TestSlapOSGenerateSupportRequestForSlapOS, self)._makeComputer() SlapOSTestCaseMixin._makeComputer(self)
# Clone computer document # Clone computer document
self.computer.edit( self.computer.edit(
source_administration_value=self.makePerson(user=0) source_administration_value=self.makePerson(user=0)
...@@ -2597,7 +2521,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin): ...@@ -2597,7 +2521,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin):
transaction.abort() transaction.abort()
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSComputer_CheckState, self).afterSetUp() TestCRMSkinsMixin.afterSetUp(self)
self._cancelTestSupportRequestList("% TESTCOMPT-%") self._cancelTestSupportRequestList("% TESTCOMPT-%")
def _makeSupportRequest(self): def _makeSupportRequest(self):
...@@ -2627,7 +2551,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin): ...@@ -2627,7 +2551,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin):
return support_request return support_request
def _makeComputer(self): def _makeComputer(self):
super(TestSlapOSComputer_CheckState, self)._makeComputer() TestCRMSkinsMixin._makeComputer(self)
# Clone computer document # Clone computer document
self.computer.edit( self.computer.edit(
...@@ -2770,7 +2694,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin): ...@@ -2770,7 +2694,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin):
ticket.workflow_history['edit_workflow'][-1]['comment']) ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSHostingSubscription_createSupportRequestEvent(testSlapOSMixin): class TestSlapOSHostingSubscription_createSupportRequestEvent(SlapOSTestCaseMixin):
def _makeNotificationMessage(self, reference): def _makeNotificationMessage(self, reference):
notification_message = self.portal.notification_message_module.newContent( notification_message = self.portal.notification_message_module.newContent(
...@@ -2869,7 +2793,7 @@ class TestSlapOSHostingSubscription_createSupportRequestEvent(testSlapOSMixin): ...@@ -2869,7 +2793,7 @@ class TestSlapOSHostingSubscription_createSupportRequestEvent(testSlapOSMixin):
hosting_subscription.HostingSubscription_createSupportRequestEvent( hosting_subscription.HostingSubscription_createSupportRequestEvent(
hosting_subscription, "test-slapos-crm-check.notification")) hosting_subscription, "test-slapos-crm-check.notification"))
class TestSlapOSHasError(testSlapOSMixin): class TestSlapOSHasError(SlapOSTestCaseMixin):
def _makeSoftwareRelease(self, software_release_url=None): def _makeSoftwareRelease(self, software_release_url=None):
software_release = self.portal.software_release_module\ software_release = self.portal.software_release_module\
...@@ -3154,11 +3078,10 @@ class TestSlapOSHasError(testSlapOSMixin): ...@@ -3154,11 +3078,10 @@ class TestSlapOSHasError(testSlapOSMixin):
None, None,
hosting_subscription.HostingSubscription_checkSoftwareInstanceState()) hosting_subscription.HostingSubscription_checkSoftwareInstanceState())
class TestSupportRequestTrySendNotificationMessage(testSlapOSMixin): class TestSupportRequestTrySendNotificationMessage(SlapOSTestCaseMixin):
def _makeComputer(self): def _makeComputer(self):
super(TestSupportRequestTrySendNotificationMessage, self)._makeComputer() SlapOSTestCaseMixin._makeComputer(self)
# Clone computer document # Clone computer document
self.computer.edit( self.computer.edit(
source_administration_value=self.makePerson(user=0) source_administration_value=self.makePerson(user=0)
...@@ -3250,11 +3173,10 @@ class TestSupportRequestTrySendNotificationMessage(testSlapOSMixin): ...@@ -3250,11 +3173,10 @@ class TestSupportRequestTrySendNotificationMessage(testSlapOSMixin):
another_support_request.getRelativeUrl()) another_support_request.getRelativeUrl())
class TestSupportRequestUpdateMonitoringState(testSlapOSMixin): class TestSupportRequestUpdateMonitoringState(SlapOSTestCaseMixin):
def _makeComputer(self): def _makeComputer(self):
super(TestSupportRequestUpdateMonitoringState, self)._makeComputer() SlapOSTestCaseMixin._makeComputer(self)
# Clone computer document # Clone computer document
self.computer.edit( self.computer.edit(
source_administration_value=self.makePerson(user=0) source_administration_value=self.makePerson(user=0)
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
import transaction import transaction
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
testSlapOSMixin
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from unittest import skip
import json
from DateTime import DateTime from DateTime import DateTime
from zExceptions import Unauthorized from zExceptions import Unauthorized
class TestSlapOSERP5CleanupActiveProcess(testSlapOSMixin): class TestSlapOSERP5CleanupActiveProcess(SlapOSTestCaseMixinWithAbort):
def beforeTearDown(self):
transaction.abort()
def _simulateActiveProcess_deleteSelf(self): def _simulateActiveProcess_deleteSelf(self):
script_name = 'ActiveProcess_deleteSelf' script_name = 'ActiveProcess_deleteSelf'
...@@ -69,10 +64,7 @@ context.edit(description=description)""") ...@@ -69,10 +64,7 @@ context.edit(description=description)""")
self.check_cleanup_active_process_alarm(DateTime() - 20, self.assertFalse) self.check_cleanup_active_process_alarm(DateTime() - 20, self.assertFalse)
class TestSlapOSERP5ActiveProcess_deleteSelf(testSlapOSMixin): class TestSlapOSERP5ActiveProcess_deleteSelf(SlapOSTestCaseMixinWithAbort):
def beforeTearDown(self):
transaction.abort()
def createActiveProcess(self): def createActiveProcess(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -100,9 +92,9 @@ class TestSlapOSERP5ActiveProcess_deleteSelf(testSlapOSMixin): ...@@ -100,9 +92,9 @@ class TestSlapOSERP5ActiveProcess_deleteSelf(testSlapOSMixin):
def test_default_use_case(self): def test_default_use_case(self):
active_process = self.createActiveProcess() active_process = self.createActiveProcess()
module = active_process.getParentValue() module = active_process.getParentValue()
id = active_process.getId() ac_id = active_process.getId()
active_process.ActiveProcess_deleteSelf() active_process.ActiveProcess_deleteSelf()
self.assertRaises( self.assertRaises(
KeyError, KeyError,
module._getOb, module._getOb,
id) ac_id)
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSERP5Alarm</string> </value> <value> <string>testSlapOSERP5Alarm</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSERP5Alarm</string> </value> <value> <string>test.erp5.testSlapOSERP5Alarm</string> </value>
...@@ -33,11 +45,7 @@ ...@@ -33,11 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W:103, 4: Redefining built-in \'id\' (redefined-builtin)</string>
<string>W: 6, 0: Unused import skip (unused-import)</string>
<string>W: 7, 0: Unused import json (unused-import)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -47,13 +55,28 @@ ...@@ -47,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -66,7 +89,7 @@ ...@@ -66,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -75,7 +98,7 @@ ...@@ -75,7 +98,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
############################################################################## ##############################################################################
from erp5.component.test.testSlapOSCloudSecurityGroup import TestSlapOSSecurityMixin from erp5.component.test.testSlapOSCloudSecurityGroup import TestSlapOSSecurityMixin
from Products.SlapOS.tests.testSlapOSMixin import changeSkin from erp5.component.test.SlapOSTestCaseMixin import changeSkin
import re import re
import xml_marshaller import xml_marshaller
from AccessControl.SecurityManagement import getSecurityManager, \ from AccessControl.SecurityManagement import getSecurityManager, \
......
# Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import testSlapOSMixin from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
class TestSlapOSGroupRoleSecurityMixin(testSlapOSMixin): class TestSlapOSGroupRoleSecurityMixin(SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSGroupRoleSecurityMixin, self).afterSetUp() SlapOSTestCaseMixinWithAbort.afterSetUp(self)
self.user_id = getSecurityManager().getUser().getId() self.user_id = getSecurityManager().getUser().getId()
def changeOwnership(self, document): def changeOwnership(self, document):
...@@ -16,10 +15,6 @@ class TestSlapOSGroupRoleSecurityMixin(testSlapOSMixin): ...@@ -16,10 +15,6 @@ class TestSlapOSGroupRoleSecurityMixin(testSlapOSMixin):
document.changeOwnership(getSecurityManager().getUser(), False) document.changeOwnership(getSecurityManager().getUser(), False)
document.updateLocalRolesOnSecurityGroups() document.updateLocalRolesOnSecurityGroups()
def generateNewId(self):
return self.getPortalObject().portal_ids.generateNewId(
id_group=('slapos_core_test'))
def _getLocalRoles(self, context): def _getLocalRoles(self, context):
return [x[0] for x in context.get_local_roles()] return [x[0] for x in context.get_local_roles()]
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
# #
############################################################################## ##############################################################################
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
testSlapOSMixin
import os import os
from Testing import ZopeTestCase from Testing import ZopeTestCase
class TestSlapOSDump(testSlapOSMixin): class TestSlapOSDump(SlapOSTestCaseMixin):
def write(self, name, output): def write(self, name, output):
path = os.path.join(os.environ['INSTANCE_HOME'], name) path = os.path.join(os.environ['INSTANCE_HOME'], name)
with open(path, 'w') as f: with open(path, 'w') as f:
......
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSERP5SiteDump</string> </value> <value> <string>testSlapOSERP5SiteDump</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSERP5SiteDump</string> </value> <value> <string>test.erp5.testSlapOSERP5SiteDump</string> </value>
...@@ -43,13 +55,28 @@ ...@@ -43,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -62,7 +89,7 @@ ...@@ -62,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -71,7 +98,7 @@ ...@@ -71,7 +98,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
......
...@@ -27,12 +27,10 @@ ...@@ -27,12 +27,10 @@
# #
############################################################################## ##############################################################################
import unittest import unittest
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
testSlapOSMixin
import difflib import difflib
class TestSlaposSkinSelection(testSlapOSMixin): class TestSlaposSkinSelection(SlapOSTestCaseMixin):
run_all_test = 1 run_all_test = 1
def getTitle(self): def getTitle(self):
......
...@@ -4,17 +4,16 @@ ...@@ -4,17 +4,16 @@
import unittest import unittest
from Products.ERP5.tests import testXHTML from Products.ERP5.tests import testXHTML
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
testSlapOSMixin
class TestSlapOSXHTML(testSlapOSMixin, testXHTML.TestXHTML): class TestSlapOSXHTML(SlapOSTestCaseMixin, testXHTML.TestXHTML):
# some forms have intentionally empty listbox selections like RSS generators # some forms have intentionally empty listbox selections like RSS generators
JSL_IGNORE_SKIN_LIST = ('erp5_ace_editor', 'erp5_code_mirror', 'erp5_ckeditor', JSL_IGNORE_SKIN_LIST = ('erp5_ace_editor', 'erp5_code_mirror', 'erp5_ckeditor',
'erp5_fckeditor', 'erp5_jquery', 'erp5_jquery_ui', 'erp5_fckeditor', 'erp5_jquery', 'erp5_jquery_ui',
'erp5_svg_editor', 'erp5_xinha_editor', 'erp5_web_renderjs') 'erp5_svg_editor', 'erp5_xinha_editor', 'erp5_web_renderjs')
def afterSetUp(self): def afterSetUp(self):
testSlapOSMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
# Live tests all uses the same request. For now we remove cell from # Live tests all uses the same request. For now we remove cell from
# previous test that can cause problems in this test. # previous test that can cause problems in this test.
self.portal.REQUEST.other.pop('cell', None) self.portal.REQUEST.other.pop('cell', None)
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
testSlapOSMixin
import json import json
import httplib import httplib
import urlparse import urlparse
...@@ -25,7 +25,7 @@ def getRelativeUrlFromUrn(urn): ...@@ -25,7 +25,7 @@ def getRelativeUrlFromUrn(urn):
return return
return url return url
class TestSlapOSHypermediaPersonScenario(testSlapOSMixin): class TestSlapOSHypermediaPersonScenario(SlapOSTestCaseMixin):
def _makeUser(self): def _makeUser(self):
person_user = self.makePerson() person_user = self.makePerson()
...@@ -386,10 +386,7 @@ class TestSlapOSHypermediaPersonScenario(testSlapOSMixin): ...@@ -386,10 +386,7 @@ class TestSlapOSHypermediaPersonScenario(testSlapOSMixin):
software_hal = json.loads(response.read()) software_hal = json.loads(response.read())
class TestSlapOSHypermediaInstanceScenario(testSlapOSMixin): class TestSlapOSHypermediaInstanceScenario(SlapOSTestCaseMixin):
def generateNewId(self):
return "%s" % self.portal.portal_ids.generateNewId(
id_group=('slapos_core_test'))
def generateNewSoftwareReleaseUrl(self): def generateNewSoftwareReleaseUrl(self):
return 'http://example.org/test%s.cfg' % self.generateNewId() return 'http://example.org/test%s.cfg' % self.generateNewId()
......
...@@ -47,14 +47,14 @@ ...@@ -47,14 +47,14 @@
<value> <value>
<tuple> <tuple>
<string>W: 12, 5: Using type() instead of isinstance() for a typecheck. (unidiomatic-typecheck)</string> <string>W: 12, 5: Using type() instead of isinstance() for a typecheck. (unidiomatic-typecheck)</string>
<string>W: 59, 28: Unused variable \'api_path\' (unused-variable)</string> <string>W: 50, 28: Unused variable \'api_path\' (unused-variable)</string>
<string>W:290, 4: Unused variable \'news_hal\' (unused-variable)</string> <string>W:281, 4: Unused variable \'news_hal\' (unused-variable)</string>
<string>W: 60, 8: Unused variable \'api_fragment\' (unused-variable)</string> <string>W: 51, 8: Unused variable \'api_fragment\' (unused-variable)</string>
<string>W: 59, 38: Unused variable \'api_query\' (unused-variable)</string> <string>W: 50, 38: Unused variable \'api_query\' (unused-variable)</string>
<string>W:395, 4: Unused variable \'software_hal\' (unused-variable)</string> <string>W:386, 4: Unused variable \'software_hal\' (unused-variable)</string>
<string>W:422, 28: Unused variable \'api_path\' (unused-variable)</string> <string>W:412, 28: Unused variable \'api_path\' (unused-variable)</string>
<string>W:422, 38: Unused variable \'api_query\' (unused-variable)</string> <string>W:412, 38: Unused variable \'api_query\' (unused-variable)</string>
<string>W:423, 8: Unused variable \'api_fragment\' (unused-variable)</string> <string>W:413, 8: Unused variable \'api_fragment\' (unused-variable)</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction import transaction
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import \
testSlapOSMixin, changeSkin, simulate SlapOSTestCaseMixinWithAbort, changeSkin, simulate
from zExceptions import Unauthorized from zExceptions import Unauthorized
from unittest import skip from unittest import skip
...@@ -132,14 +132,11 @@ class TestBase_handleAcceptHeader(ERP5HALJSONStyleSkinsMixin): ...@@ -132,14 +132,11 @@ class TestBase_handleAcceptHeader(ERP5HALJSONStyleSkinsMixin):
) )
class TestSlapOSHypermediaMixin(testSlapOSMixin): class TestSlapOSHypermediaMixin(SlapOSTestCaseMixinWithAbort):
def afterSetUp(self): def afterSetUp(self):
testSlapOSMixin.afterSetUp(self) SlapOSTestCaseMixinWithAbort.afterSetUp(self)
self.changeSkin('Hal') self.changeSkin('Hal')
def beforeTearDown(self):
transaction.abort()
def _makePerson(self): def _makePerson(self):
person_user = self.makePerson() person_user = self.makePerson()
self.tic() self.tic()
...@@ -238,7 +235,6 @@ class TestSlapOSPersonERP5Document_getHateoas(TestSlapOSHypermediaMixin): ...@@ -238,7 +235,6 @@ class TestSlapOSPersonERP5Document_getHateoas(TestSlapOSHypermediaMixin):
u'title': u'getHateoasInformation' u'title': u'getHateoasInformation'
}, },
]: ]:
self.assertTrue(action in action_object_slap, \ self.assertTrue(action in action_object_slap, \
"%s not in %s" % (action, action_object_slap)) "%s not in %s" % (action, action_object_slap))
self.assertEquals(results['_links']['action_object_slap_post'], { self.assertEquals(results['_links']['action_object_slap_post'], {
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple>
<string>W: 51, 0: Dangerous default value {} as argument (dangerous-default-value)</string> <string>W: 15, 0: Dangerous default value {} as argument (dangerous-default-value)</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
testSlapOSMixin
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from DateTime import DateTime from DateTime import DateTime
class TestSlapOSPayzenUpdateConfirmedPayment(testSlapOSMixin): class TestSlapOSPayzenUpdateConfirmedPayment(SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def _simulatePaymentTransaction_startPayzenPayment(self): def _simulatePaymentTransaction_startPayzenPayment(self):
script_name = 'PaymentTransaction_startPayzenPayment' script_name = 'PaymentTransaction_startPayzenPayment'
...@@ -215,10 +212,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P ...@@ -215,10 +212,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P
self.assertEquals(transaction.getSimulationState(), 'started') self.assertEquals(transaction.getSimulationState(), 'started')
class TestSlapOSPayzenUpdateStartedPayment(testSlapOSMixin): class TestSlapOSPayzenUpdateStartedPayment(SlapOSTestCaseMixinWithAbort):
def beforeTearDown(self):
self.abort()
def test_not_started_payment(self): def test_not_started_payment(self):
new_id = self.generateNewId() new_id = self.generateNewId()
......
...@@ -5,10 +5,9 @@ ...@@ -5,10 +5,9 @@
# #
############################################################################## ##############################################################################
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
testSlapOSMixin
class TestSlapOSPaymentTransactionOrderBuilder(testSlapOSMixin): class TestSlapOSPaymentTransactionOrderBuilder(SlapOSTestCaseMixin):
def sumReceivable(self, payment_transaction): def sumReceivable(self, payment_transaction):
quantity = .0 quantity = .0
default_source_uid = self.portal.restrictedTraverse( default_source_uid = self.portal.restrictedTraverse(
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
testSlapOSMixin
from DateTime import DateTime from DateTime import DateTime
from zExceptions import Unauthorized from zExceptions import Unauthorized
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestSlapOSCurrency_getIntegrationMapping(testSlapOSMixin): class TestSlapOSCurrency_getIntegrationMapping(SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def test_integratedCurrency(self): def test_integratedCurrency(self):
currency = self.portal.currency_module.EUR currency = self.portal.currency_module.EUR
...@@ -25,9 +23,7 @@ class TestSlapOSCurrency_getIntegrationMapping(testSlapOSMixin): ...@@ -25,9 +23,7 @@ class TestSlapOSCurrency_getIntegrationMapping(testSlapOSMixin):
currency.Currency_getIntegrationMapping) currency.Currency_getIntegrationMapping)
class TestSlapOSAccountingTransaction_updateStartDate(testSlapOSMixin): class TestSlapOSAccountingTransaction_updateStartDate(SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createPaymentTransaction(self): def createPaymentTransaction(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -52,17 +48,7 @@ class TestSlapOSAccountingTransaction_updateStartDate(testSlapOSMixin): ...@@ -52,17 +48,7 @@ class TestSlapOSAccountingTransaction_updateStartDate(testSlapOSMixin):
date, REQUEST={}) date, REQUEST={})
class TestSlapOSPaymentTransaction_getPayzenId(testSlapOSMixin): class TestSlapOSPaymentTransaction_getPayzenId(SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createPaymentTransaction(self):
new_id = self.generateNewId()
return self.portal.accounting_module.newContent(
portal_type='Payment Transaction',
title="Transaction %s" % new_id,
reference="TESTTRANS-%s" % new_id,
)
def test_getPayzenId_newPaymentTransaction(self): def test_getPayzenId_newPaymentTransaction(self):
payment_transaction = self.createPaymentTransaction() payment_transaction = self.createPaymentTransaction()
...@@ -102,17 +88,7 @@ class TestSlapOSPaymentTransaction_getPayzenId(testSlapOSMixin): ...@@ -102,17 +88,7 @@ class TestSlapOSPaymentTransaction_getPayzenId(testSlapOSMixin):
REQUEST={}) REQUEST={})
class TestSlapOSPaymentTransaction_generatePayzenId(testSlapOSMixin): class TestSlapOSPaymentTransaction_generatePayzenId(SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createPaymentTransaction(self):
new_id = self.generateNewId()
return self.portal.accounting_module.newContent(
portal_type='Payment Transaction',
title="Transaction %s" % new_id,
reference="TESTTRANS-%s" % new_id,
)
def test_generatePayzenId_newPaymentTransaction(self): def test_generatePayzenId_newPaymentTransaction(self):
payment_transaction = self.createPaymentTransaction() payment_transaction = self.createPaymentTransaction()
...@@ -172,17 +148,7 @@ class TestSlapOSPaymentTransaction_generatePayzenId(testSlapOSMixin): ...@@ -172,17 +148,7 @@ class TestSlapOSPaymentTransaction_generatePayzenId(testSlapOSMixin):
REQUEST={}) REQUEST={})
class TestSlapOSPaymentTransaction_createPayzenEvent(testSlapOSMixin): class TestSlapOSPaymentTransaction_createPayzenEvent(SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createPaymentTransaction(self):
new_id = self.generateNewId()
return self.portal.accounting_module.newContent(
portal_type='Payment Transaction',
title="Transaction %s" % new_id,
reference="TESTTRANS-%s" % new_id,
)
def test_createPayzenEvent_REQUEST_disallowed(self): def test_createPayzenEvent_REQUEST_disallowed(self):
payment_transaction = self.createPaymentTransaction() payment_transaction = self.createPaymentTransaction()
...@@ -210,22 +176,7 @@ class TestSlapOSPaymentTransaction_createPayzenEvent(testSlapOSMixin): ...@@ -210,22 +176,7 @@ class TestSlapOSPaymentTransaction_createPayzenEvent(testSlapOSMixin):
self.assertEquals(payzen_event.getTitle(), "foo") self.assertEquals(payzen_event.getTitle(), "foo")
class TestSlapOSPayzenEvent_processUpdate(testSlapOSMixin): class TestSlapOSPayzenEvent_processUpdate(SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createPaymentTransaction(self):
new_id = self.generateNewId()
return self.portal.accounting_module.newContent(
portal_type='Payment Transaction',
title="Transaction %s" % new_id,
reference="TESTTRANS-%s" % new_id,
)
def createPayzenEvent(self):
return self.portal.system_event_module.newContent(
portal_type='Payzen Event',
reference='PAY-%s' % self.generateNewId())
def test_processUpdate_REQUEST_disallowed(self): def test_processUpdate_REQUEST_disallowed(self):
event = self.createPayzenEvent() event = self.createPayzenEvent()
...@@ -578,9 +529,7 @@ return addToDate(DateTime(), to_add={'day': -1, 'second': -1}).toZone('UTC'), 'f ...@@ -578,9 +529,7 @@ return addToDate(DateTime(), to_add={'day': -1, 'second': -1}).toZone('UTC'), 'f
'Aborting refused payzen payment.', 'Aborting refused payzen payment.',
payment.workflow_history['accounting_workflow'][-1]['comment']) payment.workflow_history['accounting_workflow'][-1]['comment'])
class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(testSlapOSMixin): class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def test_getPayzenServiceRelativeUrl_REQUEST_disallowed(self): def test_getPayzenServiceRelativeUrl_REQUEST_disallowed(self):
self.assertRaises( self.assertRaises(
...@@ -592,47 +541,28 @@ class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(testSlapOSMixin): ...@@ -592,47 +541,28 @@ class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(testSlapOSMixin):
result = self.portal.Base_getPayzenServiceRelativeUrl() result = self.portal.Base_getPayzenServiceRelativeUrl()
self.assertEquals(result, 'portal_secure_payments/slapos_payzen_test') self.assertEquals(result, 'portal_secure_payments/slapos_payzen_test')
class TestSlapOSPayzenSaleInvoiceTransaction_createReversalPayzenTransaction(
testSlapOSMixin):
abort_transaction = 1
def createPayzenSaleInvoiceTransaction(self):
new_title = self.generateNewId()
new_reference = self.generateNewId()
new_source_reference = self.generateNewId()
new_destination_reference = self.generateNewId()
invoice = self.portal.accounting_module.newContent(
portal_type="Sale Invoice Transaction",
title=new_title,
start_date=DateTime(),
reference=new_reference,
source_reference=new_source_reference,
destination_reference=new_destination_reference,
payment_mode="payzen",
specialise="sale_trade_condition_module/slapos_aggregated_trade_condition",
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(invoice, 'stopped')
invoice.newContent(
title="",
portal_type="Invoice Line",
quantity=-2,
price=2,
)
invoice.newContent(
portal_type="Sale Invoice Transaction Line",
source="account_module/receivable",
quantity=-3,
)
payment = self.portal.accounting_module.newContent( class TestSlapOSPayzenSaleInvoiceTransaction_getPayzenPaymentRelatedValue(
portal_type="Payment Transaction", SlapOSTestCaseMixinWithAbort):
payment_mode="payzen",
causality_value=invoice, def test_SaleInvoiceTransaction_getPayzenPaymentRelatedValue(self):
created_by_builder=1 # to prevent init script to create lines invoice = self.createPayzenSaleInvoiceTransaction()
) self.tic()
self.portal.portal_workflow._jumpToStateFor(payment, 'started') payment = invoice.SaleInvoiceTransaction_getPayzenPaymentRelatedValue()
return invoice self.assertNotEquals(None, payment)
self.assertEquals(payment.getSimulationState(), "started")
self.assertEquals(payment.getCausalityValue(), invoice)
self.assertEquals(payment.getPaymentModeUid(),
self.portal.portal_categories.payment_mode.payzen.getUid())
payment.setStartDate(DateTime())
payment.stop()
payment.immediateReindexObject()
payment = invoice.SaleInvoiceTransaction_getPayzenPaymentRelatedValue()
self.assertEquals(None, payment)
class TestSlapOSPayzenSaleInvoiceTransaction_createReversalPayzenTransaction(
SlapOSTestCaseMixinWithAbort):
def test_createReversalPayzenTransaction_REQUEST_disallowed(self): def test_createReversalPayzenTransaction_REQUEST_disallowed(self):
self.assertRaises( self.assertRaises(
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
testSlapOSMixin
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
...@@ -15,22 +14,7 @@ vads_url_refused = 'http://example.org/refused' ...@@ -15,22 +14,7 @@ vads_url_refused = 'http://example.org/refused'
vads_url_success = 'http://example.org/success' vads_url_success = 'http://example.org/success'
vads_url_return = 'http://example.org/return' vads_url_return = 'http://example.org/return'
class TestSlapOSPayzenInterfaceWorkflow(testSlapOSMixin): class TestSlapOSPayzenInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
abort_transaction = 1
def createPaymentTransaction(self):
new_id = self.generateNewId()
return self.portal.accounting_module.newContent(
portal_type='Payment Transaction',
title="Transaction %s" % new_id,
reference="TESTTRANS-%s" % new_id,
)
def createPayzenEvent(self):
return self.portal.system_event_module.newContent(
portal_type='Payzen Event',
reference='PAY-%s' % self.generateNewId())
def _simulatePaymentTransaction_getTotalPayablePrice(self): def _simulatePaymentTransaction_getTotalPayablePrice(self):
script_name = 'PaymentTransaction_getTotalPayablePrice' script_name = 'PaymentTransaction_getTotalPayablePrice'
......
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction import transaction
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
testSlapOSMixin
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestSlapOSUpgradeDecisionProcess(testSlapOSMixin): class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSUpgradeDecisionProcess, self).afterSetUp() SlapOSTestCaseMixin.afterSetUp(self)
self.new_id = self.generateNewId() self.new_id = self.generateNewId()
def generateNewId(self):
return "%sTEST" % self.portal.portal_ids.generateNewId(
id_group=('slapos_core_test'))
def _makeUpgradeDecision(self, confirm=True): def _makeUpgradeDecision(self, confirm=True):
upgrade_decision = self.portal.\ upgrade_decision = self.portal.\
upgrade_decision_module.newContent( upgrade_decision_module.newContent(
......
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSPDMAlarm</string> </value> <value> <string>testSlapOSPDMAlarm</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSPDMAlarm</string> </value> <value> <string>test.erp5.testSlapOSPDMAlarm</string> </value>
...@@ -33,10 +45,7 @@ ...@@ -33,10 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 13, 0: Bad indentation. Found 5 spaces, expected 4 (bad-indentation)</string>
<string>W: 25, 2: Arguments number differs from overridden method (arguments-differ)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -46,13 +55,28 @@ ...@@ -46,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -65,7 +89,7 @@ ...@@ -65,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -74,7 +98,7 @@ ...@@ -74,7 +98,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
......
...@@ -26,14 +26,13 @@ ...@@ -26,14 +26,13 @@
# #
############################################################################## ##############################################################################
import transaction from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin, simulate
from Products.SlapOS.tests.testSlapOSMixin import testSlapOSMixin, simulate
from DateTime import DateTime from DateTime import DateTime
class TestSlapOSPDMSkins(testSlapOSMixin): class TestSlapOSPDMSkins(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSPDMSkins, self).afterSetUp() SlapOSTestCaseMixin.afterSetUp(self)
self.new_id = self.generateNewId() self.new_id = self.generateNewId()
self.request_kw = dict( self.request_kw = dict(
software_title=self.generateNewSoftwareTitle(), software_title=self.generateNewSoftwareTitle(),
...@@ -52,11 +51,6 @@ class TestSlapOSPDMSkins(testSlapOSMixin): ...@@ -52,11 +51,6 @@ class TestSlapOSPDMSkins(testSlapOSMixin):
self.portal.upgrade_decision_module.manage_delObjects(id_list) self.portal.upgrade_decision_module.manage_delObjects(id_list)
self.tic() self.tic()
def generateNewId(self):
return "%sTEST" % self.portal.portal_ids.generateNewId(
id_group=('slapos_core_test'))
def _makePerson(self): def _makePerson(self):
person_user = self.makePerson(new_id=self.new_id) person_user = self.makePerson(new_id=self.new_id)
return person_user return person_user
...@@ -234,7 +228,6 @@ class TestSlapOSPDMSkins(testSlapOSMixin): ...@@ -234,7 +228,6 @@ class TestSlapOSPDMSkins(testSlapOSMixin):
portal_type="Upgrade Decision Line", portal_type="Upgrade Decision Line",
title="TESTUPDE-%s" % self.new_id) title="TESTUPDE-%s" % self.new_id)
def test_getSortedSoftwareReleaseListFromSoftwareProduct(self): def test_getSortedSoftwareReleaseListFromSoftwareProduct(self):
software_product = self._makeSoftwareProduct() software_product = self._makeSoftwareProduct()
release_list = software_product.SoftwareProduct_getSortedSoftwareReleaseList( release_list = software_product.SoftwareProduct_getSortedSoftwareReleaseList(
...@@ -266,7 +259,6 @@ class TestSlapOSPDMSkins(testSlapOSMixin): ...@@ -266,7 +259,6 @@ class TestSlapOSPDMSkins(testSlapOSMixin):
self.assertEquals([release.getUrlString() for release in release_list], self.assertEquals([release.getUrlString() for release in release_list],
['http://example.org/2-%s.cfg' % self.new_id, 'http://example.org/1-%s.cfg' % self.new_id]) ['http://example.org/2-%s.cfg' % self.new_id, 'http://example.org/1-%s.cfg' % self.new_id])
def test_getSortedSoftwareReleaseListFromSoftwareProduct_Changed(self): def test_getSortedSoftwareReleaseListFromSoftwareProduct_Changed(self):
software_product = self._makeSoftwareProduct() software_product = self._makeSoftwareProduct()
release_list = software_product.SoftwareProduct_getSortedSoftwareReleaseList( release_list = software_product.SoftwareProduct_getSortedSoftwareReleaseList(
......
...@@ -45,10 +45,7 @@ ...@@ -45,10 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W:127, 2: Arguments number differs from overridden method (arguments-differ)</string>
<string>W:140, 2: Arguments number differs from overridden method (arguments-differ)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
testSlapOSMixin
from DateTime import DateTime from DateTime import DateTime
from App.Common import rfc1123_date from App.Common import rfc1123_date
...@@ -34,24 +33,22 @@ class Simulator: ...@@ -34,24 +33,22 @@ class Simulator:
'reckwargs': kwargs}) 'reckwargs': kwargs})
open(self.outfile, 'w').write(repr(l)) open(self.outfile, 'w').write(repr(l))
class TestSlapOSSlapToolMixin(testSlapOSMixin): class TestSlapOSSlapToolMixin(SlapOSTestCaseMixin):
def afterSetUp(self, person=None): def afterSetUp(self):
testSlapOSMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
self.portal_slap = self.portal.portal_slap self.portal_slap = self.portal.portal_slap
new_id = self.generateNewId()
# Prepare computer # Prepare computer
self.computer = self.portal.computer_module.template_computer\ self.computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1) .Base_createCloneDocument(batch_mode=1)
self.computer.edit( self.computer.edit(
title="Computer %s" % new_id, title="Computer %s" % self.new_id,
reference="TESTCOMP-%s" % new_id reference="TESTCOMP-%s" % self.new_id
) )
if (person is not None): if getattr(self, "person", None) is not None:
self.computer.edit( self.computer.edit(
source_administration_value=person, source_administration_value=getattr(self, "person", None),
) )
self.computer.validate() self.computer.validate()
self._addERP5Login(self.computer) self._addERP5Login(self.computer)
...@@ -2145,7 +2142,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2145,7 +2142,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
self.person = person self.person = person
self.person_reference = person.getReference() self.person_reference = person.getReference()
self.person_user_id = person.getUserId() self.person_user_id = person.getUserId()
TestSlapOSSlapToolMixin.afterSetUp(self, person=person) TestSlapOSSlapToolMixin.afterSetUp(self)
def test_not_accessed_getComputerStatus(self): def test_not_accessed_getComputerStatus(self):
self.login(self.person_user_id) self.login(self.person_user_id)
......
...@@ -46,24 +46,22 @@ ...@@ -46,24 +46,22 @@
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple>
<string>W: 29, 10: Use of eval (eval-used)</string> <string>W: 28, 10: Use of eval (eval-used)</string>
<string>W: 38, 2: Arguments number differs from overridden \'afterSetUp\' method (arguments-differ)</string> <string>W:516, 13: Use of eval (eval-used)</string>
<string>W:519, 13: Use of eval (eval-used)</string> <string>W:567, 13: Use of eval (eval-used)</string>
<string>W:570, 13: Use of eval (eval-used)</string> <string>W:792, 13: Use of eval (eval-used)</string>
<string>W:795, 13: Use of eval (eval-used)</string> <string>W:1400, 13: Use of eval (eval-used)</string>
<string>W:1403, 13: Use of eval (eval-used)</string> <string>W:1513, 13: Use of eval (eval-used)</string>
<string>W:1516, 13: Use of eval (eval-used)</string> <string>W:1567, 13: Use of eval (eval-used)</string>
<string>W:1570, 13: Use of eval (eval-used)</string> <string>W:1607, 13: Use of eval (eval-used)</string>
<string>W:1610, 13: Use of eval (eval-used)</string> <string>W:2229, 13: Use of eval (eval-used)</string>
<string>W:2134, 2: Arguments number differs from overridden \'afterSetUp\' method (arguments-differ)</string> <string>W:2614, 13: Use of eval (eval-used)</string>
<string>W:2231, 13: Use of eval (eval-used)</string> <string>W:2668, 13: Use of eval (eval-used)</string>
<string>W:2616, 13: Use of eval (eval-used)</string> <string>W:2695, 13: Use of eval (eval-used)</string>
<string>W:2670, 13: Use of eval (eval-used)</string> <string>W:2850, 13: Use of eval (eval-used)</string>
<string>W:2697, 13: Use of eval (eval-used)</string> <string>W:2878, 13: Use of eval (eval-used)</string>
<string>W:2852, 13: Use of eval (eval-used)</string> <string>W:2927, 13: Use of eval (eval-used)</string>
<string>W:2880, 13: Use of eval (eval-used)</string> <string>W:2974, 13: Use of eval (eval-used)</string>
<string>W:2929, 13: Use of eval (eval-used)</string>
<string>W:2976, 13: Use of eval (eval-used)</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
import transaction from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
class TestSlapOSCoreComputerUpdateFromDict(testSlapOSMixin): class TestSlapOSCoreComputerUpdateFromDict(SlapOSTestCaseMixinWithAbort):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSCoreComputerUpdateFromDict, self).afterSetUp() SlapOSTestCaseMixinWithAbort.afterSetUp(self)
self.computer = self.portal.computer_module.template_computer\ self.computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1) .Base_createCloneDocument(batch_mode=1)
self.computer.edit( self.computer.edit(
...@@ -23,9 +21,6 @@ class TestSlapOSCoreComputerUpdateFromDict(testSlapOSMixin): ...@@ -23,9 +21,6 @@ class TestSlapOSCoreComputerUpdateFromDict(testSlapOSMixin):
portal_type='Computer Partition') portal_type='Computer Partition')
self.assertEqual(len(partition_list), 0) self.assertEqual(len(partition_list), 0)
def beforeTearDown(self):
transaction.abort()
############################################# #############################################
# Computer network information # Computer network information
############################################# #############################################
...@@ -420,7 +415,7 @@ class TestSlapOSCoreComputerUpdateFromDict(testSlapOSMixin): ...@@ -420,7 +415,7 @@ class TestSlapOSCoreComputerUpdateFromDict(testSlapOSMixin):
id ='foo', id ='foo',
portal_type='Internet Protocol Address', portal_type='Internet Protocol Address',
) )
other_address2 = partition.newContent( partition.newContent(
id ='route_foo', id ='route_foo',
portal_type='Internet Protocol Address', portal_type='Internet Protocol Address',
) )
...@@ -553,11 +548,11 @@ class TestSlapOSCoreComputerUpdateFromDict(testSlapOSMixin): ...@@ -553,11 +548,11 @@ class TestSlapOSCoreComputerUpdateFromDict(testSlapOSMixin):
address_list = partition.contentValues( address_list = partition.contentValues(
portal_type='Internet Protocol Address') portal_type='Internet Protocol Address')
self.assertEqual(len(address_list), 0) self.assertEqual(len(address_list), 0)
other_address = partition.newContent( partition.newContent(
id ='foo', id ='foo',
portal_type='Internet Protocol Address', portal_type='Internet Protocol Address',
) )
default_address = partition.newContent( partition.newContent(
id ='default_network_interface', id ='default_network_interface',
portal_type='Internet Protocol Address', portal_type='Internet Protocol Address',
) )
...@@ -594,11 +589,11 @@ class TestSlapOSCoreComputerUpdateFromDict(testSlapOSMixin): ...@@ -594,11 +589,11 @@ class TestSlapOSCoreComputerUpdateFromDict(testSlapOSMixin):
address_list = partition.contentValues( address_list = partition.contentValues(
portal_type='Internet Protocol Address') portal_type='Internet Protocol Address')
self.assertEqual(len(address_list), 0) self.assertEqual(len(address_list), 0)
other_address = partition.newContent( partition.newContent(
id ='foo', id ='foo',
portal_type='Internet Protocol Address', portal_type='Internet Protocol Address',
) )
default_address = partition.newContent( partition.newContent(
id ='default_network_interface', id ='default_network_interface',
portal_type='Internet Protocol Address', portal_type='Internet Protocol Address',
) )
......
...@@ -45,13 +45,7 @@ ...@@ -45,13 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W:423, 4: Unused variable \'other_address2\' (unused-variable)</string>
<string>W:560, 4: Unused variable \'default_address\' (unused-variable)</string>
<string>W:556, 4: Unused variable \'other_address\' (unused-variable)</string>
<string>W:601, 4: Unused variable \'default_address\' (unused-variable)</string>
<string>W:597, 4: Unused variable \'other_address\' (unused-variable)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -30,62 +30,16 @@ import random ...@@ -30,62 +30,16 @@ import random
import transaction import transaction
import unittest import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
import functools
from Products.ERP5Type.tests.utils import DummyMailHost from Products.ERP5Type.tests.utils import DummyMailHost
from Products.ERP5Type.Utils import convertToUpperCase from Products.ERP5Type.Utils import convertToUpperCase
import os import os
import glob import glob
from functools import wraps
from Products.ERP5Type.tests.utils import createZODBPythonScript
from AccessControl.SecurityManagement import getSecurityManager, \ from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager setSecurityManager
from App.config import getConfiguration from App.config import getConfiguration
config = getConfiguration() config = getConfiguration()
def changeSkin(skin_name):
def decorator(func):
def wrapped(self, *args, **kwargs):
default_skin = self.portal.portal_skins.default_skin
self.portal.portal_skins.changeSkin(skin_name)
self.app.REQUEST.set('portal_skin', skin_name)
try:
v = func(self, *args, **kwargs)
finally:
self.portal.portal_skins.changeSkin(default_skin)
self.app.REQUEST.set('portal_skin', default_skin)
return v
return wrapped
return decorator
def simulate(script_id, params_string, code_string):
def upperWrap(f):
@wraps(f)
def decorated(self, *args, **kw):
if script_id in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_id)
createZODBPythonScript(self.portal.portal_skins.custom,
script_id, params_string, code_string)
transaction.commit()
try:
result = f(self, *args, **kw)
finally:
if script_id in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_id)
transaction.commit()
return result
return decorated
return upperWrap
def withAbort(func):
@functools.wraps(func)
def wrapped(self, *args, **kwargs):
try:
func(self, *args, **kwargs)
finally:
self.abort()
return wrapped
class testSlapOSMixin(ERP5TypeTestCase): class testSlapOSMixin(ERP5TypeTestCase):
abort_transaction = 0 abort_transaction = 0
...@@ -183,9 +137,6 @@ class testSlapOSMixin(ERP5TypeTestCase): ...@@ -183,9 +137,6 @@ class testSlapOSMixin(ERP5TypeTestCase):
self.login() self.login()
self.createAlarmStep() self.createAlarmStep()
# Helpfull for the tests
self.new_id = self.generateNewId()
if self.isLiveTest(): if self.isLiveTest():
self.setUpPersistentDummyMailHost() self.setUpPersistentDummyMailHost()
return return
...@@ -267,385 +218,6 @@ class testSlapOSMixin(ERP5TypeTestCase): ...@@ -267,385 +218,6 @@ class testSlapOSMixin(ERP5TypeTestCase):
] ]
return result return result
def makePerson(self, new_id=None, index=True, user=True):
if new_id is None:
new_id = self.generateNewId()
# Clone person document
person_user = self.portal.person_module.template_member.\
Base_createCloneDocument(batch_mode=1)
person_user.edit(
title="live_test_%s" % new_id,
reference="live_test_%s" % new_id,
default_email_text="live_test_%s@example.org" % new_id,
)
person_user.validate()
for assignment in person_user.contentValues(portal_type="Assignment"):
assignment.open()
if user:
login = self._addERP5Login(person_user)
if index:
transaction.commit()
person_user.immediateReindexObject()
if user:
login.immediateReindexObject()
return person_user
def _addERP5Login(self, document):
login = document.newContent(
portal_type="ERP5 Login",
reference=document.getReference())
login.validate()
return login
def _makeTree(self, requested_template_id='template_software_instance'):
new_id = self.generateNewId()
self.request_kw = dict(
software_release=self.generateNewSoftwareReleaseUrl(),
software_title=self.generateNewSoftwareTitle(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateEmptyXml(),
shared=False,
state="started"
)
self.person_user = self.makePerson(new_id=new_id, index=False)
self.commit()
# prepare part of tree
self.hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
self.software_instance = self.portal.software_instance_module\
[requested_template_id].Base_createCloneDocument(batch_mode=1)
self.hosting_subscription.edit(
title=self.request_kw['software_title'],
reference="TESTHS-%s" % new_id,
url_string=self.request_kw['software_release'],
source_reference=self.request_kw['software_type'],
text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'],
root_slave=self.request_kw['shared'],
predecessor=self.software_instance.getRelativeUrl(),
destination_section=self.person_user.getRelativeUrl()
)
self.hosting_subscription.validate()
self.portal.portal_workflow._jumpToStateFor(self.hosting_subscription, 'start_requested')
self.requested_software_instance = self.portal.software_instance_module\
.template_software_instance.Base_createCloneDocument(batch_mode=1)
self.software_instance.edit(
title=self.request_kw['software_title'],
reference="TESTSI-%s" % new_id,
url_string=self.request_kw['software_release'],
source_reference=self.request_kw['software_type'],
text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'],
specialise=self.hosting_subscription.getRelativeUrl(),
predecessor=self.requested_software_instance.getRelativeUrl()
)
self.portal.portal_workflow._jumpToStateFor(self.software_instance, 'start_requested')
self.software_instance.validate()
self.requested_software_instance.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
url_string=self.request_kw['software_release'],
source_reference=self.request_kw['software_type'],
text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'],
specialise=self.hosting_subscription.getRelativeUrl(),
)
self.portal.portal_workflow._jumpToStateFor(self.requested_software_instance, 'start_requested')
self.requested_software_instance.validate()
self.tic()
def _makeComputer(self, owner=None):
self.computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1)
reference = 'TESTCOMP-%s' % self.generateNewId()
self.computer.edit(
allocation_scope='open/public',
capacity_scope='open',
reference=reference,
title=reference
)
self.computer.validate()
reference = 'TESTPART-%s' % self.generateNewId()
self.partition = self.computer.newContent(portal_type='Computer Partition',
reference=reference,
title=reference
)
self.partition.markFree()
self.partition.validate()
self.tic()
if owner is not None:
self.computer.edit(
source_administration_value=owner,
)
return self.computer, self.partition
def _makeComputerNetwork(self):
reference = 'TESTCOMPNETWORK-%s' % self.generateNewId()
self.computer_network = self.portal.computer_network_module.newContent(
portal_type='Computer Network',
reference=reference,
title=reference
)
self.computer_network.validate()
self.tic()
return self.computer_network
def _makeComplexComputer(self, person=None, with_slave=False):
for i in range(1, 5):
id_ = 'partition%s' % i
p = self.computer.newContent(portal_type='Computer Partition',
id=id_,
title=id_,
reference=id_,
default_network_address_ip_address='ip_address_%s' % i,
default_network_address_netmask='netmask_%s' % i)
p.markFree()
p.validate()
self.start_requested_software_installation = self.portal.software_installation_module\
.template_software_installation.Base_createCloneDocument(batch_mode=1)
self.start_requested_software_installation.edit(
url_string=self.generateNewSoftwareReleaseUrl(),
aggregate=self.computer.getRelativeUrl(),
reference='TESTSOFTINST-%s' % self.generateNewId(),
title='Start requested for %s' % self.computer.getTitle()
)
self.start_requested_software_installation.validate()
self.start_requested_software_installation.requestStart()
self.destroy_requested_software_installation = self.portal.software_installation_module\
.template_software_installation.Base_createCloneDocument(batch_mode=1)
self.destroy_requested_software_installation.edit(
url_string=self.generateNewSoftwareReleaseUrl(),
aggregate=self.computer.getRelativeUrl(),
reference='TESTSOFTINST-%s' % self.generateNewId(),
title='Destroy requested for %s' % self.computer.getTitle()
)
self.destroy_requested_software_installation.validate()
self.destroy_requested_software_installation.requestStart()
self.destroy_requested_software_installation.requestDestroy()
self.destroyed_software_installation = self.portal.software_installation_module\
.template_software_installation.Base_createCloneDocument(batch_mode=1)
self.destroyed_software_installation.edit(
url_string=self.generateNewSoftwareReleaseUrl(),
aggregate=self.computer.getRelativeUrl(),
reference='TESTSOFTINST-%s' % self.generateNewId(),
title='Destroyed for %s' % self.computer.getTitle()
)
self.destroyed_software_installation.validate()
self.destroyed_software_installation.requestStart()
self.destroyed_software_installation.requestDestroy()
self.destroyed_software_installation.invalidate()
self.computer.partition1.markBusy()
self.computer.partition2.markBusy()
self.computer.partition3.markBusy()
# prepare some trees
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
destination_section_value=person,
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='started'
)
hosting_subscription.requestStart(**kw)
hosting_subscription.requestInstance(**kw)
self.start_requested_software_instance = hosting_subscription.getPredecessorValue()
self.start_requested_software_instance.edit(aggregate=self.computer.partition1.getRelativeUrl())
if with_slave:
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
destination_section_value=person,
)
slave_kw = dict(
software_release=kw['software_release'],
software_type=kw['software_type'],
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=True,
software_title=hosting_subscription.getTitle(),
state='started'
)
hosting_subscription.requestStart(**slave_kw)
hosting_subscription.requestInstance(**slave_kw)
self.start_requested_slave_instance = hosting_subscription.getPredecessorValue()
self.start_requested_slave_instance.edit(aggregate=self.computer.partition1.getRelativeUrl())
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
destination_section_value=person,
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='stopped'
)
hosting_subscription.requestStop(**kw)
hosting_subscription.requestInstance(**kw)
self.stop_requested_software_instance = hosting_subscription.getPredecessorValue()
self.stop_requested_software_instance.edit(
aggregate=self.computer.partition2.getRelativeUrl()
)
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='stopped'
)
hosting_subscription.requestStop(**kw)
hosting_subscription.requestInstance(**kw)
kw['state'] = 'destroyed'
hosting_subscription.requestDestroy(**kw)
self.destroy_requested_software_instance = hosting_subscription.getPredecessorValue()
self.destroy_requested_software_instance.requestDestroy(**kw)
self.destroy_requested_software_instance.edit(
aggregate=self.computer.partition3.getRelativeUrl()
)
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='stopped'
)
hosting_subscription.requestStop(**kw)
hosting_subscription.requestInstance(**kw)
kw['state'] = 'destroyed'
hosting_subscription.requestDestroy(**kw)
self.destroyed_software_instance = hosting_subscription.getPredecessorValue()
self.destroyed_software_instance.edit(
aggregate=self.computer.partition4.getRelativeUrl()
)
self.destroyed_software_instance.requestDestroy(**kw)
self.destroyed_software_instance.invalidate()
self.tic()
if with_slave:
# as slave is created in non usual way update its local roles
self.start_requested_slave_instance.updateLocalRolesOnSecurityGroups()
self.tic()
self._cleaupREQUEST()
def _makeSoftwareProduct(self, new_id):
software_product = self.portal.software_product_module\
.template_software_product.Base_createCloneDocument(batch_mode=1)
software_product.edit(
reference='TESTSOFTPROD-%s' % new_id,
title='Test software product %s' % new_id
)
software_product.publish()
return software_product
def _makeSoftwareRelease(self, new_id):
software_release = self.portal.software_release_module\
.template_software_release.Base_createCloneDocument(batch_mode=1)
software_release.edit(
url_string=self.generateNewSoftwareReleaseUrl(),
reference='TESTSOFTRELS-%s' % new_id,
title='Start requested for %s' % new_id
)
software_release.release()
return software_release
def _cleaupREQUEST(self):
self.portal.REQUEST['request_instance'] = None
self.portal.REQUEST.headers = {}
def generateNewId(self):
return "%sö" % self.portal.portal_ids.generateNewId(
id_group=('slapos_core_test'))
def generateNewSoftwareReleaseUrl(self):
return 'http://example.org/têst%s.cfg' % self.generateNewId()
def generateNewSoftwareType(self):
return 'Type ë@î %s' % self.generateNewId()
def generateNewSoftwareTitle(self):
return 'Title é#ï %s' % self.generateNewId()
def generateSafeXml(self):
return '<?xml version="1.0" encoding="utf-8"?><instance><parameter '\
'id="%s">%s</parameter></instance>' % \
("paramé".decode("UTF-8").encode("UTF-8"),
self.generateNewId().decode("UTF-8").encode("UTF-8"))
def generateEmptyXml(self):
return '<?xml version="1.0" encoding="utf-8"?><instance></instance>'
class TestSlapOSDummy(testSlapOSMixin): class TestSlapOSDummy(testSlapOSMixin):
run_all_test = 1 run_all_test = 1
def test(self): def test(self):
......
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