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 @@
import transaction
from functools import wraps
from Products.ERP5Type.tests.utils import createZODBPythonScript
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin, withAbort
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin, withAbort
import os
import tempfile
from DateTime import DateTime
......@@ -83,7 +83,7 @@ if context.getTitle() == 'Not visited by %s':
return wrapped
return wrapper
class TestInstanceInvoicingAlarm(testSlapOSMixin):
class TestInstanceInvoicingAlarm(SlapOSTestCaseMixin):
@withAbort
def test_noSaleOrderPackingList_newSoftwareInstance(self):
"""
......@@ -275,7 +275,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
self.assertEqual(2, instance.getInvoicingSynchronizationPointer())
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_movement(setup_line, instance, subscription, 1)
self.check_instance_movement(destroy_line, instance, subscription, 1)
......@@ -347,7 +347,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
self.assertEqual(2, instance.getInvoicingSynchronizationPointer())
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_movement(setup_line, instance, subscription, 1)
......@@ -404,7 +404,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
self.assertEqual(4, instance.getInvoicingSynchronizationPointer())
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_movement(setup_line, instance, subscription, 1)
self.check_instance_movement(update_line, instance, subscription, 2)
......@@ -525,7 +525,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
self.assertEqual(4, instance.getInvoicingSynchronizationPointer())
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_movement(update_line, instance, subscription, 2)
......@@ -646,7 +646,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
self.assertEqual(4, instance.getInvoicingSynchronizationPointer())
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_movement(update_line, instance, subscription, 2)
......@@ -689,7 +689,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
self.check_instance_delivery(delivery, stop_date, stop_date, person, 1)
self.check_instance_movement(update_line, instance, subscription, 1)
class TestOpenSaleOrderAlarm(testSlapOSMixin):
class TestOpenSaleOrderAlarm(SlapOSTestCaseMixin):
def test_noOSO_newPerson(self):
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
......@@ -743,7 +743,7 @@ class TestOpenSaleOrderAlarm(testSlapOSMixin):
'Visited by HostingSubscription_requestUpdateOpenSaleOrder',
subscription.workflow_history['edit_workflow'][-1]['comment'])
class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
class TestHostingSubscription_requestUpdateOpenSaleOrder(SlapOSTestCaseMixin):
def test_REQUEST_disallowed(self):
subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
......@@ -1291,7 +1291,7 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
self.assertTrue(new_effective_date > effective_date,
"%s <= %s" % (new_effective_date, effective_date))
class TestSlapOSTriggerBuildAlarm(testSlapOSMixin):
class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin):
@simulateByTitlewMark('SimulationMovement_buildSlapOS')
def test_SimulationMovement_withoutDelivery(self):
applied_rule = self.portal.portal_simulation.newContent(
......@@ -1475,7 +1475,7 @@ class TestSlapOSTriggerBuildAlarm(testSlapOSMixin):
if os.path.exists(activate_simulator):
os.unlink(activate_simulator)
class TestSlapOSManageBuildingCalculatingDeliveryAlarm(testSlapOSMixin):
class TestSlapOSManageBuildingCalculatingDeliveryAlarm(SlapOSTestCaseMixin):
@simulateByTitlewMark('Delivery_manageBuildingCalculatingDelivery')
def _test(self, state, message):
delivery = self.portal.sale_packing_list_module.newContent(
......@@ -1656,7 +1656,7 @@ class TestSlapOSConfirmedDeliveryMixin:
'confirmed', True)
class TestSlapOSStartConfirmedAggregatedSalePackingListAlarm(
testSlapOSMixin, TestSlapOSConfirmedDeliveryMixin):
SlapOSTestCaseMixin, TestSlapOSConfirmedDeliveryMixin):
destination_state = 'started'
script = 'Delivery_startConfirmedAggregatedSalePackingList'
portal_type = 'Sale Packing List'
......@@ -1692,7 +1692,7 @@ class TestSlapOSStartConfirmedAggregatedSalePackingListAlarm(
destination_decision='organisation_module/slapos',
price_currency='currency_module/EUR',
)
movement = delivery.newContent(
delivery.newContent(
portal_type="Sale Packing List Line",
resource='service_module/slapos_instance_setup',
quantity=0,
......@@ -1708,7 +1708,7 @@ class TestSlapOSStartConfirmedAggregatedSalePackingListAlarm(
self.assertEquals(delivery.getSimulationState(), 'started')
class TestSlapOSDeliverStartedAggregatedSalePackingListAlarm(
testSlapOSMixin):
SlapOSTestCaseMixin):
destination_state = 'delivered'
script = 'Delivery_deliverStartedAggregatedSalePackingList'
portal_type = 'Sale Packing List'
......@@ -1805,13 +1805,13 @@ class TestSlapOSDeliverStartedAggregatedSalePackingListAlarm(
'started', True)
class TestSlapOSStopConfirmedAggregatedSaleInvoiceTransactionAlarm(
testSlapOSMixin, TestSlapOSConfirmedDeliveryMixin):
SlapOSTestCaseMixin, TestSlapOSConfirmedDeliveryMixin):
destination_state = 'stopped'
script = 'Delivery_stopConfirmedAggregatedSaleInvoiceTransaction'
portal_type = 'Sale Invoice Transaction'
alarm = 'slapos_stop_confirmed_aggregated_sale_invoice_transaction'
class TestSlapOSUpdateOpenSaleOrderPeriod(testSlapOSMixin):
class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
def createOpenOrder(self):
open_order = self.portal.open_sale_order_module\
......@@ -1947,7 +1947,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by O
'Visited by OpenSaleOrder_updatePeriod',
open_order.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSReindexOpenSaleOrder(testSlapOSMixin):
class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin):
def createOpenOrder(self):
open_order = self.portal.open_sale_order_module\
......@@ -2004,7 +2004,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by O
'Visited by OpenSaleOrder_reindexIfIndexedBeforeLine',
open_order.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSGeneratePackingListFromTioXML(testSlapOSMixin):
class TestSlapOSGeneratePackingListFromTioXML(SlapOSTestCaseMixin):
def createTioXMLFile(self):
document = self.portal.consumption_document_module.newContent(
......
......@@ -47,14 +47,9 @@
<value>
<tuple>
<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, 29: 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:528, 20: Unused variable \'destroy_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:688, 29: Unused variable \'destroy_line\' (unused-variable)</string>
<string>W:688, 4: Unused variable \'setup_line\' (unused-variable)</string>
......@@ -68,7 +63,6 @@
<string>W:1463, 23: 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:1695, 4: Unused variable \'movement\' (unused-variable)</string>
</tuple>
</value>
</item>
......
......@@ -5,15 +5,13 @@
#
##############################################################################
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
from DateTime import DateTime
import transaction
def convertCategoryList(base, l):
return ['%s/%s' % (base, q) for q in l]
class TestSlapOSSalePackingListBuilder(testSlapOSMixin):
class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
def checkSimulationMovement(self, simulation_movement):
self.assertEqual(1.0, simulation_movement.getDeliveryRatio())
self.assertEqual(0.0, simulation_movement.getDeliveryError())
......@@ -1210,7 +1208,7 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
self.assertEqual(invoice_2.getRelativeUrl(),
model_line_2_tax_bis.getParentValue().getRelativeUrl())
class TestSlapOSAggregatedDeliveryBuilder(testSlapOSMixin):
class TestSlapOSAggregatedDeliveryBuilder(SlapOSTestCaseMixin):
def emptyBuild(self, **kw):
delivery_list = self._build(**kw)
self.assertSameSet([], delivery_list)
......
......@@ -6,10 +6,22 @@
</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>testSlapOSAccountingBuilder</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSAccountingBuilder</string> </value>
......@@ -33,9 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 11, 0: Unused import transaction (unused-import)</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......@@ -45,13 +55,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<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>
......@@ -64,7 +89,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -73,7 +98,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......
......@@ -6,7 +6,7 @@
##############################################################################
from erp5.component.test.testSlapOSCloudConstraint import TestSlapOSConstraintMixin
from Products.ERP5Type.Base import WorkflowMethod
from Products.SlapOS.tests.testSlapOSMixin import withAbort
from erp5.component.test.SlapOSTestCaseMixin import withAbort
from unittest import skip
import transaction
......
# Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import transaction
from Products.ERP5Type.tests.utils import createZODBPythonScript
from DateTime import DateTime
from Products.ERP5Type.DateUtils import addToDate
class TestSlapOSAccountingInteractionWorkflow(testSlapOSMixin):
class TestSlapOSAccountingInteractionWorkflow(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
......
......@@ -6,10 +6,22 @@
</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>testSlapOSAccountingInteractionWorkflow</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSAccountingInteractionWorkflow</string> </value>
......@@ -33,9 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 7, 0: Unused import addToDate (unused-import)</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......@@ -45,13 +55,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<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>
......@@ -64,7 +89,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -73,7 +98,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......
......@@ -4,9 +4,8 @@
# 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 Products.ERP5Type.DateUtils import addToDate
from Products.ERP5.Document.SimulationMovement import SimulationMovement
......@@ -27,7 +26,7 @@ def getSimulationStatePlannedDelivered(self, *args, **kwargs):
return 'delivered'
return 'planned'
class TestDefaultInvoiceTransactionRule(testSlapOSMixin):
class TestDefaultInvoiceTransactionRule(SlapOSTestCaseMixin):
@withAbort
def test_simulation(self):
SimulationMovement.original_getSimulationState = SimulationMovement\
......@@ -159,7 +158,7 @@ class TestDefaultInvoiceTransactionRule(testSlapOSMixin):
.original_getSimulationState
class TestDefaultInvoiceRule(testSlapOSMixin):
class TestDefaultInvoiceRule(SlapOSTestCaseMixin):
@withAbort
def test_simulation(self):
SimulationMovement.original_getSimulationState = SimulationMovement\
......@@ -233,7 +232,7 @@ class TestDefaultInvoiceRule(testSlapOSMixin):
.original_getSimulationState
class TestDefaultInvoicingRule(testSlapOSMixin):
class TestDefaultInvoicingRule(SlapOSTestCaseMixin):
@withAbort
def test_simulation(self):
SimulationMovement.original_getSimulationState = SimulationMovement\
......@@ -353,7 +352,7 @@ class TestDefaultInvoicingRule(testSlapOSMixin):
SimulationMovement.getSimulationState = SimulationMovement\
.original_getSimulationState
class TestDefaultPaymentRule(testSlapOSMixin):
class TestDefaultPaymentRule(SlapOSTestCaseMixin):
@withAbort
def test_simulation(self):
SimulationMovement.original_getSimulationState = SimulationMovement\
......@@ -418,7 +417,7 @@ class TestDefaultPaymentRule(testSlapOSMixin):
SimulationMovement.getSimulationState = SimulationMovement\
.original_getSimulationState
class TestHostingSubscriptionSimulation(testSlapOSMixin):
class TestHostingSubscriptionSimulation(SlapOSTestCaseMixin):
def _prepare(self):
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
......@@ -666,7 +665,7 @@ class TestHostingSubscriptionSimulation(testSlapOSMixin):
SimulationMovement.isFrozen = SimulationMovement.originalIsFrozen
delattr(SimulationMovement, 'originalIsFrozen')
class TestDefaultTradeModelRule(testSlapOSMixin):
class TestDefaultTradeModelRule(SlapOSTestCaseMixin):
@withAbort
def test_simulation(self):
SimulationMovement.original_getSimulationState = SimulationMovement\
......@@ -779,7 +778,7 @@ class TestDefaultTradeModelRule(testSlapOSMixin):
SimulationMovement.getSimulationState = SimulationMovement\
.original_getSimulationState
class TestDefaultDeliveryRule(testSlapOSMixin):
class TestDefaultDeliveryRule(SlapOSTestCaseMixin):
trade_condition = 'sale_trade_condition_module/slapos_aggregated_trade_condition'
def test(self):
def newArrow():
......@@ -867,7 +866,7 @@ class TestDefaultDeliveryRule(testSlapOSMixin):
self.assertSameSet(['default_invoicing_rule'], [q.getSpecialiseReference()
for q in simulation_movement.contentValues(portal_type='Applied Rule')])
class TestDefaultDeliveryRuleConsumption(testSlapOSMixin):
class TestDefaultDeliveryRuleConsumption(SlapOSTestCaseMixin):
def test(self):
def newArrow():
return self.portal.organisation_module.newContent(
......@@ -907,6 +906,6 @@ class TestDefaultDeliveryRuleConsumption(testSlapOSMixin):
applied_rule_list = delivery.getCausalityRelatedValueList()
self.assertEqual(0, len(applied_rule_list))
class TestDefaultDeliveryRuleSubscription(testSlapOSMixin):
class TestDefaultDeliveryRuleSubscription(SlapOSTestCaseMixin):
trade_condition = 'sale_trade_condition_module/slapos_subscr'\
'iption_trade_condition'
......@@ -6,10 +6,22 @@
</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>testSlapOSAccountingRule</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSAccountingRule</string> </value>
......@@ -33,9 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 22, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......@@ -45,13 +55,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<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>
......@@ -64,7 +89,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -73,7 +98,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......
......@@ -4,14 +4,13 @@
# 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 DateTime import DateTime
import time
class TestSlapOSAccounting(testSlapOSMixin):
class TestSlapOSAccounting(SlapOSTestCaseMixin):
def createHostingSubscription(self):
new_id = self.generateNewId()
......
......@@ -6,10 +6,22 @@
</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>testSlapOSAccountingSkins</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSAccountingSkins</string> </value>
......@@ -34,7 +46,7 @@
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W:174, 4: Unused variable \'line\' (unused-variable)</string>
<string>W:173, 4: Unused variable \'line\' (unused-variable)</string>
</tuple>
</value>
</item>
......@@ -45,13 +57,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<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>
......@@ -64,7 +91,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -73,7 +100,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......
......@@ -6,14 +6,11 @@
##############################################################################
import transaction
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin, withAbort, simulate
from erp5.component.test.SlapOSTestCaseMixin import \
SlapOSTestCaseMixinWithAbort, SlapOSTestCaseMixin, simulate
from zExceptions import Unauthorized
class TestSlapOSComputer_reportComputerConsumption(testSlapOSMixin):
def beforeTearDown(self):
transaction.abort()
class TestSlapOSComputer_reportComputerConsumption(SlapOSTestCaseMixinWithAbort):
def createComputer(self):
new_id = self.generateNewId()
......@@ -128,10 +125,7 @@ class TestSlapOSComputer_reportComputerConsumption(testSlapOSMixin):
self.assertEquals(document2.getValidationState(), "submitted")
self.assertEquals(document2.getContributor(), computer.getRelativeUrl())
class TestSlapOSComputerConsumptionTioXMLFile_parseXml(testSlapOSMixin):
def beforeTearDown(self):
transaction.abort()
class TestSlapOSComputerConsumptionTioXMLFile_parseXml(SlapOSTestCaseMixinWithAbort):
def createTioXMLFile(self):
document = self.portal.consumption_document_module.newContent(
......@@ -261,7 +255,7 @@ class TestSlapOSComputerConsumptionTioXMLFile_parseXml(testSlapOSMixin):
})
class TestSlapOSComputerConsumptionTioXMLFile_solveInvoicingGeneration(
testSlapOSMixin):
SlapOSTestCaseMixin):
def createTioXMLFile(self):
document = self.portal.consumption_document_module.newContent(
......
......@@ -6,10 +6,22 @@
</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>testSlapOSConsumptionSkins</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSConsumptionSkins</string> </value>
......@@ -33,9 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 9, 0: Unused import withAbort (unused-import)</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......@@ -45,13 +55,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<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>
......@@ -64,7 +89,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -73,7 +98,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestSlapOSRequestValidationPayment(testSlapOSMixin):
class TestSlapOSRequestValidationPayment(SlapOSTestCaseMixin):
def _makeSlaveTree(self, requested_template_id='template_slave_instance'):
super(TestSlapOSRequestValidationPayment, self).\
_makeTree(requested_template_id=requested_template_id)
SlapOSTestCaseMixin.\
_makeTree(self, requested_template_id=requested_template_id)
def _simulateSoftwareInstance_requestValidationPayment(self):
script_name = 'SoftwareInstance_requestValidationPayment'
......
......@@ -6,10 +6,22 @@
</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>testSlapOSContractAlarm</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSContractAlarm</string> </value>
......@@ -43,13 +55,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<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>
......@@ -62,7 +89,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -71,7 +98,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from zExceptions import Unauthorized
from DateTime import DateTime
from functools import wraps
from Products.ERP5Type.tests.utils import createZODBPythonScript
import difflib
class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
def beforeTearDown(self):
transaction.abort()
class TestSlapOSSoftwareInstance_requestValidationPayment(SlapOSTestCaseMixinWithAbort):
def createCloudContract(self):
new_id = self.generateNewId()
......@@ -62,23 +55,23 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
return person, instance, subscription
def test_requestValidationPayment_REQUEST_disallowed(self):
person, instance, subscription = self.createNeededDocuments()
_, instance, _ = self.createNeededDocuments()
self.assertRaises(
Unauthorized,
instance.SoftwareInstance_requestValidationPayment,
REQUEST={})
def test_prevent_concurrency(self):
person, instance, subscription = self.createNeededDocuments()
person, instance, _ = self.createNeededDocuments()
tag = "%s_requestValidationPayment_inProgress" % person.getUid()
person.reindexObject(activate_kw={'tag': tag})
transaction.commit()
self.commit()
result = instance.SoftwareInstance_requestValidationPayment()
self.assertEquals(result, None)
def test_addCloudContract(self):
person, instance, subscription = self.createNeededDocuments()
person, instance, _ = self.createNeededDocuments()
contract = instance.SoftwareInstance_requestValidationPayment()
# Default property
......@@ -89,34 +82,34 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
'Contract for "%s"' % person.getTitle())
def test_addCloudContract_do_not_duplicate_contract_if_not_reindexed(self):
person, instance, subscription = self.createNeededDocuments()
_, instance, _ = self.createNeededDocuments()
contract = instance.SoftwareInstance_requestValidationPayment()
transaction.commit()
self.commit()
contract2 = instance.SoftwareInstance_requestValidationPayment()
self.assertNotEquals(contract, None)
self.assertEquals(contract2, None)
def test_addCloudContract_existing_invalidated_contract(self):
person, instance, subscription = self.createNeededDocuments()
_, instance, _ = self.createNeededDocuments()
contract = instance.SoftwareInstance_requestValidationPayment()
transaction.commit()
self.commit()
self.tic()
contract2 = instance.SoftwareInstance_requestValidationPayment()
self.assertNotEquals(contract, None)
self.assertEquals(contract2.getRelativeUrl(), contract.getRelativeUrl())
def test_addCloudContract_existing_validated_contract(self):
person, instance, subscription = self.createNeededDocuments()
_, instance, _ = self.createNeededDocuments()
contract = instance.SoftwareInstance_requestValidationPayment()
contract.validate()
transaction.commit()
self.commit()
self.tic()
contract2 = instance.SoftwareInstance_requestValidationPayment()
self.assertNotEquals(contract, None)
self.assertEquals(contract2.getRelativeUrl(), contract.getRelativeUrl())
def test_do_nothing_if_validated_contract(self):
person, instance, subscription = self.createNeededDocuments()
person, instance, _ = self.createNeededDocuments()
contract = self.createCloudContract()
contract.edit(destination_section_value=person)
contract.validate()
......@@ -128,7 +121,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
self.assertEquals(contract2.getValidationState(), "validated")
def test_validate_contract_if_payment_found(self):
person, instance, subscription = self.createNeededDocuments()
person, instance, _ = self.createNeededDocuments()
contract = self.createCloudContract()
contract.edit(destination_section_value=person)
payment = self.createPaymentTransaction()
......@@ -145,7 +138,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
self.assertEquals(contract2.getValidationState(), "validated")
def test_create_invoice_if_needed_and_no_payment_found(self):
person, instance, subscription = self.createNeededDocuments()
person, instance, _ = self.createNeededDocuments()
contract = self.createCloudContract()
contract.edit(destination_section_value=person)
self.assertEquals(contract.getValidationState(), "invalidated")
......@@ -173,7 +166,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
self.assertEquals(invoice.getStartDate(), invoice.getStopDate())
def test_do_nothing_if_invoice_is_ongoing(self):
person, instance, subscription = self.createNeededDocuments()
person, instance, _ = self.createNeededDocuments()
contract = self.createCloudContract()
invoice = self.createInvoiceTransaction()
self.portal.portal_workflow._jumpToStateFor(invoice, 'confirmed')
......@@ -190,7 +183,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
self.assertEquals(contract2.getValidationState(), "invalidated")
def test_forget_current_cancelled_invoice(self):
person, instance, subscription = self.createNeededDocuments()
person, instance, _ = self.createNeededDocuments()
contract = self.createCloudContract()
invoice = self.createInvoiceTransaction()
self.portal.portal_workflow._jumpToStateFor(invoice, 'cancelled')
......@@ -207,7 +200,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
self.assertEquals(contract2.getValidationState(), "invalidated")
def test_forget_current_grouped_invoice(self):
person, instance, subscription = self.createNeededDocuments()
person, instance, _ = self.createNeededDocuments()
contract = self.createCloudContract()
invoice = self.createInvoiceTransaction()
line = invoice.newContent(
......@@ -230,7 +223,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
self.assertEquals(contract2.getValidationState(), "invalidated")
def test_do_nothing_if_invoice_is_not_grouped(self):
person, instance, subscription = self.createNeededDocuments()
person, instance, _ = self.createNeededDocuments()
contract = self.createCloudContract()
invoice = self.createInvoiceTransaction()
invoice.newContent(
......@@ -250,10 +243,7 @@ class TestSlapOSSoftwareInstance_requestValidationPayment(testSlapOSMixin):
self.assertEquals(contract2.getCausality(""), invoice.getRelativeUrl())
self.assertEquals(contract2.getValidationState(), "invalidated")
class TestSlapOSPerson_isAllowedToAllocate(testSlapOSMixin):
def beforeTearDown(self):
transaction.abort()
class TestSlapOSPerson_isAllowedToAllocate(SlapOSTestCaseMixinWithAbort):
def createPerson(self):
new_id = self.generateNewId()
......
......@@ -6,10 +6,22 @@
</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>testSlapOSContractSkins</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSContractSkins</string> </value>
......@@ -33,28 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<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>
<tuple/>
</value>
</item>
<item>
......@@ -64,13 +55,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<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>
......@@ -83,7 +89,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -92,7 +98,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</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.
import transaction
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin, simulate
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin, simulate
from Products.ERP5Type.tests.utils import createZODBPythonScript
from unittest import skip
import json
......@@ -11,11 +10,11 @@ from DateTime import DateTime
from Products.ERP5Type.DateUtils import addToDate
from App.Common import rfc1123_date
class TestSlapOSAllocation(testSlapOSMixin):
class TestSlapOSAllocation(SlapOSTestCaseMixin):
def _makeSlaveTree(self, requested_template_id='template_slave_instance'):
super(TestSlapOSAllocation, self).\
_makeTree(requested_template_id=requested_template_id)
SlapOSTestCaseMixin._makeTree(self, requested_template_id=requested_template_id)
def _simulatePerson_isAllowedToAllocate(self):
script_name = 'Person_isAllowedToAllocate'
......@@ -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')
class TestSlapOSCoreSlapOSAssertHostingSubscriptionPredecessorAlarm(
testSlapOSMixin):
SlapOSTestCaseMixin):
def afterSetUp(self):
super(TestSlapOSCoreSlapOSAssertHostingSubscriptionPredecessorAlarm,
self).afterSetUp()
SlapOSTestCaseMixin.afterSetUp(self)
self._makeTree()
def test_HostingSubscription_assertPredecessor(self):
......@@ -1006,10 +1004,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by H
'Visited by HostingSubscription_assertPredecessor',
self.hosting_subscription.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSFreeComputerPartitionAlarm(testSlapOSMixin):
class TestSlapOSFreeComputerPartitionAlarm(SlapOSTestCaseMixin):
def afterSetUp(self):
super(TestSlapOSFreeComputerPartitionAlarm, self).afterSetUp()
SlapOSTestCaseMixin.afterSetUp(self)
self._makeTree()
def test_Instance_tryToUnallocatePartition(self):
......@@ -1145,9 +1143,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by I
'Visited by Instance_tryToUnallocatePartition',
self.software_instance.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSFreeComputerPartitionAlarmWithSlave(testSlapOSMixin):
class TestSlapOSFreeComputerPartitionAlarmWithSlave(SlapOSTestCaseMixin):
def afterSetUp(self):
super(TestSlapOSFreeComputerPartitionAlarmWithSlave, self).afterSetUp()
SlapOSTestCaseMixin.afterSetUp(self)
self._makeTree(requested_template_id='template_slave_instance')
def test_Instance_tryToUnallocatePartition(self):
......@@ -1176,10 +1174,10 @@ class TestSlapOSFreeComputerPartitionAlarmWithSlave(testSlapOSMixin):
self.assertEqual('busy', self.partition.getSlapState())
class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(testSlapOSMixin):
class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
def afterSetUp(self):
super(TestSlapOSGarbageCollectDestroyedRootTreeAlarm, self).afterSetUp()
SlapOSTestCaseMixin.afterSetUp(self)
self._makeTree()
def test_Instance_tryToGarbageCollect(self):
......@@ -1344,10 +1342,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by I
'Visited by Instance_tryToGarbageCollect',
self.software_instance.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSUpdateComputerCapacityScopeAlarm(testSlapOSMixin):
class TestSlapOSUpdateComputerCapacityScopeAlarm(SlapOSTestCaseMixin):
def afterSetUp(self):
super(TestSlapOSUpdateComputerCapacityScopeAlarm, self).afterSetUp()
SlapOSTestCaseMixin.afterSetUp(self)
self.computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1)
self.computer.edit(
......@@ -1363,7 +1361,7 @@ class TestSlapOSUpdateComputerCapacityScopeAlarm(testSlapOSMixin):
'text': '#access ok',
'created_at': rfc1123_date(DateTime())
})
self.commit()
transaction.commit()
def test_Computer_checkAndUpdateCapacityScope(self):
self.computer.Computer_checkAndUpdateCapacityScope()
......@@ -1542,7 +1540,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
'Visited by Computer_checkAndUpdateCapacityScope',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSGarbageCollectStoppedRootTreeAlarm(testSlapOSMixin):
class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
def createInstance(self):
hosting_subscription = self.portal.hosting_subscription_module\
......@@ -1654,7 +1652,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by I
'Visited by Instance_tryToStopCollect',
instance.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(testSlapOSMixin):
class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
def createInstance(self):
hosting_subscription = self.portal.hosting_subscription_module\
......@@ -1859,7 +1857,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by I
'Visited by Instance_tryToGarbageCollectNonAllocatedRootTree',
instance.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(testSlapOSMixin):
class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
def createInstance(self):
hosting_subscription = self.portal.hosting_subscription_module\
......@@ -2105,7 +2103,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
'Visited by SoftwareInstance_tryToGarbageUnlinkedInstance',
slave_instance0.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSInvalidateDestroyedInstance(testSlapOSMixin):
class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin):
def createSoftwareInstance(self):
new_id = self.generateNewId()
......
......@@ -4,11 +4,11 @@
# Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved.
#
##############################################################################
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import transaction
class TestSlapOSConstraintMixin(testSlapOSMixin):
class TestSlapOSConstraintMixin(SlapOSTestCaseMixin):
@staticmethod
def getMessageList(o):
return [str(q.getMessage()) for q in o.checkConsistency()]
......
......@@ -29,11 +29,11 @@
import unittest
import random
from AccessControl import getSecurityManager
from Products.SlapOS.tests.testSlapOSMixin import testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
from Products.PluggableAuthService.interfaces.plugins import\
IAuthenticationPlugin
class TestSlapOSSecurityMixin(testSlapOSMixin):
class TestSlapOSSecurityMixin(SlapOSTestCaseMixin):
def _generateRandomUniqueUserId(self, portal_type, search_key="user_id"):
user_id = None
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import transaction
from unittest import expectedFailure
from Products.ERP5Type.Errors import UnsupportedWorkflowMethod
......@@ -8,10 +7,10 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed
from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager
class TestSlapOSCoreComputerPartitionSlapInterfaceWorkflow(testSlapOSMixin):
class TestSlapOSCoreComputerPartitionSlapInterfaceWorkflow(SlapOSTestCaseMixin):
def afterSetUp(self):
self.login()
super(TestSlapOSCoreComputerPartitionSlapInterfaceWorkflow, self).afterSetUp()
SlapOSTestCaseMixin.afterSetUp(self)
# Clone computer document
self.computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1)
......@@ -100,9 +99,9 @@ class TestSlapOSCoreComputerPartitionSlapInterfaceWorkflow(testSlapOSMixin):
self.assertEqual(1, self.portal.portal_catalog.countResults(
parent_uid=self.computer.getUid(), free_for_request=1)[0][0])
class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin):
class TestSlapOSCoreComputerSlapInterfaceWorkflow(SlapOSTestCaseMixin):
def afterSetUp(self):
super(TestSlapOSCoreComputerSlapInterfaceWorkflow, self).afterSetUp()
SlapOSTestCaseMixin.afterSetUp(self)
# Clone computer document
self.computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1)
......@@ -115,7 +114,7 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin):
self.tic()
def beforeTearDown(self):
super(TestSlapOSCoreComputerSlapInterfaceWorkflow, self).beforeTearDown()
SlapOSTestCaseMixin.beforeTearDown(self)
self.portal.REQUEST['computer_key'] = None
self.portal.REQUEST['computer_certificate'] = None
......@@ -367,10 +366,10 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin):
self.assertEqual(None, self.portal.REQUEST.get('computer_certificate'))
self.assertEqual(None, self.computer.getDestinationReference())
class TestSlapOSCorePersonComputerSupply(testSlapOSMixin):
class TestSlapOSCorePersonComputerSupply(SlapOSTestCaseMixin):
def afterSetUp(self):
super(TestSlapOSCorePersonComputerSupply, self).afterSetUp()
SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject()
# Clone computer document
......@@ -674,9 +673,9 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin):
self.assertEqual('SOFTINSTALL-%s' % (previous_id+2),
software_installation.getReference())
class TestSlapOSCoreInstanceSlapInterfaceWorkflow(testSlapOSMixin):
class TestSlapOSCoreInstanceSlapInterfaceWorkflow(SlapOSTestCaseMixin):
def afterSetUp(self):
super(TestSlapOSCoreInstanceSlapInterfaceWorkflow, self).afterSetUp()
SlapOSTestCaseMixin.afterSetUp(self)
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
......@@ -1071,11 +1070,11 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflow(testSlapOSMixin):
connection_xml="<foo bar /<>")
transaction.abort()
class TestSlapOSCoreSoftwareInstanceRequest(testSlapOSMixin):
class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
"""Tests instance.requestInstance"""
def afterSetUp(self):
super(TestSlapOSCoreSoftwareInstanceRequest, self).afterSetUp()
SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject()
new_id = self.generateNewId()
......@@ -1909,10 +1908,10 @@ class TestSlapOSCoreSoftwareInstanceRequest(testSlapOSMixin):
self.assertEqual(bang_amount+1, self._countBang(self.software_instance))
class TestSlapOSCorePersonRequest(testSlapOSMixin):
class TestSlapOSCorePersonRequest(SlapOSTestCaseMixin):
def afterSetUp(self):
super(TestSlapOSCorePersonRequest, self).afterSetUp()
SlapOSTestCaseMixin.afterSetUp(self)
person_user = self.makePerson()
self.tic()
......@@ -2454,13 +2453,13 @@ class TestSlapOSCorePersonRequest(testSlapOSMixin):
self.assertNotEquals(hosting_subscription.getRelativeUrl(),
hosting_subscription2.getRelativeUrl())
class TestSlapOSCorePersonRequestComputer(testSlapOSMixin):
class TestSlapOSCorePersonRequestComputer(SlapOSTestCaseMixin):
def generateNewComputerTitle(self):
return 'My Comp %s' % self.generateNewId()
def afterSetUp(self):
super(TestSlapOSCorePersonRequestComputer, self).afterSetUp()
SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject()
person_user = self.makePerson()
......@@ -2654,7 +2653,7 @@ class TestSlapOSCorePersonRequestComputer(testSlapOSMixin):
self.assertRaises(NotImplementedError, person.requestComputer,
computer_title=computer_title)
class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin):
class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin):
def test_Computer_setSubjectList(self):
self.person_user = self.makePerson()
......
......@@ -3,3 +3,4 @@ test.erp5.testSlapOSCloudWorkflow
test.erp5.testSlapOSCloudSecurityGroup
test.erp5.testSlapOSCloudConstraint
test.erp5.testSlapOSCloudShadow
test.erp5.SlapOSTestCaseMixin
\ No newline at end of file
......@@ -5,14 +5,14 @@
#
##############################################################################
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import \
SlapOSTestCaseMixin
import os
class TestSlapOSConfigurator(testSlapOSMixin):
class TestSlapOSConfigurator(SlapOSTestCaseMixin):
def bootstrapSite(self):
super(TestSlapOSConfigurator, self).bootstrapSite()
SlapOSTestCaseMixin.bootstrapSite(self)
self.getBusinessConfiguration().BusinessConfiguration_invokeSlapOSMasterPromiseAlarmList()
self.tic()
......
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import \
SlapOSTestCaseMixin
from unittest import skip
from DateTime import DateTime
from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestSlapOSCRMCreateRegularisationRequest(testSlapOSMixin):
class TestSlapOSCRMCreateRegularisationRequest(SlapOSTestCaseMixin):
def _simulatePerson_checkToCreateRegularisationRequest(self):
script_name = 'Person_checkToCreateRegularisationRequest'
......@@ -92,7 +92,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P
'Visited by Person_checkToCreateRegularisationRequest',
person.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmInvalidateSuspendedRegularisationRequest(testSlapOSMixin):
class TestSlapOSCrmInvalidateSuspendedRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
......@@ -156,7 +156,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_invalidateIfPersonBalanceIsOk',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmCancelInvoiceRelatedToSuspendedRegularisationRequest(testSlapOSMixin):
class TestSlapOSCrmCancelInvoiceRelatedToSuspendedRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
......@@ -220,7 +220,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmTriggerEscalationOnAcknowledgmentRegularisationRequest(testSlapOSMixin):
class TestSlapOSCrmTriggerEscalationOnAcknowledgmentRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
......@@ -303,7 +303,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_triggerAcknowledgmentEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmTriggerEscalationOnStopReminderRegularisationRequest(testSlapOSMixin):
class TestSlapOSCrmTriggerEscalationOnStopReminderRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
......@@ -386,7 +386,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_triggerStopReminderEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmTriggerEscalationOnStopAcknowledgmentRegularisationRequest(testSlapOSMixin):
class TestSlapOSCrmTriggerEscalationOnStopAcknowledgmentRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
......@@ -469,7 +469,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_triggerStopAcknowledgmentEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmTriggerEscalationOnDeleteReminderRegularisationRequest(testSlapOSMixin):
class TestSlapOSCrmTriggerEscalationOnDeleteReminderRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
......@@ -552,7 +552,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_triggerDeleteReminderEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmStopHostingSubscription(testSlapOSMixin):
class TestSlapOSCrmStopHostingSubscription(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
......@@ -654,7 +654,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_stopHostingSubscriptionList',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmDeleteHostingSubscription(testSlapOSMixin):
class TestSlapOSCrmDeleteHostingSubscription(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
......@@ -738,8 +738,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
'Visited by RegularisationRequest_deleteHostingSubscriptionList',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmMonitoringCheckComputerState(testSlapOSMixin):
class TestSlapOSCrmMonitoringCheckComputerState(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
......@@ -825,7 +824,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
allocation_scope='closed/termination')
class TestSlapOSCrmMonitoringCheckComputerAllocationScope(testSlapOSMixin):
class TestSlapOSCrmMonitoringCheckComputerAllocationScope(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
......@@ -909,7 +908,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
self.computer.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmMonitoringCheckComputerPersonalAllocationScope(testSlapOSMixin):
class TestSlapOSCrmMonitoringCheckComputerPersonalAllocationScope(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
......@@ -1007,7 +1006,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
self.assertNotEqual('Visited by Computer_checkAndUpdatePersonalAllocationScope',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmMonitoringCheckInstanceInError(testSlapOSMixin):
class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
......@@ -1089,7 +1088,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by H
self.assertNotEqual('Visited by HostingSubscription_checkSoftwareInstanceState',
host_sub.workflow_history['edit_workflow'][-1]['comment'])
class TestSlaposCrmUpdateSupportRequestState(testSlapOSMixin):
class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
......
......@@ -46,7 +46,7 @@
<key> <string>text_content_warning_message</string> </key>
<value>
<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>
</value>
</item>
......
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin, simulate
from erp5.component.test.SlapOSTestCaseMixin import \
SlapOSTestCaseMixin,SlapOSTestCaseMixinWithAbort, simulate
from zExceptions import Unauthorized
from DateTime import DateTime
from Products.ERP5Type.tests.utils import createZODBPythonScript
......@@ -11,12 +11,10 @@ import json
def getFakeSlapState():
return "destroy_requested"
class TestCRMSkinsMixin(testSlapOSMixin):
abort_transaction = 1
class TestCRMSkinsMixin(SlapOSTestCaseMixinWithAbort):
def afterSetUp(self):
super(TestCRMSkinsMixin, self).afterSetUp()
SlapOSTestCaseMixinWithAbort.afterSetUp(self)
self.person = self.makePerson(new_id=self.new_id, index=0, user=0)
def _cancelTestSupportRequestList(self, title="%"):
......@@ -315,9 +313,7 @@ class TestSlapOSTicket_getLatestEvent(TestSlapOSTicketEvent):
self._test_event(ticket)
class TestSlapOSPerson_checkToCreateRegularisationRequest(testSlapOSMixin):
abort_transaction = 1
class TestSlapOSPerson_checkToCreateRegularisationRequest(SlapOSTestCaseMixinWithAbort):
@simulate('Entity_statBalance', '*args, **kwargs', 'return "1"')
def test_addRegularisationRequest_payment_requested(self):
......@@ -498,9 +494,7 @@ The slapos team
class TestSlapOSRegularisationRequest_invalidateIfPersonBalanceIsOk(
testSlapOSMixin):
abort_transaction = 1
SlapOSTestCaseMixinWithAbort):
def createRegularisationRequest(self):
new_id = self.generateNewId()
......@@ -554,9 +548,7 @@ class TestSlapOSRegularisationRequest_invalidateIfPersonBalanceIsOk(
ticket.RegularisationRequest_invalidateIfPersonBalanceIsOk()
self.assertEquals(ticket.getSimulationState(), 'suspended')
class TestSlapOSRegularisationRequest_checkToSendUniqEvent(testSlapOSMixin):
abort_transaction = 1
class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
def createRegularisationRequest(self):
new_id = self.generateNewId()
......@@ -686,9 +678,7 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(testSlapOSMixin):
REQUEST={})
class TestSlapOSRegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty(
testSlapOSMixin):
abort_transaction = 1
SlapOSTestCaseMixinWithAbort):
def createRegularisationRequest(self):
new_id = self.generateNewId()
......@@ -915,9 +905,7 @@ The slapos team
self.assertEqual(invoice_list, [])
class TestSlapOSRegularisationRequest_checkToTriggerNextEscalationStep(
testSlapOSMixin):
abort_transaction = 1
SlapOSTestCaseMixinWithAbort):
def createRegularisationRequest(self):
new_id = self.generateNewId()
......@@ -1112,18 +1100,7 @@ class TestSlapOSRegularisationRequest_checkToTriggerNextEscalationStep(
REQUEST={})
class TestSlapOSRegularisationRequest_triggerAcknowledgmentEscalation(
testSlapOSMixin):
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',
)
SlapOSTestCaseMixinWithAbort):
def test_triggerAcknowledgmentEscalation_REQUEST_disallowed(self):
ticket = self.createRegularisationRequest()
......@@ -1197,18 +1174,7 @@ The slapos team
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSRegularisationRequest_triggerStopReminderEscalation(
testSlapOSMixin):
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',
)
SlapOSTestCaseMixinWithAbort):
def test_triggerStopReminderEscalation_REQUEST_disallowed(self):
ticket = self.createRegularisationRequest()
......@@ -1282,18 +1248,7 @@ The slapos team
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSRegularisationRequest_triggerStopAcknowledgmentEscalation(
testSlapOSMixin):
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',
)
SlapOSTestCaseMixinWithAbort):
def test_triggerStopAcknowledgmentEscalation_REQUEST_disallowed(self):
ticket = self.createRegularisationRequest()
......@@ -1367,18 +1322,7 @@ The slapos team
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSRegularisationRequest_triggerDeleteReminderEscalation(
testSlapOSMixin):
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',
)
SlapOSTestCaseMixinWithAbort):
def test_triggerDeleteReminderEscalation_REQUEST_disallowed(self):
ticket = self.createRegularisationRequest()
......@@ -1452,18 +1396,7 @@ The slapos team
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSRegularisationRequest_stopHostingSubscriptionList(
testSlapOSMixin):
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',
)
SlapOSTestCaseMixinWithAbort):
def createHostingSubscription(self):
new_id = self.generateNewId()
......@@ -1638,9 +1571,7 @@ class TestSlapOSRegularisationRequest_stopHostingSubscriptionList(
self.tic()
class TestSlapOSHostingSubscription_stopFromRegularisationRequest(
testSlapOSMixin):
abort_transaction = 1
SlapOSTestCaseMixinWithAbort):
def createHostingSubscription(self):
new_id = self.generateNewId()
......@@ -1711,9 +1642,7 @@ class TestSlapOSHostingSubscription_stopFromRegularisationRequest(
'foobar')
class TestSlapOSHostingSubscription_deleteFromRegularisationRequest(
testSlapOSMixin):
abort_transaction = 1
SlapOSTestCaseMixinWithAbort):
def createHostingSubscription(self):
new_id = self.generateNewId()
......@@ -1814,9 +1743,7 @@ class TestSlapOSHostingSubscription_deleteFromRegularisationRequest(
'foobar')
class TestSlapOSRegularisationRequest_deleteHostingSubscriptionList(
testSlapOSMixin):
abort_transaction = 1
SlapOSTestCaseMixinWithAbort):
def createRegularisationRequest(self):
new_id = self.generateNewId()
......@@ -1970,11 +1897,11 @@ class TestSlapOSRegularisationRequest_deleteHostingSubscriptionList(
class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin):
def afterSetUp(self):
super(TestSlapOSComputer_notifyWrongAllocationScope, self).afterSetUp()
TestCRMSkinsMixin.afterSetUp(self)
self._cancelTestSupportRequestList(title="%%TESTCOMPT-%")
def _makeComputer(self):
super(TestSlapOSComputer_notifyWrongAllocationScope, self)._makeComputer()
TestCRMSkinsMixin._makeComputer(self)
# Clone computer document
self.computer.edit(
......@@ -2142,12 +2069,10 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin):
self.assertEquals(computer.getAllocationScope(), 'open/friend')
class TestComputer_hasContactedRecently(testSlapOSMixin):
abort_transaction = 1
class TestComputer_hasContactedRecently(SlapOSTestCaseMixinWithAbort):
def _makeComputer(self):
super(TestComputer_hasContactedRecently, self)._makeComputer()
SlapOSTestCaseMixinWithAbort._makeComputer(self)
return self.computer
def createSPL(self, computer):
......@@ -2239,7 +2164,7 @@ class TestComputer_hasContactedRecently(testSlapOSMixin):
has_contacted = computer.Computer_hasContactedRecently()
self.assertFalse(has_contacted)
class TestSlapOSPerson_isServiceProvider(testSlapOSMixin):
class TestSlapOSPerson_isServiceProvider(SlapOSTestCaseMixin):
abort_transaction = 1
......@@ -2268,7 +2193,7 @@ class TestSlapOSPerson_isServiceProvider(testSlapOSMixin):
class TestSlapOSisSupportRequestCreationClosed(TestCRMSkinsMixin):
def afterSetUp(self):
super(TestSlapOSisSupportRequestCreationClosed, self).afterSetUp()
TestCRMSkinsMixin.afterSetUp(self)
self._cancelTestSupportRequestList()
def test_ERP5Site_isSupportRequestCreationClosed(self):
......@@ -2354,7 +2279,7 @@ class TestSlapOSisSupportRequestCreationClosed(TestCRMSkinsMixin):
class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin):
def afterSetUp(self):
super(TestSlapOSGenerateSupportRequestForSlapOS, self).afterSetUp()
TestCRMSkinsMixin.afterSetUp(self)
self.tic()
self._cancelTestSupportRequestList()
......@@ -2390,8 +2315,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin):
hosting_subscription.requestInstance(**kw)
def _makeComputer(self):
super(TestSlapOSGenerateSupportRequestForSlapOS, self)._makeComputer()
SlapOSTestCaseMixin._makeComputer(self)
# Clone computer document
self.computer.edit(
source_administration_value=self.makePerson(user=0)
......@@ -2597,7 +2521,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin):
transaction.abort()
def afterSetUp(self):
super(TestSlapOSComputer_CheckState, self).afterSetUp()
TestCRMSkinsMixin.afterSetUp(self)
self._cancelTestSupportRequestList("% TESTCOMPT-%")
def _makeSupportRequest(self):
......@@ -2627,7 +2551,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin):
return support_request
def _makeComputer(self):
super(TestSlapOSComputer_CheckState, self)._makeComputer()
TestCRMSkinsMixin._makeComputer(self)
# Clone computer document
self.computer.edit(
......@@ -2770,7 +2694,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin):
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSHostingSubscription_createSupportRequestEvent(testSlapOSMixin):
class TestSlapOSHostingSubscription_createSupportRequestEvent(SlapOSTestCaseMixin):
def _makeNotificationMessage(self, reference):
notification_message = self.portal.notification_message_module.newContent(
......@@ -2869,7 +2793,7 @@ class TestSlapOSHostingSubscription_createSupportRequestEvent(testSlapOSMixin):
hosting_subscription.HostingSubscription_createSupportRequestEvent(
hosting_subscription, "test-slapos-crm-check.notification"))
class TestSlapOSHasError(testSlapOSMixin):
class TestSlapOSHasError(SlapOSTestCaseMixin):
def _makeSoftwareRelease(self, software_release_url=None):
software_release = self.portal.software_release_module\
......@@ -3154,11 +3078,10 @@ class TestSlapOSHasError(testSlapOSMixin):
None,
hosting_subscription.HostingSubscription_checkSoftwareInstanceState())
class TestSupportRequestTrySendNotificationMessage(testSlapOSMixin):
class TestSupportRequestTrySendNotificationMessage(SlapOSTestCaseMixin):
def _makeComputer(self):
super(TestSupportRequestTrySendNotificationMessage, self)._makeComputer()
SlapOSTestCaseMixin._makeComputer(self)
# Clone computer document
self.computer.edit(
source_administration_value=self.makePerson(user=0)
......@@ -3250,11 +3173,10 @@ class TestSupportRequestTrySendNotificationMessage(testSlapOSMixin):
another_support_request.getRelativeUrl())
class TestSupportRequestUpdateMonitoringState(testSlapOSMixin):
class TestSupportRequestUpdateMonitoringState(SlapOSTestCaseMixin):
def _makeComputer(self):
super(TestSupportRequestUpdateMonitoringState, self)._makeComputer()
SlapOSTestCaseMixin._makeComputer(self)
# Clone computer document
self.computer.edit(
source_administration_value=self.makePerson(user=0)
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
import transaction
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from Products.ERP5Type.tests.utils import createZODBPythonScript
from unittest import skip
import json
from DateTime import DateTime
from zExceptions import Unauthorized
class TestSlapOSERP5CleanupActiveProcess(testSlapOSMixin):
def beforeTearDown(self):
transaction.abort()
class TestSlapOSERP5CleanupActiveProcess(SlapOSTestCaseMixinWithAbort):
def _simulateActiveProcess_deleteSelf(self):
script_name = 'ActiveProcess_deleteSelf'
......@@ -69,10 +64,7 @@ context.edit(description=description)""")
self.check_cleanup_active_process_alarm(DateTime() - 20, self.assertFalse)
class TestSlapOSERP5ActiveProcess_deleteSelf(testSlapOSMixin):
def beforeTearDown(self):
transaction.abort()
class TestSlapOSERP5ActiveProcess_deleteSelf(SlapOSTestCaseMixinWithAbort):
def createActiveProcess(self):
new_id = self.generateNewId()
......@@ -100,9 +92,9 @@ class TestSlapOSERP5ActiveProcess_deleteSelf(testSlapOSMixin):
def test_default_use_case(self):
active_process = self.createActiveProcess()
module = active_process.getParentValue()
id = active_process.getId()
ac_id = active_process.getId()
active_process.ActiveProcess_deleteSelf()
self.assertRaises(
KeyError,
module._getOb,
id)
ac_id)
......@@ -6,10 +6,22 @@
</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>testSlapOSERP5Alarm</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSERP5Alarm</string> </value>
......@@ -33,11 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<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>
<tuple/>
</value>
</item>
<item>
......@@ -47,13 +55,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<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>
......@@ -66,7 +89,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -75,7 +98,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......
......@@ -6,7 +6,7 @@
##############################################################################
from erp5.component.test.testSlapOSCloudSecurityGroup import TestSlapOSSecurityMixin
from Products.SlapOS.tests.testSlapOSMixin import changeSkin
from erp5.component.test.SlapOSTestCaseMixin import changeSkin
import re
import xml_marshaller
from AccessControl.SecurityManagement import getSecurityManager, \
......
# 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
class TestSlapOSGroupRoleSecurityMixin(testSlapOSMixin):
abort_transaction = 1
class TestSlapOSGroupRoleSecurityMixin(SlapOSTestCaseMixinWithAbort):
def afterSetUp(self):
super(TestSlapOSGroupRoleSecurityMixin, self).afterSetUp()
SlapOSTestCaseMixinWithAbort.afterSetUp(self)
self.user_id = getSecurityManager().getUser().getId()
def changeOwnership(self, document):
......@@ -16,10 +15,6 @@ class TestSlapOSGroupRoleSecurityMixin(testSlapOSMixin):
document.changeOwnership(getSecurityManager().getUser(), False)
document.updateLocalRolesOnSecurityGroups()
def generateNewId(self):
return self.getPortalObject().portal_ids.generateNewId(
id_group=('slapos_core_test'))
def _getLocalRoles(self, context):
return [x[0] for x in context.get_local_roles()]
......
......@@ -5,12 +5,12 @@
#
##############################################################################
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import os
from Testing import ZopeTestCase
class TestSlapOSDump(testSlapOSMixin):
class TestSlapOSDump(SlapOSTestCaseMixin):
def write(self, name, output):
path = os.path.join(os.environ['INSTANCE_HOME'], name)
with open(path, 'w') as f:
......
......@@ -6,10 +6,22 @@
</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>testSlapOSERP5SiteDump</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSERP5SiteDump</string> </value>
......@@ -43,13 +55,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<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>
......@@ -62,7 +89,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -71,7 +98,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......
......@@ -27,12 +27,10 @@
#
##############################################################################
import unittest
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import difflib
class TestSlaposSkinSelection(testSlapOSMixin):
class TestSlaposSkinSelection(SlapOSTestCaseMixin):
run_all_test = 1
def getTitle(self):
......
......@@ -4,17 +4,16 @@
import unittest
from Products.ERP5.tests import testXHTML
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
class TestSlapOSXHTML(testSlapOSMixin, testXHTML.TestXHTML):
class TestSlapOSXHTML(SlapOSTestCaseMixin, testXHTML.TestXHTML):
# some forms have intentionally empty listbox selections like RSS generators
JSL_IGNORE_SKIN_LIST = ('erp5_ace_editor', 'erp5_code_mirror', 'erp5_ckeditor',
'erp5_fckeditor', 'erp5_jquery', 'erp5_jquery_ui',
'erp5_svg_editor', 'erp5_xinha_editor', 'erp5_web_renderjs')
def afterSetUp(self):
testSlapOSMixin.afterSetUp(self)
SlapOSTestCaseMixin.afterSetUp(self)
# Live tests all uses the same request. For now we remove cell from
# previous test that can cause problems in this test.
self.portal.REQUEST.other.pop('cell', None)
......
# -*- coding: utf-8 -*-
# Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import json
import httplib
import urlparse
......@@ -25,7 +25,7 @@ def getRelativeUrlFromUrn(urn):
return
return url
class TestSlapOSHypermediaPersonScenario(testSlapOSMixin):
class TestSlapOSHypermediaPersonScenario(SlapOSTestCaseMixin):
def _makeUser(self):
person_user = self.makePerson()
......@@ -386,10 +386,7 @@ class TestSlapOSHypermediaPersonScenario(testSlapOSMixin):
software_hal = json.loads(response.read())
class TestSlapOSHypermediaInstanceScenario(testSlapOSMixin):
def generateNewId(self):
return "%s" % self.portal.portal_ids.generateNewId(
id_group=('slapos_core_test'))
class TestSlapOSHypermediaInstanceScenario(SlapOSTestCaseMixin):
def generateNewSoftwareReleaseUrl(self):
return 'http://example.org/test%s.cfg' % self.generateNewId()
......
......@@ -47,14 +47,14 @@
<value>
<tuple>
<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:290, 4: Unused variable \'news_hal\' (unused-variable)</string>
<string>W: 60, 8: Unused variable \'api_fragment\' (unused-variable)</string>
<string>W: 59, 38: Unused variable \'api_query\' (unused-variable)</string>
<string>W:395, 4: Unused variable \'software_hal\' (unused-variable)</string>
<string>W:422, 28: Unused variable \'api_path\' (unused-variable)</string>
<string>W:422, 38: Unused variable \'api_query\' (unused-variable)</string>
<string>W:423, 8: Unused variable \'api_fragment\' (unused-variable)</string>
<string>W: 50, 28: Unused variable \'api_path\' (unused-variable)</string>
<string>W:281, 4: Unused variable \'news_hal\' (unused-variable)</string>
<string>W: 51, 8: Unused variable \'api_fragment\' (unused-variable)</string>
<string>W: 50, 38: Unused variable \'api_query\' (unused-variable)</string>
<string>W:386, 4: Unused variable \'software_hal\' (unused-variable)</string>
<string>W:412, 28: Unused variable \'api_path\' (unused-variable)</string>
<string>W:412, 38: Unused variable \'api_query\' (unused-variable)</string>
<string>W:413, 8: Unused variable \'api_fragment\' (unused-variable)</string>
</tuple>
</value>
</item>
......
# -*- coding: utf-8 -*-
# Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin, changeSkin, simulate
from erp5.component.test.SlapOSTestCaseMixin import \
SlapOSTestCaseMixinWithAbort, changeSkin, simulate
from zExceptions import Unauthorized
from unittest import skip
......@@ -132,14 +132,11 @@ class TestBase_handleAcceptHeader(ERP5HALJSONStyleSkinsMixin):
)
class TestSlapOSHypermediaMixin(testSlapOSMixin):
class TestSlapOSHypermediaMixin(SlapOSTestCaseMixinWithAbort):
def afterSetUp(self):
testSlapOSMixin.afterSetUp(self)
SlapOSTestCaseMixinWithAbort.afterSetUp(self)
self.changeSkin('Hal')
def beforeTearDown(self):
transaction.abort()
def _makePerson(self):
person_user = self.makePerson()
self.tic()
......@@ -238,7 +235,6 @@ class TestSlapOSPersonERP5Document_getHateoas(TestSlapOSHypermediaMixin):
u'title': u'getHateoasInformation'
},
]:
self.assertTrue(action in action_object_slap, \
"%s not in %s" % (action, action_object_slap))
self.assertEquals(results['_links']['action_object_slap_post'], {
......
......@@ -46,7 +46,7 @@
<key> <string>text_content_warning_message</string> </key>
<value>
<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>
</value>
</item>
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from Products.ERP5Type.tests.utils import createZODBPythonScript
from DateTime import DateTime
class TestSlapOSPayzenUpdateConfirmedPayment(testSlapOSMixin):
abort_transaction = 1
class TestSlapOSPayzenUpdateConfirmedPayment(SlapOSTestCaseMixinWithAbort):
def _simulatePaymentTransaction_startPayzenPayment(self):
script_name = 'PaymentTransaction_startPayzenPayment'
......@@ -215,10 +212,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P
self.assertEquals(transaction.getSimulationState(), 'started')
class TestSlapOSPayzenUpdateStartedPayment(testSlapOSMixin):
def beforeTearDown(self):
self.abort()
class TestSlapOSPayzenUpdateStartedPayment(SlapOSTestCaseMixinWithAbort):
def test_not_started_payment(self):
new_id = self.generateNewId()
......
......@@ -5,10 +5,9 @@
#
##############################################################################
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
class TestSlapOSPaymentTransactionOrderBuilder(testSlapOSMixin):
class TestSlapOSPaymentTransactionOrderBuilder(SlapOSTestCaseMixin):
def sumReceivable(self, payment_transaction):
quantity = .0
default_source_uid = self.portal.restrictedTraverse(
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from DateTime import DateTime
from zExceptions import Unauthorized
from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestSlapOSCurrency_getIntegrationMapping(testSlapOSMixin):
abort_transaction = 1
class TestSlapOSCurrency_getIntegrationMapping(SlapOSTestCaseMixinWithAbort):
def test_integratedCurrency(self):
currency = self.portal.currency_module.EUR
......@@ -25,9 +23,7 @@ class TestSlapOSCurrency_getIntegrationMapping(testSlapOSMixin):
currency.Currency_getIntegrationMapping)
class TestSlapOSAccountingTransaction_updateStartDate(testSlapOSMixin):
abort_transaction = 1
class TestSlapOSAccountingTransaction_updateStartDate(SlapOSTestCaseMixinWithAbort):
def createPaymentTransaction(self):
new_id = self.generateNewId()
......@@ -52,17 +48,7 @@ class TestSlapOSAccountingTransaction_updateStartDate(testSlapOSMixin):
date, REQUEST={})
class TestSlapOSPaymentTransaction_getPayzenId(testSlapOSMixin):
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,
)
class TestSlapOSPaymentTransaction_getPayzenId(SlapOSTestCaseMixinWithAbort):
def test_getPayzenId_newPaymentTransaction(self):
payment_transaction = self.createPaymentTransaction()
......@@ -102,17 +88,7 @@ class TestSlapOSPaymentTransaction_getPayzenId(testSlapOSMixin):
REQUEST={})
class TestSlapOSPaymentTransaction_generatePayzenId(testSlapOSMixin):
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,
)
class TestSlapOSPaymentTransaction_generatePayzenId(SlapOSTestCaseMixinWithAbort):
def test_generatePayzenId_newPaymentTransaction(self):
payment_transaction = self.createPaymentTransaction()
......@@ -172,17 +148,7 @@ class TestSlapOSPaymentTransaction_generatePayzenId(testSlapOSMixin):
REQUEST={})
class TestSlapOSPaymentTransaction_createPayzenEvent(testSlapOSMixin):
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,
)
class TestSlapOSPaymentTransaction_createPayzenEvent(SlapOSTestCaseMixinWithAbort):
def test_createPayzenEvent_REQUEST_disallowed(self):
payment_transaction = self.createPaymentTransaction()
......@@ -210,22 +176,7 @@ class TestSlapOSPaymentTransaction_createPayzenEvent(testSlapOSMixin):
self.assertEquals(payzen_event.getTitle(), "foo")
class TestSlapOSPayzenEvent_processUpdate(testSlapOSMixin):
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())
class TestSlapOSPayzenEvent_processUpdate(SlapOSTestCaseMixinWithAbort):
def test_processUpdate_REQUEST_disallowed(self):
event = self.createPayzenEvent()
......@@ -578,9 +529,7 @@ return addToDate(DateTime(), to_add={'day': -1, 'second': -1}).toZone('UTC'), 'f
'Aborting refused payzen payment.',
payment.workflow_history['accounting_workflow'][-1]['comment'])
class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(testSlapOSMixin):
abort_transaction = 1
class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(SlapOSTestCaseMixinWithAbort):
def test_getPayzenServiceRelativeUrl_REQUEST_disallowed(self):
self.assertRaises(
......@@ -592,47 +541,28 @@ class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(testSlapOSMixin):
result = self.portal.Base_getPayzenServiceRelativeUrl()
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(
portal_type="Payment Transaction",
payment_mode="payzen",
causality_value=invoice,
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
return invoice
class TestSlapOSPayzenSaleInvoiceTransaction_getPayzenPaymentRelatedValue(
SlapOSTestCaseMixinWithAbort):
def test_SaleInvoiceTransaction_getPayzenPaymentRelatedValue(self):
invoice = self.createPayzenSaleInvoiceTransaction()
self.tic()
payment = invoice.SaleInvoiceTransaction_getPayzenPaymentRelatedValue()
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):
self.assertRaises(
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from DateTime import DateTime
from Products.ERP5Type.tests.utils import createZODBPythonScript
......@@ -15,22 +14,7 @@ vads_url_refused = 'http://example.org/refused'
vads_url_success = 'http://example.org/success'
vads_url_return = 'http://example.org/return'
class TestSlapOSPayzenInterfaceWorkflow(testSlapOSMixin):
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())
class TestSlapOSPayzenInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
def _simulatePaymentTransaction_getTotalPayablePrice(self):
script_name = 'PaymentTransaction_getTotalPayablePrice'
......
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestSlapOSUpgradeDecisionProcess(testSlapOSMixin):
class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin):
def afterSetUp(self):
super(TestSlapOSUpgradeDecisionProcess, self).afterSetUp()
SlapOSTestCaseMixin.afterSetUp(self)
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):
upgrade_decision = self.portal.\
upgrade_decision_module.newContent(
......
......@@ -6,10 +6,22 @@
</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>testSlapOSPDMAlarm</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSPDMAlarm</string> </value>
......@@ -33,10 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<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>
<tuple/>
</value>
</item>
<item>
......@@ -46,13 +55,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<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>
......@@ -65,7 +89,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -74,7 +98,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......
......@@ -26,14 +26,13 @@
#
##############################################################################
import transaction
from Products.SlapOS.tests.testSlapOSMixin import testSlapOSMixin, simulate
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin, simulate
from DateTime import DateTime
class TestSlapOSPDMSkins(testSlapOSMixin):
class TestSlapOSPDMSkins(SlapOSTestCaseMixin):
def afterSetUp(self):
super(TestSlapOSPDMSkins, self).afterSetUp()
SlapOSTestCaseMixin.afterSetUp(self)
self.new_id = self.generateNewId()
self.request_kw = dict(
software_title=self.generateNewSoftwareTitle(),
......@@ -52,11 +51,6 @@ class TestSlapOSPDMSkins(testSlapOSMixin):
self.portal.upgrade_decision_module.manage_delObjects(id_list)
self.tic()
def generateNewId(self):
return "%sTEST" % self.portal.portal_ids.generateNewId(
id_group=('slapos_core_test'))
def _makePerson(self):
person_user = self.makePerson(new_id=self.new_id)
return person_user
......@@ -234,7 +228,6 @@ class TestSlapOSPDMSkins(testSlapOSMixin):
portal_type="Upgrade Decision Line",
title="TESTUPDE-%s" % self.new_id)
def test_getSortedSoftwareReleaseListFromSoftwareProduct(self):
software_product = self._makeSoftwareProduct()
release_list = software_product.SoftwareProduct_getSortedSoftwareReleaseList(
......@@ -266,7 +259,6 @@ class TestSlapOSPDMSkins(testSlapOSMixin):
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])
def test_getSortedSoftwareReleaseListFromSoftwareProduct_Changed(self):
software_product = self._makeSoftwareProduct()
release_list = software_product.SoftwareProduct_getSortedSoftwareReleaseList(
......
......@@ -45,10 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<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>
<tuple/>
</value>
</item>
<item>
......
# -*- coding: utf-8 -*-
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
from DateTime import DateTime
from App.Common import rfc1123_date
......@@ -34,24 +33,22 @@ class Simulator:
'reckwargs': kwargs})
open(self.outfile, 'w').write(repr(l))
class TestSlapOSSlapToolMixin(testSlapOSMixin):
def afterSetUp(self, person=None):
testSlapOSMixin.afterSetUp(self)
class TestSlapOSSlapToolMixin(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
self.portal_slap = self.portal.portal_slap
new_id = self.generateNewId()
# Prepare computer
self.computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1)
self.computer.edit(
title="Computer %s" % new_id,
reference="TESTCOMP-%s" % new_id
title="Computer %s" % self.new_id,
reference="TESTCOMP-%s" % self.new_id
)
if (person is not None):
if getattr(self, "person", None) is not None:
self.computer.edit(
source_administration_value=person,
source_administration_value=getattr(self, "person", None),
)
self.computer.validate()
self._addERP5Login(self.computer)
......@@ -2145,7 +2142,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
self.person = person
self.person_reference = person.getReference()
self.person_user_id = person.getUserId()
TestSlapOSSlapToolMixin.afterSetUp(self, person=person)
TestSlapOSSlapToolMixin.afterSetUp(self)
def test_not_accessed_getComputerStatus(self):
self.login(self.person_user_id)
......
......@@ -46,24 +46,22 @@
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 29, 10: Use of eval (eval-used)</string>
<string>W: 38, 2: Arguments number differs from overridden \'afterSetUp\' method (arguments-differ)</string>
<string>W:519, 13: Use of eval (eval-used)</string>
<string>W:570, 13: Use of eval (eval-used)</string>
<string>W:795, 13: Use of eval (eval-used)</string>
<string>W:1403, 13: Use of eval (eval-used)</string>
<string>W:1516, 13: Use of eval (eval-used)</string>
<string>W:1570, 13: Use of eval (eval-used)</string>
<string>W:1610, 13: Use of eval (eval-used)</string>
<string>W:2134, 2: Arguments number differs from overridden \'afterSetUp\' method (arguments-differ)</string>
<string>W:2231, 13: Use of eval (eval-used)</string>
<string>W:2616, 13: Use of eval (eval-used)</string>
<string>W:2670, 13: Use of eval (eval-used)</string>
<string>W:2697, 13: Use of eval (eval-used)</string>
<string>W:2852, 13: Use of eval (eval-used)</string>
<string>W:2880, 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>
<string>W: 28, 10: Use of eval (eval-used)</string>
<string>W:516, 13: Use of eval (eval-used)</string>
<string>W:567, 13: Use of eval (eval-used)</string>
<string>W:792, 13: Use of eval (eval-used)</string>
<string>W:1400, 13: Use of eval (eval-used)</string>
<string>W:1513, 13: Use of eval (eval-used)</string>
<string>W:1567, 13: Use of eval (eval-used)</string>
<string>W:1607, 13: Use of eval (eval-used)</string>
<string>W:2229, 13: Use of eval (eval-used)</string>
<string>W:2614, 13: Use of eval (eval-used)</string>
<string>W:2668, 13: Use of eval (eval-used)</string>
<string>W:2695, 13: Use of eval (eval-used)</string>
<string>W:2850, 13: Use of eval (eval-used)</string>
<string>W:2878, 13: Use of eval (eval-used)</string>
<string>W:2927, 13: Use of eval (eval-used)</string>
<string>W:2974, 13: Use of eval (eval-used)</string>
</tuple>
</value>
</item>
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
import transaction
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
class TestSlapOSCoreComputerUpdateFromDict(testSlapOSMixin):
class TestSlapOSCoreComputerUpdateFromDict(SlapOSTestCaseMixinWithAbort):
def afterSetUp(self):
super(TestSlapOSCoreComputerUpdateFromDict, self).afterSetUp()
SlapOSTestCaseMixinWithAbort.afterSetUp(self)
self.computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1)
self.computer.edit(
......@@ -23,9 +21,6 @@ class TestSlapOSCoreComputerUpdateFromDict(testSlapOSMixin):
portal_type='Computer Partition')
self.assertEqual(len(partition_list), 0)
def beforeTearDown(self):
transaction.abort()
#############################################
# Computer network information
#############################################
......@@ -420,7 +415,7 @@ class TestSlapOSCoreComputerUpdateFromDict(testSlapOSMixin):
id ='foo',
portal_type='Internet Protocol Address',
)
other_address2 = partition.newContent(
partition.newContent(
id ='route_foo',
portal_type='Internet Protocol Address',
)
......@@ -553,11 +548,11 @@ class TestSlapOSCoreComputerUpdateFromDict(testSlapOSMixin):
address_list = partition.contentValues(
portal_type='Internet Protocol Address')
self.assertEqual(len(address_list), 0)
other_address = partition.newContent(
partition.newContent(
id ='foo',
portal_type='Internet Protocol Address',
)
default_address = partition.newContent(
partition.newContent(
id ='default_network_interface',
portal_type='Internet Protocol Address',
)
......@@ -594,11 +589,11 @@ class TestSlapOSCoreComputerUpdateFromDict(testSlapOSMixin):
address_list = partition.contentValues(
portal_type='Internet Protocol Address')
self.assertEqual(len(address_list), 0)
other_address = partition.newContent(
partition.newContent(
id ='foo',
portal_type='Internet Protocol Address',
)
default_address = partition.newContent(
partition.newContent(
id ='default_network_interface',
portal_type='Internet Protocol Address',
)
......
......@@ -45,13 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<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>
<tuple/>
</value>
</item>
<item>
......
......@@ -30,62 +30,16 @@ import random
import transaction
import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
import functools
from Products.ERP5Type.tests.utils import DummyMailHost
from Products.ERP5Type.Utils import convertToUpperCase
import os
import glob
from functools import wraps
from Products.ERP5Type.tests.utils import createZODBPythonScript
from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager
from App.config import 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):
abort_transaction = 0
......@@ -183,9 +137,6 @@ class testSlapOSMixin(ERP5TypeTestCase):
self.login()
self.createAlarmStep()
# Helpfull for the tests
self.new_id = self.generateNewId()
if self.isLiveTest():
self.setUpPersistentDummyMailHost()
return
......@@ -267,385 +218,6 @@ class testSlapOSMixin(ERP5TypeTestCase):
]
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):
run_all_test = 1
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