Commit 8d31c98b authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Rafael Monnerat

Test script for Alarm checkAndUpdateAllocationScope and H_S partial allocation instances

parent c2f92080
...@@ -692,48 +692,102 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -692,48 +692,102 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self.assertEqual('Visited by SoftwareRelease_testForAllocation', self.assertEqual('Visited by SoftwareRelease_testForAllocation',
software_release.workflow_history['edit_workflow'][-1]['comment']) software_release.workflow_history['edit_workflow'][-1]['comment'])
def test_Alarm_notAllowedAllocationScope(self): def _simulateComputer_checkAndUpdateAllocationScope(self):
computer = self._makeComputer(self.new_id) script_name = 'Computer_checkAndUpdateAllocationScope'
person = computer.getSourceAdministrationValue() if script_name in self.portal.portal_skins.custom.objectIds():
self._updatePersonAssignment(person, 'role/member') raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
computer.edit(allocation_scope='open/public') script_name,
self.portal.portal_alarms.slapos_check_update_allocation_scope.activeSense() '*args, **kw',
self.tic() '# Script body\n'
self.assertEquals(computer.getAllocationScope(), 'open/personal') """portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by Computer_checkAndUpdateAllocationScope') """ )
transaction.commit()
computer.edit(allocation_scope='open/personal') def _dropComputer_checkAndUpdateAllocationScope(self):
self.portal.portal_alarms.slapos_check_update_allocation_scope.activeSense() script_name = 'Computer_checkAndUpdateAllocationScope'
self.tic() if script_name in self.portal.portal_skins.custom.objectIds():
self.assertEquals(computer.getAllocationScope(), 'open/personal') self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_Alarm_notAllowedAllocationScope_OpenPublic(self):
computer = self._makeComputer(self.new_id)
computer.edit(allocation_scope = 'open/public')
friend_person = self._makePerson(self.new_id) self._simulateComputer_checkAndUpdateAllocationScope()
computer.edit(allocation_scope='open/friend',
destination_section=friend_person.getRelativeUrl()) try:
self.portal.portal_alarms.slapos_check_update_allocation_scope.activeSense() self.portal.portal_alarms.slapos_crm_check_update_allocation_scope.activeSense()
self.tic() self.tic()
self.assertEquals(computer.getAllocationScope(), 'open/personal') finally:
self._dropComputer_checkAndUpdateAllocationScope()
def test_Alarm_allowedAllocationScope(self): self.assertEqual('Visited by Computer_checkAndUpdateAllocationScope',
computer.workflow_history['edit_workflow'][-1]['comment'])
def test_Alarm_notAllowedAllocationScope_OpenFriend(self):
computer = self._makeComputer(self.new_id) computer = self._makeComputer(self.new_id)
person = computer.getSourceAdministrationValue() computer.edit(allocation_scope = 'open/friend')
self._updatePersonAssignment(person, 'role/service_provider')
computer.edit(allocation_scope='open/public') self._simulateComputer_checkAndUpdateAllocationScope()
self.portal.portal_alarms.slapos_check_update_allocation_scope.activeSense()
self.tic() try:
self.assertEquals(computer.getAllocationScope(), 'open/public') self.portal.portal_alarms.slapos_crm_check_update_allocation_scope.activeSense()
self.tic()
finally:
self._dropComputer_checkAndUpdateAllocationScope()
self.assertEqual('Visited by Computer_checkAndUpdateAllocationScope',
computer.workflow_history['edit_workflow'][-1]['comment'])
def test_Alarm_notAllowedAllocationScope_OpenPersonal(self):
computer = self._makeComputer(self.new_id)
computer.edit(allocation_scope = 'open/personal')
computer.edit(allocation_scope='open/personal') self._simulateComputer_checkAndUpdateAllocationScope()
self.portal.portal_alarms.slapos_check_update_allocation_scope.activeSense()
self.tic() try:
self.assertEquals(computer.getAllocationScope(), 'open/personal') self.portal.portal_alarms.slapos_crm_check_update_allocation_scope.activeSense()
self.tic()
finally:
self._dropComputer_checkAndUpdateAllocationScope()
self.assertNotEqual('Visited by Computer_checkAndUpdateAllocationScope',
computer.workflow_history['edit_workflow'][-1]['comment'])
def _simulateHostingSubscription_checkSofwareInstanceState(self):
script_name = 'HostingSubscription_checkSofwareInstanceState'
if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
script_name,
'*args, **kw',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by HostingSubscription_checkSofwareInstanceState') """ )
transaction.commit()
def _dropHostingSubscription_checkSofwareInstanceState(self):
script_name = 'HostingSubscription_checkSofwareInstanceState'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_Alarm_findAndNofitiyUnallocatedSoftwareInstance(self):
host_sub = self._makeHostingSubscription(self.new_id)
self._makeSoftwareInstance(host_sub, self.generateNewSoftwareReleaseUrl())
instance = host_sub.getPredecessorValue()
self.assertEqual(instance.getAggregate(""), "")
friend_person = self._makePerson(self.new_id) self._simulateHostingSubscription_checkSofwareInstanceState()
computer.edit(allocation_scope='open/friend',
destination_section=friend_person.getRelativeUrl()) try:
self.portal.portal_alarms.slapos_check_update_allocation_scope.activeSense() self.portal.portal_alarms.slapos_crm_check_partially_allocated_instance.activeSense()
self.tic() self.tic()
self.assertEquals(computer.getAllocationScope(), 'open/friend') finally:
self._dropHostingSubscription_checkSofwareInstanceState()
\ No newline at end of file
self.assertEqual('Visited by HostingSubscription_checkSofwareInstanceState',
host_sub.workflow_history['edit_workflow'][-1]['comment'])
\ No newline at end of file
35 36
\ No newline at end of file \ No newline at end of file
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