Commit 7b5d49a0 authored by Rafael Monnerat's avatar Rafael Monnerat

Python3 Preparations (again)

See merge request !620
parents 97a0dd7a a27ea9c0
...@@ -44,7 +44,7 @@ length = context.getArrayShape()[0] ...@@ -44,7 +44,7 @@ length = context.getArrayShape()[0]
# never access more than 1000 lines at once # never access more than 1000 lines at once
list_lines = min(list_lines, limit, 1000) list_lines = min(list_lines, limit, 1000)
if context.REQUEST.has_key("limit"): if "limit" in context.REQUEST:
list_start = limit[0] list_start = limit[0]
list_lines = limit[1] - limit[0] list_lines = limit[1] - limit[0]
......
...@@ -228,7 +228,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -228,7 +228,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
self.tic() self.tic()
data_array = self._getRelatedDataArrayList(database_debian11)[0] data_array = self._getRelatedDataArrayList(database_debian11)[0]
# /home/test3/metadata-collect-agent/scan-filesystem/cython/command-line.main.pyx, /home/test3/metadata-collect-agent/scan-filesystem/cython/test.main.pyx # /home/test3/metadata-collect-agent/scan-filesystem/cython/command-line.main.pyx, /home/test3/metadata-collect-agent/scan-filesystem/cython/test.main.pyx
self.assertEquals(len(data_array.getArray()), 2) self.assertEqual(len(data_array.getArray()), 2)
database_debian11.edit(exclude_path_list=['/home/test3/metadata-collect-agent/scan-filesystem/cython']) database_debian11.edit(exclude_path_list=['/home/test3/metadata-collect-agent/scan-filesystem/cython'])
self.tic() self.tic()
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
...@@ -247,7 +247,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -247,7 +247,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
if 'file_system_image/process_state/converted' in new_array.getPublicationSectionList(): if 'file_system_image/process_state/converted' in new_array.getPublicationSectionList():
break break
self.assertIn('file_system_image/process_state/converted', new_array.getPublicationSectionList()) self.assertIn('file_system_image/process_state/converted', new_array.getPublicationSectionList())
self.assertEquals(len(new_array.getArray()), 0) self.assertEqual(len(new_array.getArray()), 0)
def test_data_processing_for_the_first_access(self): def test_data_processing_for_the_first_access(self):
......
...@@ -7,7 +7,7 @@ from DateTime import DateTime ...@@ -7,7 +7,7 @@ from DateTime import DateTime
portal = context.getPortalObject() portal = context.getPortalObject()
if related_simulation_movement_path_list is None: if related_simulation_movement_path_list is None:
raise RuntimeError, 'related_simulation_movement_path_list is missing. Update ERP5 Product.' raise RuntimeError('related_simulation_movement_path_list is missing. Update ERP5 Product.')
invoice = context invoice = context
price_currency = invoice.getPriceCurrency() price_currency = invoice.getPriceCurrency()
......
if related_simulation_movement_path_list is None: if related_simulation_movement_path_list is None:
raise RuntimeError, 'related_simulation_movement_path_list is missing. Update ERP5 Product.' raise RuntimeError('related_simulation_movement_path_list is missing. Update ERP5 Product.')
packing_list = context packing_list = context
......
...@@ -40,8 +40,8 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -40,8 +40,8 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
self.assertTrue(owner_person.Entity_hasOutstandingAmount(include_planned=True)) self.assertTrue(owner_person.Entity_hasOutstandingAmount(include_planned=True))
amount_list = owner_person.Entity_getOutstandingAmountList(include_planned=True) amount_list = owner_person.Entity_getOutstandingAmountList(include_planned=True)
self.assertEquals(len(amount_list), 1) self.assertEqual(len(amount_list), 1)
self.assertEquals(amount_list[0].total_price, 24.384) self.assertEqual(amount_list[0].total_price, 24.384)
self.assertFalse(owner_person.Entity_hasOutstandingAmount()) self.assertFalse(owner_person.Entity_hasOutstandingAmount())
self.assertEqual(subscription_request.getSimulationState(), "invalidated") self.assertEqual(subscription_request.getSimulationState(), "invalidated")
open_sale_order = self.portal.portal_catalog.getResultValue( open_sale_order = self.portal.portal_catalog.getResultValue(
...@@ -80,12 +80,12 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -80,12 +80,12 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
self.assertTrue(owner_person.Entity_hasOutstandingAmount(include_planned=True)) self.assertTrue(owner_person.Entity_hasOutstandingAmount(include_planned=True))
amount_list = owner_person.Entity_getOutstandingAmountList(include_planned=True) amount_list = owner_person.Entity_getOutstandingAmountList(include_planned=True)
self.assertEquals(len(amount_list), 1) self.assertEqual(len(amount_list), 1)
self.assertEquals(amount_list[0].total_price, 175.584) self.assertEqual(amount_list[0].total_price, 175.584)
self.assertTrue(owner_person.Entity_hasOutstandingAmount()) self.assertTrue(owner_person.Entity_hasOutstandingAmount())
amount_list = owner_person.Entity_getOutstandingAmountList() amount_list = owner_person.Entity_getOutstandingAmountList()
self.assertEquals(len(amount_list), 1) self.assertEqual(len(amount_list), 1)
self.assertEquals(amount_list[0].total_price, 125.184) self.assertEqual(amount_list[0].total_price, 125.184)
self.assertEqual(first_invoice.getSimulationState(), "stopped") self.assertEqual(first_invoice.getSimulationState(), "stopped")
# Ensure no unexpected object has been created # Ensure no unexpected object has been created
# 4 accounting transactions # 4 accounting transactions
...@@ -110,16 +110,16 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -110,16 +110,16 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
) )
) )
payment_transaction.stop() payment_transaction.stop()
self.assertEquals(payment_transaction.AccountingTransaction_getTotalCredit(), 74.78399999999999) self.assertEqual(payment_transaction.AccountingTransaction_getTotalCredit(), 74.78399999999999)
self.tic() self.tic()
self.assertTrue(owner_person.Entity_hasOutstandingAmount(include_planned=True)) self.assertTrue(owner_person.Entity_hasOutstandingAmount(include_planned=True))
amount_list = owner_person.Entity_getOutstandingAmountList(include_planned=True) amount_list = owner_person.Entity_getOutstandingAmountList(include_planned=True)
self.assertEquals(len(amount_list), 1) self.assertEqual(len(amount_list), 1)
self.assertEquals(amount_list[0].total_price, 100.8) self.assertEqual(amount_list[0].total_price, 100.8)
self.assertTrue(owner_person.Entity_hasOutstandingAmount()) self.assertTrue(owner_person.Entity_hasOutstandingAmount())
amount_list = owner_person.Entity_getOutstandingAmountList() amount_list = owner_person.Entity_getOutstandingAmountList()
self.assertEquals(len(amount_list), 1) self.assertEqual(len(amount_list), 1)
self.assertEquals(amount_list[0].total_price, 50.4) self.assertEqual(amount_list[0].total_price, 50.4)
self.assertTrue(first_invoice.SaleInvoiceTransaction_isLettered()) self.assertTrue(first_invoice.SaleInvoiceTransaction_isLettered())
# Ensure no unexpected object has been created # Ensure no unexpected object has been created
self.assertRelatedObjectCount(project, 22) self.assertRelatedObjectCount(project, 22)
...@@ -136,15 +136,15 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -136,15 +136,15 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
) )
) )
payment_transaction.stop() payment_transaction.stop()
self.assertEquals(payment_transaction.AccountingTransaction_getTotalCredit(), 50.4) self.assertEqual(payment_transaction.AccountingTransaction_getTotalCredit(), 50.4)
self.tic() self.tic()
self.assertTrue(owner_person.Entity_hasOutstandingAmount(include_planned=True)) self.assertTrue(owner_person.Entity_hasOutstandingAmount(include_planned=True))
amount_list = owner_person.Entity_getOutstandingAmountList(include_planned=True) amount_list = owner_person.Entity_getOutstandingAmountList(include_planned=True)
self.assertEquals(len(amount_list), 1) self.assertEqual(len(amount_list), 1)
self.assertEquals(amount_list[0].total_price, 50.4) self.assertEqual(amount_list[0].total_price, 50.4)
self.assertFalse(owner_person.Entity_hasOutstandingAmount()) self.assertFalse(owner_person.Entity_hasOutstandingAmount())
amount_list = owner_person.Entity_getOutstandingAmountList() amount_list = owner_person.Entity_getOutstandingAmountList()
self.assertEquals(len(amount_list), 0) self.assertEqual(len(amount_list), 0)
# Ensure no unexpected object has been created # Ensure no unexpected object has been created
self.assertRelatedObjectCount(project, 22) self.assertRelatedObjectCount(project, 22)
...@@ -236,7 +236,7 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -236,7 +236,7 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
self.logout() self.logout()
self.login() self.login()
# Check that no activity has been triggered yet # Check that no activity has been triggered yet
self.assertEquals(self.portal.portal_catalog.countResults( self.assertEqual(self.portal.portal_catalog.countResults(
portal_type='Compute Node', portal_type='Compute Node',
follow_up__uid=project.getUid() follow_up__uid=project.getUid()
)[0][0], 0) )[0][0], 0)
...@@ -246,7 +246,7 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -246,7 +246,7 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
# 1 invoice for the compute node # 1 invoice for the compute node
# per user: # per user:
# 1 monthly invoice for products # 1 monthly invoice for products
self.assertEquals(self.portal.portal_catalog.countResults( self.assertEqual(self.portal.portal_catalog.countResults(
portal_type='Sale Invoice Transaction', portal_type='Sale Invoice Transaction',
source_project__uid=project.getUid() source_project__uid=project.getUid()
)[0][0], 1 + len(person_list)) )[0][0], 1 + len(person_list))
...@@ -271,7 +271,7 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -271,7 +271,7 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
# Execute activities for all services # Execute activities for all services
# To try detection bad activity tag dependencies # To try detection bad activity tag dependencies
self.tic() self.tic()
self.assertEquals(self.portal.portal_catalog.countResults( self.assertEqual(self.portal.portal_catalog.countResults(
portal_type='Sale Invoice Transaction', portal_type='Sale Invoice Transaction',
source_project__uid=project.getUid() source_project__uid=project.getUid()
)[0][0], 1 + len(person_list)) )[0][0], 1 + len(person_list))
...@@ -283,7 +283,7 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -283,7 +283,7 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
self.login() self.login()
self.portal.portal_alarms.update_open_order_simulation.activeSense() self.portal.portal_alarms.update_open_order_simulation.activeSense()
self.tic() self.tic()
self.assertEquals(self.portal.portal_catalog.countResults( self.assertEqual(self.portal.portal_catalog.countResults(
portal_type='Sale Invoice Transaction', portal_type='Sale Invoice Transaction',
source_project__uid=project.getUid() source_project__uid=project.getUid()
)[0][0], (1 + len(person_list)) * 3) )[0][0], (1 + len(person_list)) * 3)
...@@ -327,15 +327,15 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -327,15 +327,15 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
parent_uid=invoice.getUid(), parent_uid=invoice.getUid(),
resource__uid=self.portal.service_module.slapos_tax.getUid() resource__uid=self.portal.service_module.slapos_tax.getUid()
) )
self.assertEquals(tax_line.getPrice(), 0) self.assertEqual(tax_line.getPrice(), 0)
self.assertEquals(invoice.getTotalPrice(), 42) self.assertEqual(invoice.getTotalPrice(), 42)
with PinnedDateTime(self, creation_date + 35): with PinnedDateTime(self, creation_date + 35):
self.portal.portal_alarms.update_open_order_simulation.activeSense() self.portal.portal_alarms.update_open_order_simulation.activeSense()
self.tic() self.tic()
self.assertEquals(invoice.getTotalPrice(), 42) self.assertEqual(invoice.getTotalPrice(), 42)
self.assertEquals(invoice.getSimulationState(), 'stopped') self.assertEqual(invoice.getSimulationState(), 'stopped')
# Ensure no unexpected object has been created # Ensure no unexpected object has been created
# 2 invoice lines # 2 invoice lines
......
...@@ -48,7 +48,7 @@ class SlapOSCatalogToolCacheMixin(object): ...@@ -48,7 +48,7 @@ class SlapOSCatalogToolCacheMixin(object):
validation_state="validated", validation_state="validated",
reference=reference) reference=reference)
if len(compute_node_list) != 1: if len(compute_node_list) != 1:
raise NotFound, "No document found with parameters: %s" % reference raise NotFound("No document found with parameters: %s" % reference)
else: else:
return _assertACI(compute_node_list[0].getObject()).getRelativeUrl() return _assertACI(compute_node_list[0].getObject()).getRelativeUrl()
...@@ -88,7 +88,7 @@ class SlapOSCatalogToolCacheMixin(object): ...@@ -88,7 +88,7 @@ class SlapOSCatalogToolCacheMixin(object):
parent_uid=self._getNonCachedComputeNodeUid( parent_uid=self._getNonCachedComputeNodeUid(
compute_node_reference)) compute_node_reference))
if len(compute_partition_list) != 1: if len(compute_partition_list) != 1:
raise NotFound, "No document found with parameters: %s %s" % \ raise NotFound("No document found with parameters: %s %s" % \
(compute_node_reference, compute_partition_reference) (compute_node_reference, compute_partition_reference))
else: else:
return _assertACI(compute_partition_list[0].getObject()) return _assertACI(compute_partition_list[0].getObject())
...@@ -276,8 +276,8 @@ class SlapOSComputeNodeMixin(object): ...@@ -276,8 +276,8 @@ class SlapOSComputeNodeMixin(object):
software_instance = _assertACI(software_instance_list[0].getObject()) software_instance = _assertACI(software_instance_list[0].getObject())
elif software_instance_count > 1: elif software_instance_count > 1:
# XXX do not prevent the system to work if one partition is broken # XXX do not prevent the system to work if one partition is broken
raise NotImplementedError, "Too many instances linked to %s" % \ raise NotImplementedError("Too many instances linked to %s" % \
compute_partition_document.getRelativeUrl() compute_partition_document.getRelativeUrl())
if software_instance is not None: if software_instance is not None:
state = software_instance.getSlapState() state = software_instance.getSlapState()
...@@ -306,10 +306,10 @@ class SlapOSComputeNodeMixin(object): ...@@ -306,10 +306,10 @@ class SlapOSComputeNodeMixin(object):
parameter_dict.pop('filter_xml')) parameter_dict.pop('filter_xml'))
partition_dict['_instance_guid'] = parameter_dict.pop('instance_guid') partition_dict['_instance_guid'] = parameter_dict.pop('instance_guid')
for slave_instance_dict in parameter_dict.get("slave_instance_list", []): for slave_instance_dict in parameter_dict.get("slave_instance_list", []):
if slave_instance_dict.has_key("connection_xml"): if "connection_xml" in slave_instance_dict:
slave_instance_dict.update(self._instanceXmlToDict( slave_instance_dict.update(self._instanceXmlToDict(
slave_instance_dict.pop("connection_xml"))) slave_instance_dict.pop("connection_xml")))
if slave_instance_dict.has_key("xml"): if "xml" in slave_instance_dict:
slave_instance_dict.update(self._instanceXmlToDict( slave_instance_dict.update(self._instanceXmlToDict(
slave_instance_dict.pop("xml"))) slave_instance_dict.pop("xml")))
partition_dict['_parameter_dict'].update(parameter_dict) partition_dict['_parameter_dict'].update(parameter_dict)
......
...@@ -98,9 +98,9 @@ class SlapOSComputePartitionMixin(object): ...@@ -98,9 +98,9 @@ class SlapOSComputePartitionMixin(object):
software_instance = _assertACI(software_instance_list[0].getObject()) software_instance = _assertACI(software_instance_list[0].getObject())
elif software_instance_count > 1: elif software_instance_count > 1:
# XXX do not prevent the system to work if one partition is broken # XXX do not prevent the system to work if one partition is broken
raise NotImplementedError, "Too many instances %s linked to %s" % \ raise NotImplementedError("Too many instances %s linked to %s" % \
([x.path for x in software_instance_list], ([x.path for x in software_instance_list],
self.getRelativeUrl()) self.getRelativeUrl()))
if software_instance is not None: if software_instance is not None:
state = software_instance.getSlapState() state = software_instance.getSlapState()
...@@ -129,13 +129,13 @@ class SlapOSComputePartitionMixin(object): ...@@ -129,13 +129,13 @@ class SlapOSComputePartitionMixin(object):
parameter_dict.pop('filter_xml')) parameter_dict.pop('filter_xml'))
partition_dict['_instance_guid'] = parameter_dict.pop('instance_guid') partition_dict['_instance_guid'] = parameter_dict.pop('instance_guid')
for slave_instance_dict in parameter_dict.get("slave_instance_list", []): for slave_instance_dict in parameter_dict.get("slave_instance_list", []):
if slave_instance_dict.has_key("connection_xml"): if "connection_xml" in slave_instance_dict:
connection_dict = software_instance._instanceXmlToDict( connection_dict = software_instance._instanceXmlToDict(
slave_instance_dict.pop("connection_xml")) slave_instance_dict.pop("connection_xml"))
slave_instance_dict.update(connection_dict) slave_instance_dict.update(connection_dict)
slave_instance_dict['connection-parameter-hash'] = \ slave_instance_dict['connection-parameter-hash'] = \
calculate_dict_hash(connection_dict) calculate_dict_hash(connection_dict)
if slave_instance_dict.has_key("xml"): if "xml" in slave_instance_dict:
slave_instance_dict.update(software_instance._instanceXmlToDict( slave_instance_dict.update(software_instance._instanceXmlToDict(
slave_instance_dict.pop("xml"))) slave_instance_dict.pop("xml")))
partition_dict['_parameter_dict'].update(parameter_dict) partition_dict['_parameter_dict'].update(parameter_dict)
......
...@@ -126,7 +126,7 @@ try: ...@@ -126,7 +126,7 @@ try:
instance_tree.activate(activity="SQLQueue", tag=tag, instance_tree.activate(activity="SQLQueue", tag=tag,
after_tag="allocate_%s" % compute_partition_url).getId() after_tag="allocate_%s" % compute_partition_url).getId()
except ValueError, e: except ValueError as e:
# It was not possible to find free Compute Partition # It was not possible to find free Compute Partition
markHistory(software_instance, 'Allocation failed: no free Compute Partition %s' % e) markHistory(software_instance, 'Allocation failed: no free Compute Partition %s' % e)
else: else:
......
...@@ -11,8 +11,8 @@ if (instance.getSlapState() != "destroy_requested"): ...@@ -11,8 +11,8 @@ if (instance.getSlapState() != "destroy_requested"):
elif instance.getPortalType() == 'Slave Instance': elif instance.getPortalType() == 'Slave Instance':
is_slave = True is_slave = True
else: else:
raise NotImplementedError, "Unknown portal type %s of %s" % \ raise NotImplementedError("Unknown portal type %s of %s" % \
(instance.getPortalType(), instance.getRelativeUrl()) (instance.getPortalType(), instance.getRelativeUrl()))
if requester is None: if requester is None:
# This instance has no successor (link removed) and should be trashed # This instance has no successor (link removed) and should be trashed
......
...@@ -16,8 +16,8 @@ if (instance_tree.getSlapState() == "stop_requested"): ...@@ -16,8 +16,8 @@ if (instance_tree.getSlapState() == "stop_requested"):
elif instance.getPortalType() == 'Slave Instance': elif instance.getPortalType() == 'Slave Instance':
is_slave = True is_slave = True
else: else:
raise NotImplementedError, "Unknown portal type %s of %s" % \ raise NotImplementedError("Unknown portal type %s of %s" % \
(instance.getPortalType(), instance.getRelativeUrl()) (instance.getPortalType(), instance.getRelativeUrl()))
# Buildout may not propagate the stop request # Buildout may not propagate the stop request
requester = instance.getSuccessorRelatedValue() requester = instance.getSuccessorRelatedValue()
......
...@@ -75,7 +75,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort): ...@@ -75,7 +75,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort):
# check that alarm was called after the object was reindexed # check that alarm was called after the object was reindexed
self.assertTrue(next_indexation_timestamp < edit_timestamp) self.assertTrue(next_indexation_timestamp < edit_timestamp)
self.assertEquals( self.assertEqual(
len(alarm.workflow_history['edit_workflow']), len(alarm.workflow_history['edit_workflow']),
workflow_history_count + 1 workflow_history_count + 1
) )
...@@ -101,11 +101,11 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort): ...@@ -101,11 +101,11 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort):
next_indexation_timestamp = self.getIndexationDate(document) next_indexation_timestamp = self.getIndexationDate(document)
edit_timestamp = alarm.getModificationDate() edit_timestamp = alarm.getModificationDate()
# check that the document was not reindexed # check that the document was not reindexed
self.assertEquals(previous_indexation_timestamp, next_indexation_timestamp) self.assertEqual(previous_indexation_timestamp, next_indexation_timestamp)
# check that alarm was called after the object was reindexed # check that alarm was called after the object was reindexed
self.assertTrue(next_indexation_timestamp < edit_timestamp) self.assertTrue(next_indexation_timestamp < edit_timestamp)
self.assertEquals( self.assertEqual(
len(alarm.workflow_history['edit_workflow']), len(alarm.workflow_history['edit_workflow']),
workflow_history_count + 1 workflow_history_count + 1
) )
...@@ -129,9 +129,9 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort): ...@@ -129,9 +129,9 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort):
next_indexation_timestamp = self.getIndexationDate(document) next_indexation_timestamp = self.getIndexationDate(document)
# check that the document was not reindex # check that the document was not reindex
self.assertEquals(previous_indexation_timestamp, next_indexation_timestamp) self.assertEqual(previous_indexation_timestamp, next_indexation_timestamp)
# check that the alarm was not triggered # check that the alarm was not triggered
self.assertEquals( self.assertEqual(
len(alarm.workflow_history['edit_workflow']), len(alarm.workflow_history['edit_workflow']),
workflow_history_count workflow_history_count
) )
...@@ -157,7 +157,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort): ...@@ -157,7 +157,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort):
# check that alarm was called ONCE after the object was reindexed # check that alarm was called ONCE after the object was reindexed
self.assertTrue(next_indexation_timestamp < edit_timestamp) self.assertTrue(next_indexation_timestamp < edit_timestamp)
self.assertEquals( self.assertEqual(
len(alarm.workflow_history['edit_workflow']), len(alarm.workflow_history['edit_workflow']),
workflow_history_count + 1 workflow_history_count + 1
) )
...@@ -182,7 +182,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort): ...@@ -182,7 +182,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort):
self.tic() self.tic()
# check that alarm was called ONCE # check that alarm was called ONCE
self.assertEquals( self.assertEqual(
len(alarm.workflow_history['edit_workflow']), len(alarm.workflow_history['edit_workflow']),
workflow_history_count + 1 workflow_history_count + 1
) )
...@@ -213,7 +213,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort): ...@@ -213,7 +213,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort):
# check that alarm was called ONCE after the object was reindexed # check that alarm was called ONCE after the object was reindexed
self.assertTrue(next_indexation_timestamp < edit_timestamp) self.assertTrue(next_indexation_timestamp < edit_timestamp)
self.assertEquals( self.assertEqual(
len(alarm.workflow_history['edit_workflow']), len(alarm.workflow_history['edit_workflow']),
workflow_history_count + 1 workflow_history_count + 1
) )
...@@ -241,7 +241,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort): ...@@ -241,7 +241,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort):
with TemporaryAlarmScript(alarm, 'Alarm_allocateInstance'): with TemporaryAlarmScript(alarm, 'Alarm_allocateInstance'):
self.tic() self.tic()
self.assertEquals( self.assertEqual(
len(alarm.workflow_history['edit_workflow']), len(alarm.workflow_history['edit_workflow']),
workflow_history_count + 3 workflow_history_count + 3
) )
...@@ -277,7 +277,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort): ...@@ -277,7 +277,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort):
self.assertTrue(next_indexation_timestamp1 < edit_timestamp) self.assertTrue(next_indexation_timestamp1 < edit_timestamp)
self.assertTrue(next_indexation_timestamp2 < edit_timestamp) self.assertTrue(next_indexation_timestamp2 < edit_timestamp)
self.assertEquals( self.assertEqual(
len(alarm.workflow_history['edit_workflow']), len(alarm.workflow_history['edit_workflow']),
workflow_history_count + 1 workflow_history_count + 1
) )
...@@ -314,7 +314,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort): ...@@ -314,7 +314,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort):
self.assertTrue(next_indexation_timestamp1 < edit_timestamp) self.assertTrue(next_indexation_timestamp1 < edit_timestamp)
self.assertTrue(next_indexation_timestamp2 < edit_timestamp) self.assertTrue(next_indexation_timestamp2 < edit_timestamp)
self.assertEquals( self.assertEqual(
len(alarm.workflow_history['edit_workflow']), len(alarm.workflow_history['edit_workflow']),
workflow_history_count + 1 workflow_history_count + 1
) )
...@@ -349,7 +349,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort): ...@@ -349,7 +349,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort):
self.assertTrue(next_indexation_timestamp < edit_timestamp1) self.assertTrue(next_indexation_timestamp < edit_timestamp1)
self.assertTrue(next_indexation_timestamp < edit_timestamp2) self.assertTrue(next_indexation_timestamp < edit_timestamp2)
self.assertEquals( self.assertEqual(
len(alarm1.workflow_history['edit_workflow']), len(alarm1.workflow_history['edit_workflow']),
workflow_history_count1 + 1 workflow_history_count1 + 1
) )
...@@ -357,7 +357,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort): ...@@ -357,7 +357,7 @@ class TestBase_reindexAndSenseAlarm(SlapOSTestCaseMixinWithAbort):
'Visited by Alarm_allocateInstance', 'Visited by Alarm_allocateInstance',
alarm1.workflow_history['edit_workflow'][-1]['comment'] alarm1.workflow_history['edit_workflow'][-1]['comment']
) )
self.assertEquals( self.assertEqual(
len(alarm2.workflow_history['edit_workflow']), len(alarm2.workflow_history['edit_workflow']),
workflow_history_count2 + 1 workflow_history_count2 + 1
) )
......
...@@ -9,7 +9,7 @@ kwargs = state_change.kwargs ...@@ -9,7 +9,7 @@ kwargs = state_change.kwargs
try: try:
compute_partition_url = kwargs['compute_partition_url'] compute_partition_url = kwargs['compute_partition_url']
except KeyError: except KeyError:
raise TypeError, "RequestedInstance_allocatePartition takes exactly 1 argument" raise TypeError("RequestedInstance_allocatePartition takes exactly 1 argument")
assert instance.getAggregateValue() is None assert instance.getAggregateValue() is None
compute_partition = portal.restrictedTraverse(compute_partition_url) compute_partition = portal.restrictedTraverse(compute_partition_url)
......
...@@ -26,7 +26,7 @@ request_software_instance_list = portal.portal_catalog( ...@@ -26,7 +26,7 @@ request_software_instance_list = portal.portal_catalog(
limit=1, limit=1,
) )
if len(request_software_instance_list) == 1: if len(request_software_instance_list) == 1:
raise ValueError, "Too many instances '%s' found: %s" % (software_title, [x.path for x in request_software_instance_list]) raise ValueError("Too many instances '%s' found: %s" % (software_title, [x.path for x in request_software_instance_list]))
# Change the title # Change the title
previous_title = instance.getTitle() previous_title = instance.getTitle()
......
...@@ -4,7 +4,7 @@ instance = state_change['object'] ...@@ -4,7 +4,7 @@ instance = state_change['object']
try: try:
connection_xml = state_change.kwargs['connection_xml'] connection_xml = state_change.kwargs['connection_xml']
except KeyError: except KeyError:
raise TypeError, "RequestedInstance_updateConnectionInformation takes exactly 1 arguments" raise TypeError("RequestedInstance_updateConnectionInformation takes exactly 1 arguments")
edit_kw = { edit_kw = {
'connection_xml': connection_xml, 'connection_xml': connection_xml,
......
...@@ -11,7 +11,7 @@ try: ...@@ -11,7 +11,7 @@ try:
sla_xml = kwargs["sla_xml"] sla_xml = kwargs["sla_xml"]
is_slave = kwargs["shared"] is_slave = kwargs["shared"]
except KeyError: except KeyError:
raise TypeError, "RequestedInstance_updateParameterInformation takes exactly 5 arguments" raise TypeError("RequestedInstance_updateParameterInformation takes exactly 5 arguments")
edit_kw = { edit_kw = {
'url_string': software_release_url_string, 'url_string': software_release_url_string,
...@@ -22,21 +22,21 @@ edit_kw = { ...@@ -22,21 +22,21 @@ edit_kw = {
# Check the slave management # Check the slave management
if is_slave not in [True, False]: if is_slave not in [True, False]:
raise ValueError, "shared should be a boolean" raise ValueError("shared should be a boolean")
instance_portal_type = instance.getPortalType() instance_portal_type = instance.getPortalType()
if instance_portal_type == "Instance Tree": if instance_portal_type == "Instance Tree":
edit_kw['root_slave'] = is_slave edit_kw['root_slave'] = is_slave
elif instance_portal_type == "Software Instance": elif instance_portal_type == "Software Instance":
if is_slave: if is_slave:
raise NotImplementedError, "Please destroy before doing a slave instance (%s)" % \ raise NotImplementedError("Please destroy before doing a slave instance (%s)" % \
(instance.getRelativeUrl(), ) (instance.getRelativeUrl(), ))
elif instance_portal_type == "Slave Instance": elif instance_portal_type == "Slave Instance":
if not is_slave: if not is_slave:
raise NotImplementedError, "Please destroy before doing a software instance (%s)" % \ raise NotImplementedError("Please destroy before doing a software instance (%s)" % \
(instance.getRelativeUrl(), ) (instance.getRelativeUrl(), ))
else: else:
raise NotImplementedError, "Not supported portal type %s (%s)" % \ raise NotImplementedError("Not supported portal type %s (%s)" % \
(instance.getPortalType(), instance.getRelativeUrl()) (instance.getPortalType(), instance.getRelativeUrl()))
instance.edit(**edit_kw) instance.edit(**edit_kw)
# Prevent storing broken XML in text content (which prevent to update parameters after) # Prevent storing broken XML in text content (which prevent to update parameters after)
......
...@@ -20,7 +20,7 @@ except KeyError: ...@@ -20,7 +20,7 @@ except KeyError:
#raise TypeError, "RequesterInstance_request takes exactly 7 arguments" #raise TypeError, "RequesterInstance_request takes exactly 7 arguments"
if is_slave not in [True, False]: if is_slave not in [True, False]:
raise ValueError, "shared should be a boolean" raise ValueError("shared should be a boolean")
# Instance tree is used as the root of the instance tree # Instance tree is used as the root of the instance tree
if requester_instance.getPortalType() == "Instance Tree": if requester_instance.getPortalType() == "Instance Tree":
...@@ -80,7 +80,7 @@ if instance_count == 0: ...@@ -80,7 +80,7 @@ if instance_count == 0:
elif instance_count == 1: elif instance_count == 1:
request_software_instance = request_software_instance_list[0].getObject() request_software_instance = request_software_instance_list[0].getObject()
else: else:
raise ValueError, "Too many instances '%s' found: %s" % (software_title, [x.path for x in request_software_instance_list]) raise ValueError("Too many instances '%s' found: %s" % (software_title, [x.path for x in request_software_instance_list]))
if (request_software_instance is None): if (request_software_instance is None):
if (root_state == "destroyed"): if (root_state == "destroyed"):
...@@ -161,7 +161,7 @@ if instance_found: ...@@ -161,7 +161,7 @@ if instance_found:
request_software_instance.requestDestroy(**promise_kw) request_software_instance.requestDestroy(**promise_kw)
context.REQUEST.set('request_instance', None) context.REQUEST.set('request_instance', None)
else: else:
raise ValueError, "state should be started, stopped or destroyed" raise ValueError("state should be started, stopped or destroyed")
successor_list = requester_instance.getSuccessorList() successor_list = requester_instance.getSuccessorList()
successor_uid_list = requester_instance.getSuccessorUidList() successor_uid_list = requester_instance.getSuccessorUidList()
......
...@@ -8,12 +8,12 @@ kwargs = state_change.kwargs ...@@ -8,12 +8,12 @@ kwargs = state_change.kwargs
try: try:
compute_node_title = kwargs['compute_node_title'] compute_node_title = kwargs['compute_node_title']
except KeyError: except KeyError:
raise TypeError, "Person_requestComputeNode takes exactly 2 arguments. Missing compute_node_title." raise TypeError("Person_requestComputeNode takes exactly 2 arguments. Missing compute_node_title.")
try: try:
project_reference = kwargs['project_reference'] project_reference = kwargs['project_reference']
except KeyError: except KeyError:
raise TypeError, "Person_requestComputeNode takes exactly 2 arguments. Missing project_reference." raise TypeError("Person_requestComputeNode takes exactly 2 arguments. Missing project_reference.")
tag = "%s_%s_ComputeNodeInProgress" % (person.getUid(), tag = "%s_%s_ComputeNodeInProgress" % (person.getUid(),
compute_node_title) compute_node_title)
......
...@@ -8,12 +8,12 @@ kwargs = state_change.kwargs ...@@ -8,12 +8,12 @@ kwargs = state_change.kwargs
try: try:
computer_network_title = kwargs['network_title'] computer_network_title = kwargs['network_title']
except KeyError: except KeyError:
raise TypeError, "Person_requestNetwork takes exactly 2 arguments. Missing network_title." raise TypeError("Person_requestNetwork takes exactly 2 arguments. Missing network_title.")
try: try:
project_reference = kwargs['project_reference'] project_reference = kwargs['project_reference']
except KeyError: except KeyError:
raise TypeError, "Person_requestNetwork takes exactly 2 arguments. Missing project_reference." raise TypeError("Person_requestNetwork takes exactly 2 arguments. Missing project_reference.")
tag = "%s_%s_NetworkInProgress" % (person.getUid(), tag = "%s_%s_NetworkInProgress" % (person.getUid(),
computer_network_title) computer_network_title)
......
...@@ -15,10 +15,10 @@ try: ...@@ -15,10 +15,10 @@ try:
root_state = kwargs["state"] root_state = kwargs["state"]
project_reference = kwargs['project_reference'] project_reference = kwargs['project_reference']
except KeyError: except KeyError:
raise TypeError, "Person_requestSoftwareInstance takes exactly 8 arguments" raise TypeError("Person_requestSoftwareInstance takes exactly 8 arguments")
if is_slave not in [True, False]: if is_slave not in [True, False]:
raise ValueError, "shared should be a boolean" raise ValueError("shared should be a boolean")
instance_tree_portal_type = "Instance Tree" instance_tree_portal_type = "Instance Tree"
...@@ -46,7 +46,7 @@ request_instance_tree_list = portal.portal_catalog( ...@@ -46,7 +46,7 @@ request_instance_tree_list = portal.portal_catalog(
limit=2, limit=2,
) )
if len(request_instance_tree_list) > 1: if len(request_instance_tree_list) > 1:
raise NotImplementedError, "Too many instance tree %s found %s" % (software_title, [x.path for x in request_instance_tree_list]) raise NotImplementedError("Too many instance tree %s found %s" % (software_title, [x.path for x in request_instance_tree_list]))
elif len(request_instance_tree_list) == 1: elif len(request_instance_tree_list) == 1:
request_instance_tree = request_instance_tree_list[0].getObject() request_instance_tree = request_instance_tree_list[0].getObject()
assert request_instance_tree.getFollowUp() == project_list[0].getRelativeUrl() assert request_instance_tree.getFollowUp() == project_list[0].getRelativeUrl()
...@@ -54,7 +54,7 @@ elif len(request_instance_tree_list) == 1: ...@@ -54,7 +54,7 @@ elif len(request_instance_tree_list) == 1:
(request_instance_tree.getTitle() != software_title) or \ (request_instance_tree.getTitle() != software_title) or \
(request_instance_tree.getValidationState() != "validated") or \ (request_instance_tree.getValidationState() != "validated") or \
(request_instance_tree.getDestinationSection() != person.getRelativeUrl()): (request_instance_tree.getDestinationSection() != person.getRelativeUrl()):
raise NotImplementedError, "The system was not able to get the expected instance tree" raise NotImplementedError("The system was not able to get the expected instance tree")
# Do not allow user to change the release/type/shared status # Do not allow user to change the release/type/shared status
# This is not compatible with invoicing the service # This is not compatible with invoicing the service
# Instance release change will be handled by allocation supply and upgrade decision # Instance release change will be handled by allocation supply and upgrade decision
...@@ -62,7 +62,7 @@ elif len(request_instance_tree_list) == 1: ...@@ -62,7 +62,7 @@ elif len(request_instance_tree_list) == 1:
(request_instance_tree.getSourceReference() != software_type) or \ (request_instance_tree.getSourceReference() != software_type) or \
(request_instance_tree.getRootSlave() != is_slave)) and \ (request_instance_tree.getRootSlave() != is_slave)) and \
(not kwargs.get("force_software_change", False)): (not kwargs.get("force_software_change", False)):
raise NotImplementedError, "You can not change the release / type / shared states" raise NotImplementedError("You can not change the release / type / shared states")
else: else:
if (root_state == "destroyed"): if (root_state == "destroyed"):
# No need to create destroyed subscription. # No need to create destroyed subscription.
...@@ -97,7 +97,7 @@ elif (root_state == "destroyed"): ...@@ -97,7 +97,7 @@ elif (root_state == "destroyed"):
request_instance_tree.requestDestroy(**promise_kw) request_instance_tree.requestDestroy(**promise_kw)
context.REQUEST.set('request_instance_tree', None) context.REQUEST.set('request_instance_tree', None)
else: else:
raise ValueError, "state should be started, stopped or destroyed" raise ValueError("state should be started, stopped or destroyed")
request_instance_tree.requestInstance( request_instance_tree.requestInstance(
software_release=software_release_url_string, software_release=software_release_url_string,
......
...@@ -8,7 +8,7 @@ kwargs = state_change.kwargs ...@@ -8,7 +8,7 @@ kwargs = state_change.kwargs
try: try:
request_url = kwargs['request_url'] request_url = kwargs['request_url']
except KeyError: except KeyError:
raise TypeError, "Person_requestToken takes exactly 1 argument" raise TypeError("Person_requestToken takes exactly 1 argument")
request_method = "POST" request_method = "POST"
access_token = portal.access_token_module.newContent( access_token = portal.access_token_module.newContent(
......
...@@ -10,7 +10,7 @@ message_dict = context.getAccessStatus() ...@@ -10,7 +10,7 @@ message_dict = context.getAccessStatus()
if message_dict.get("no_data", None) == 1: if message_dict.get("no_data", None) == 1:
message_dict = {} message_dict = {}
if message_dict.has_key('created_at'): if 'created_at' in message_dict:
contact_date = DateTime(message_dict.get('created_at').encode('utf-8')) contact_date = DateTime(message_dict.get('created_at').encode('utf-8'))
return (now_date - contact_date) < maximum_days return (now_date - contact_date) < maximum_days
......
...@@ -101,7 +101,7 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -101,7 +101,7 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin):
portal_type='Regularisation Request', portal_type='Regularisation Request',
destination__uid=owner_person.getUid() destination__uid=owner_person.getUid()
) )
self.assertEquals(regularisation_request.getSimulationState(), 'suspended') self.assertEqual(regularisation_request.getSimulationState(), 'suspended')
################################################## ##################################################
# Trigger regularisation request escalation # Trigger regularisation request escalation
...@@ -124,21 +124,21 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -124,21 +124,21 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin):
# Items must be deleted # Items must be deleted
# Open Order must be archived # Open Order must be archived
# Invoice must be paid with Deposit # Invoice must be paid with Deposit
self.assertEquals(project.getValidationState(), 'invalidated') self.assertEqual(project.getValidationState(), 'invalidated')
self.assertEquals(instance_tree.getValidationState(), 'archived') self.assertEqual(instance_tree.getValidationState(), 'archived')
self.assertEquals(instance_tree.getSlapState(), 'destroy_requested') self.assertEqual(instance_tree.getSlapState(), 'destroy_requested')
self.assertEquals(compute_node.getValidationState(), 'invalidated') self.assertEqual(compute_node.getValidationState(), 'invalidated')
open_order_list = self.portal.portal_catalog( open_order_list = self.portal.portal_catalog(
portal_type='Open Sale Order', portal_type='Open Sale Order',
destination_section__uid=owner_person.getUid() destination_section__uid=owner_person.getUid()
) )
hosting_subscription_list = [] hosting_subscription_list = []
self.assertEquals(len(open_order_list), 3) self.assertEqual(len(open_order_list), 3)
for open_order in open_order_list: for open_order in open_order_list:
self.assertEquals(open_order.getValidationState(), 'archived') self.assertEqual(open_order.getValidationState(), 'archived')
self.assertNotEquals(open_order.getStopDate(), open_order.getStartDate()) self.assertNotEqual(open_order.getStopDate(), open_order.getStartDate())
self.assertNotEquals(open_order.getStopDate(), None) self.assertNotEqual(open_order.getStopDate(), None)
self.assertEquals(open_order.getStopDate(), DateTime('2020/07/17')) self.assertEqual(open_order.getStopDate(), DateTime('2020/07/17'))
for line in open_order.contentValues(): for line in open_order.contentValues():
for cell in line.contentValues(): for cell in line.contentValues():
...@@ -149,12 +149,12 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -149,12 +149,12 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin):
if tmp is not None: if tmp is not None:
hosting_subscription_list.append(tmp) hosting_subscription_list.append(tmp)
self.assertEquals(len(hosting_subscription_list), 3) self.assertEqual(len(hosting_subscription_list), 3)
for hosting_subscription in hosting_subscription_list: for hosting_subscription in hosting_subscription_list:
self.assertEquals(hosting_subscription.getValidationState(), 'archived') self.assertEqual(hosting_subscription.getValidationState(), 'archived')
self.assertEquals(regularisation_request.getSimulationState(), 'suspended') self.assertEqual(regularisation_request.getSimulationState(), 'suspended')
self.assertEquals(regularisation_request.getResourceId(), self.assertEqual(regularisation_request.getResourceId(),
'slapos_crm_delete_acknowledgement') 'slapos_crm_delete_acknowledgement')
# No planned invoice is expected # No planned invoice is expected
...@@ -162,15 +162,15 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -162,15 +162,15 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin):
outstanding_amount_list = owner_person.Entity_getOutstandingAmountList( outstanding_amount_list = owner_person.Entity_getOutstandingAmountList(
ledger_uid=ledger_uid ledger_uid=ledger_uid
) )
self.assertEquals(len(outstanding_amount_list), 1) self.assertEqual(len(outstanding_amount_list), 1)
self.assertEquals(outstanding_amount_list[0].total_price, 132) self.assertEqual(outstanding_amount_list[0].total_price, 132)
planned_outstanding_amount_list = owner_person.Entity_getOutstandingAmountList( planned_outstanding_amount_list = owner_person.Entity_getOutstandingAmountList(
ledger_uid=ledger_uid, ledger_uid=ledger_uid,
include_planned=True include_planned=True
) )
self.assertEquals(len(planned_outstanding_amount_list), 1) self.assertEqual(len(planned_outstanding_amount_list), 1)
self.assertEquals(outstanding_amount_list[0].total_price, self.assertEqual(outstanding_amount_list[0].total_price,
planned_outstanding_amount_list[0].total_price) planned_outstanding_amount_list[0].total_price)
......
...@@ -29,9 +29,9 @@ parameter_dict = instance.getConnectionXmlAsDict() ...@@ -29,9 +29,9 @@ parameter_dict = instance.getConnectionXmlAsDict()
url_string = parameter_dict.get('monitor-setup-url', '') url_string = parameter_dict.get('monitor-setup-url', '')
if url_string: if url_string:
if parameter_dict.has_key('monitor-user') and \ if 'monitor-user' in parameter_dict and \
parameter_dict.has_key('monitor-password') and \ 'monitor-password' in parameter_dict and \
parameter_dict.has_key('monitor-base-url'): 'monitor-base-url' in parameter_dict:
username = parameter_dict.get('monitor-user') username = parameter_dict.get('monitor-user')
password = parameter_dict.get('monitor-password') password = parameter_dict.get('monitor-password')
url = parameter_dict.get('monitor-base-url') + '/public/feeds' url = parameter_dict.get('monitor-base-url') + '/public/feeds'
......
...@@ -26,7 +26,7 @@ current_username = context.getPortalObject().portal_membership.getAuthenticatedM ...@@ -26,7 +26,7 @@ current_username = context.getPortalObject().portal_membership.getAuthenticatedM
if current_username == original_login: if current_username == original_login:
# We should logout immediately # We should logout immediately
if context.REQUEST.has_key('portal_skin'): if 'portal_skin' in context.REQUEST:
context.portal_skins.clearSkinCookie() context.portal_skins.clearSkinCookie()
context.REQUEST.RESPONSE.expireCookie('__ac', path='/') context.REQUEST.RESPONSE.expireCookie('__ac', path='/')
context.REQUEST.RESPONSE.expireCookie('__ac_google_hash', path='/') context.REQUEST.RESPONSE.expireCookie('__ac_google_hash', path='/')
......
...@@ -17,7 +17,7 @@ currency_value = portal.restrictedTraverse(price_currency) ...@@ -17,7 +17,7 @@ currency_value = portal.restrictedTraverse(price_currency)
# create the subscription request, which will lead to the Open Order # create the subscription request, which will lead to the Open Order
try: try:
subscription_request = resource.Resource_createSubscriptionRequest(customer, [], project, currency_value=currency_value) subscription_request = resource.Resource_createSubscriptionRequest(customer, [], project, currency_value=currency_value)
except AssertionError, e: except AssertionError as e:
if batch: if batch:
raise raise
return context.Base_redirect( return context.Base_redirect(
......
...@@ -14,7 +14,7 @@ try: ...@@ -14,7 +14,7 @@ try:
vads_url_success = kwargs['vads_url_success'] vads_url_success = kwargs['vads_url_success']
vads_url_return = kwargs['vads_url_return'] vads_url_return = kwargs['vads_url_return']
except KeyError: except KeyError:
raise TypeError, "PayzenEvent_generateNavigationPage takes exactly 6 arguments" raise TypeError("PayzenEvent_generateNavigationPage takes exactly 6 arguments")
payment_transaction = payzen_event.getDestinationValue(portal_type="Payment Transaction") payment_transaction = payzen_event.getDestinationValue(portal_type="Payment Transaction")
now = DateTime() now = DateTime()
...@@ -22,7 +22,7 @@ payment_transaction.AccountingTransaction_updateStartDate(now) ...@@ -22,7 +22,7 @@ payment_transaction.AccountingTransaction_updateStartDate(now)
transaction_date, transaction_number = payment_transaction.PaymentTransaction_generatePayzenId() transaction_date, transaction_number = payment_transaction.PaymentTransaction_generatePayzenId()
if transaction_number is None: if transaction_number is None:
raise ValueError, "Transaction already registered" raise ValueError("Transaction already registered")
transaction_id = transaction_date.Date().replace("/", "") + "-" + transaction_number transaction_id = transaction_date.Date().replace("/", "") + "-" + transaction_number
......
...@@ -14,7 +14,7 @@ def compareAndUpdateAddressList(document, address_list, additional_dict=None): ...@@ -14,7 +14,7 @@ def compareAndUpdateAddressList(document, address_list, additional_dict=None):
to_add_ip_dict_list.remove(current_dict) to_add_ip_dict_list.remove(current_dict)
else: else:
# XXX - Only delete if Network interface are supposed to be the same # XXX - Only delete if Network interface are supposed to be the same
if additional_dict.has_key('network_interface'): if 'network_interface' in additional_dict:
if address.getNetworkInterface('') and additional_dict['network_interface'] != address.getNetworkInterface(): if address.getNetworkInterface('') and additional_dict['network_interface'] != address.getNetworkInterface():
continue continue
to_delete_ip_id_list.append(address.getId()) to_delete_ip_id_list.append(address.getId())
...@@ -94,7 +94,7 @@ for send_partition in compute_node_dict['partition_list']: ...@@ -94,7 +94,7 @@ for send_partition in compute_node_dict['partition_list']:
compareAndUpdateAddressList(partition, send_partition['address_list'], {'network_interface': network_interface}) compareAndUpdateAddressList(partition, send_partition['address_list'], {'network_interface': network_interface})
tap_addr_list = [] tap_addr_list = []
additional_dict = {'network_interface': 'route_' + network_interface} additional_dict = {'network_interface': 'route_' + network_interface}
if send_partition['tap'].has_key('ipv4_addr') and send_partition['tap']['ipv4_addr']: if 'ipv4_addr' in send_partition['tap'] and send_partition['tap']['ipv4_addr']:
tap_addr_list.append({ tap_addr_list.append({
'addr': send_partition['tap']['ipv4_addr'], 'addr': send_partition['tap']['ipv4_addr'],
'netmask': send_partition['tap']['ipv4_netmask'] 'netmask': send_partition['tap']['ipv4_netmask']
......
...@@ -14,8 +14,8 @@ class TestSlapOSHalRestrictedCompatibility(ERP5HALJSONStyleSkinsMixin): ...@@ -14,8 +14,8 @@ class TestSlapOSHalRestrictedCompatibility(ERP5HALJSONStyleSkinsMixin):
fake_request = do_fake_request("GET") fake_request = do_fake_request("GET")
self.logout() self.logout()
self.getHatoasWebSite().ERP5Document_getHateoas(REQUEST=fake_request, mode="search") self.getHatoasWebSite().ERP5Document_getHateoas(REQUEST=fake_request, mode="search")
self.assertEquals(fake_request.RESPONSE.status, 401) self.assertEqual(fake_request.RESPONSE.status, 401)
self.assertEquals(fake_request.RESPONSE.getHeader('WWW-Authenticate'), self.assertEqual(fake_request.RESPONSE.getHeader('WWW-Authenticate'),
'X-Delegate uri="%s/connection/login_form{?came_from}"' % self.getHatoasWebSite().absolute_url() 'X-Delegate uri="%s/connection/login_form{?came_from}"' % self.getHatoasWebSite().absolute_url()
) )
...@@ -32,8 +32,8 @@ class TestSlapOSHalRestrictedCompatibility(ERP5HALJSONStyleSkinsMixin): ...@@ -32,8 +32,8 @@ class TestSlapOSHalRestrictedCompatibility(ERP5HALJSONStyleSkinsMixin):
query='portal_type: "Hosting Subscription"' query='portal_type: "Hosting Subscription"'
) )
self.assertEquals(fake_request.RESPONSE.status, 200) self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEquals(fake_request.RESPONSE.getHeader('Content-Type'), self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json" "application/hal+json"
) )
result_dict = json.loads(result) result_dict = json.loads(result)
......
...@@ -92,11 +92,11 @@ def convertToREST(function): ...@@ -92,11 +92,11 @@ def convertToREST(function):
""" """
try: try:
retval = function(self, *args, **kwd) retval = function(self, *args, **kwd)
except (ValueError, AttributeError), log: except (ValueError, AttributeError) as log:
LOG('SlapTool', INFO, 'Converting ValueError to NotFound, real error:', LOG('SlapTool', INFO, 'Converting ValueError to NotFound, real error:',
error=True) error=True)
raise NotFound(log) raise NotFound(log)
except SoftwareInstanceNotReady, log: except SoftwareInstanceNotReady as log:
self.REQUEST.response.setStatus(408) self.REQUEST.response.setStatus(408)
self.REQUEST.response.setHeader('Cache-Control', 'private') self.REQUEST.response.setHeader('Cache-Control', 'private')
return self.REQUEST.response return self.REQUEST.response
......
...@@ -58,7 +58,7 @@ if destination_decision_value is None: ...@@ -58,7 +58,7 @@ if destination_decision_value is None:
try: try:
subscription_request = service.Resource_createSubscriptionRequest(destination_decision_value, resource_vcl, project_value, currency_value=currency_value, default_price=default_price) subscription_request = service.Resource_createSubscriptionRequest(destination_decision_value, resource_vcl, project_value, currency_value=currency_value, default_price=default_price)
except AssertionError, error: except AssertionError as error:
storeWorkflowComment(item, str(error)) storeWorkflowComment(item, str(error))
return return
subscription_request.setAggregateValue(item) subscription_request.setAggregateValue(item)
......
...@@ -7,7 +7,7 @@ payment_transaction.AccountingTransaction_updateStartDate(now) ...@@ -7,7 +7,7 @@ payment_transaction.AccountingTransaction_updateStartDate(now)
_, transaction_id = payment_transaction.PaymentTransaction_generateWechatId() _, transaction_id = payment_transaction.PaymentTransaction_generateWechatId()
if transaction_id is None: if transaction_id is None:
raise ValueError, "Transaction already registered" raise ValueError("Transaction already registered")
wechat_dict = { wechat_dict = {
'out_trade_no': payment_transaction.getId().encode('utf-8'), 'out_trade_no': payment_transaction.getId().encode('utf-8'),
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
from Products.ERP5Type.Utils import initializeProduct, updateGlobals from Products.ERP5Type.Utils import initializeProduct, updateGlobals
from AccessControl.Permissions import manage_users as ManageUsers from AccessControl.Permissions import manage_users as ManageUsers
import sys import sys
import Permissions from . import Permissions
this_module = sys.modules[ __name__ ] this_module = sys.modules[ __name__ ]
document_classes = updateGlobals(this_module, globals(), document_classes = updateGlobals(this_module, globals(),
permissions_module=Permissions) permissions_module=Permissions)
...@@ -38,10 +38,10 @@ content_constructors = () ...@@ -38,10 +38,10 @@ content_constructors = ()
portal_tools = () portal_tools = ()
from Products.PluggableAuthService.PluggableAuthService import registerMultiPlugin from Products.PluggableAuthService.PluggableAuthService import registerMultiPlugin
import SlapOSShadowAuthenticationPlugin from . import SlapOSShadowAuthenticationPlugin
def initialize(context): def initialize(context):
import Document from . import Document
initializeProduct(context, this_module, globals(), document_module=Document, initializeProduct(context, this_module, globals(), document_module=Document,
document_classes=document_classes, object_classes=object_classes, document_classes=document_classes, object_classes=object_classes,
portal_tools=portal_tools, content_constructors=content_constructors, portal_tools=portal_tools, content_constructors=content_constructors,
......
...@@ -138,7 +138,7 @@ class testSlapOSMixin(ERP5TypeTestCase): ...@@ -138,7 +138,7 @@ class testSlapOSMixin(ERP5TypeTestCase):
def isLiveTest(self): def isLiveTest(self):
#return 'ERP5TypeLiveTestCase' in [q.__name__ for q in self.__class__.mro()] #return 'ERP5TypeLiveTestCase' in [q.__name__ for q in self.__class__.mro()]
# XXX - What is the better way to know if we are in live test mode ? # XXX - What is the better way to know if we are in live test mode ?
return not os.environ.has_key('TEST_CA_PATH') return 'TEST_CA_PATH' not in os.environ
def beforeTearDown(self): def beforeTearDown(self):
if self.abort_transaction: if self.abort_transaction:
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
############################################################################## ##############################################################################
from testSlapOSMixin import testSlapOSMixin from .testSlapOSMixin import testSlapOSMixin
import unittest import unittest
class TestUpgradeInstanceWithOldDataFs(testSlapOSMixin): class TestUpgradeInstanceWithOldDataFs(testSlapOSMixin):
......
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