Commit 00d126f5 authored by Rafael Monnerat's avatar Rafael Monnerat

[slapos_cloud] Test for Capacity at Computer Models

parent c5caf8f0
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Computer Model" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>capacity_quantity</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>template_computer_model</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Computer Model</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>template_computer_model</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -1089,6 +1089,66 @@ class TestSlapOSUpdateComputerCapacityScopeAlarm(testSlapOSMixin): ...@@ -1089,6 +1089,66 @@ class TestSlapOSUpdateComputerCapacityScopeAlarm(testSlapOSMixin):
self.computer.Computer_checkAndUpdateCapacityScope() self.computer.Computer_checkAndUpdateCapacityScope()
self.assertEqual('open', self.computer.getCapacityScope()) self.assertEqual('open', self.computer.getCapacityScope())
def _newComputerModel(self, quantity=None):
computer_model = self.portal.computer_model_module.\
template_computer_model.Base_createCloneDocument(batch_mode=1)
computer_model.edit(capacity_quantity=quantity,
reference='TESTCM-%s' % self.generateNewId(),
)
return computer_model
def _addPartitionToComputer(self):
partition = self.computer.newContent(portal_type='Computer Partition',
reference='part1')
partition.markFree()
partition.markBusy()
partition.validate()
self.software_instance.setAggregate(partition.getRelativeUrl())
self.tic()
def test_Computer_checkAndUpdateCapacityScope_model(self):
computer_model = self._newComputerModel(9999)
self.computer.edit(specialise_value=computer_model,
capacity_quantity=None)
transaction.commit()
self.computer.Computer_checkAndUpdateCapacityScope()
self.assertEqual('open', self.computer.getCapacityScope())
self.assertEqual(computer_model.getCapacityQuantity(),
self.computer.getCapacityQuantity())
def test_Computer_checkAndUpdateCapacityScope_model_no_capacity(self):
self._makeTree()
computer_model = self._newComputerModel(1)
self.computer.edit(specialise_value=computer_model,
capacity_quantity=None)
self._addPartitionToComputer()
self.computer.Computer_checkAndUpdateCapacityScope()
self.assertEqual('close', self.computer.getCapacityScope())
self.assertEqual('Computer capacity limit exceeded',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
self.assertEqual(computer_model.getCapacityQuantity(),
self.computer.getCapacityQuantity())
def test_Computer_checkAndUpdateCapacityScope_model_has_capacity(self):
# If capacity is set on computer, model value is ignored.
self._makeTree()
computer_model = self._newComputerModel(1)
self.computer.edit(specialise_value=computer_model,
capacity_quantity=2)
self._addPartitionToComputer()
self.computer.Computer_checkAndUpdateCapacityScope()
self.assertEqual('open', self.computer.getCapacityScope())
self.assertNotEqual(computer_model.getCapacityQuantity(),
self.computer.getCapacityQuantity())
def test_Computer_checkAndUpdateCapacityScope_with_old_access(self): def test_Computer_checkAndUpdateCapacityScope_with_old_access(self):
memcached_dict = self.portal.portal_memcached.getMemcachedDict( memcached_dict = self.portal.portal_memcached.getMemcachedDict(
key_prefix='slap_tool', key_prefix='slap_tool',
...@@ -1106,14 +1166,7 @@ class TestSlapOSUpdateComputerCapacityScopeAlarm(testSlapOSMixin): ...@@ -1106,14 +1166,7 @@ class TestSlapOSUpdateComputerCapacityScopeAlarm(testSlapOSMixin):
def test_Computer_checkAndUpdateCapacityScope_no_capacity_quantity(self): def test_Computer_checkAndUpdateCapacityScope_no_capacity_quantity(self):
self._makeTree() self._makeTree()
self.computer.edit(capacity_quantity=1) self.computer.edit(capacity_quantity=1)
partition = self.computer.newContent(portal_type='Computer Partition', self._addPartitionToComputer()
reference='part1')
partition.markFree()
partition.markBusy()
partition.validate()
self.software_instance.setAggregate(partition.getRelativeUrl())
self.tic()
self.computer.Computer_checkAndUpdateCapacityScope() self.computer.Computer_checkAndUpdateCapacityScope()
self.assertEqual('close', self.computer.getCapacityScope()) self.assertEqual('close', self.computer.getCapacityScope())
self.assertEqual('Computer capacity limit exceeded', self.assertEqual('Computer capacity limit exceeded',
......
300 301
\ No newline at end of file \ No newline at end of file
acl_users/slapos_access_token_extraction acl_users/slapos_access_token_extraction
acl_users/slapos_machine acl_users/slapos_machine
acl_users/slapos_shadow acl_users/slapos_shadow
computer_model_module/template_computer_model
computer_model_module/template_computer_model/**
computer_module/template_computer computer_module/template_computer
computer_module/template_computer/** computer_module/template_computer/**
hosting_subscription_module/template_hosting_subscription hosting_subscription_module/template_hosting_subscription
......
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