Commit 893c304f authored by Łukasz Nowak's avatar Łukasz Nowak

Cover Slave and Software instance constraints.

parent 056bd3b0
...@@ -6,17 +6,163 @@ ...@@ -6,17 +6,163 @@
############################################################################## ##############################################################################
from Products.SlapOS.tests.testSlapOSMixin import \ from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin testSlapOSMixin
import transaction
def getMessageList(o): def getMessageList(o):
return [str(q.getMessage()) for q in o.checkConsistency()] return [str(q.getMessage()) for q in o.checkConsistency()]
class TestSlapOSSoftwareInstanceConstraint(testSlapOSMixin): class TestSlapOSConstraintMixin(testSlapOSMixin):
def test_sla_xml(self): def _test_property_existence(self, property_id, consistency_message):
software_instance = self.portal.software_instance_module.newContent( self.software_instance.edit(**{property_id:'A'})
# fetch basic list of consistency messages
current_message_list = getMessageList(self.software_instance)
# test the test: no expected message found
self.assertFalse(consistency_message in current_message_list)
# required
self.software_instance.edit(**{property_id:None})
self.assertTrue(consistency_message in getMessageList(self.software_instance))
self.software_instance.edit(**{property_id:''})
self.assertTrue(consistency_message in getMessageList(self.software_instance))
self.software_instance.edit(**{property_id:'A'})
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.assertSameSet(current_message_list, getMessageList(self.software_instance))
class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
def afterSetUp(self):
self.software_instance = self.portal.software_instance_module.newContent(
portal_type='Software Instance') portal_type='Software Instance')
def beforeTearDown(self):
transaction.abort()
def test_connection_xml(self):
# fetch basic list of consistency messages # fetch basic list of consistency messages
current_message_list = getMessageList(software_instance) current_message_list = getMessageList(self.software_instance)
consistency_message = "Connection XML is invalid: Start tag expected, '<' not "\
"found, line 1, column 1"
# test the test: no expected message found
self.assertFalse(consistency_message in current_message_list)
# connection_xml is optional
self.software_instance.edit(connection_xml=None)
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.assertSameSet(current_message_list, getMessageList(self.software_instance))
self.software_instance.edit(connection_xml='')
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.assertSameSet(current_message_list, getMessageList(self.software_instance))
# if available shall be correct XML
self.software_instance.edit(connection_xml='this is bad xml')
self.assertTrue(consistency_message in getMessageList(self.software_instance))
self.software_instance.edit(connection_xml=self.generateEmptyXml())
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.assertSameSet(current_message_list, getMessageList(self.software_instance))
def test_property_existence_destination_reference(self):
self._test_property_existence('destination_reference',
'Property existence error for property destination_reference, this document'
' has no such property or the property has never been set')
def test_property_existence_source_reference(self):
property_id = 'source_reference'
consistency_message = 'Property existence error for property '\
'source_reference, this document has no such property or the property '\
'has never been set'
# not required in draft state
self.software_instance.edit(**{property_id:None})
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.software_instance.edit(**{property_id:''})
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'start_requested')
self._test_property_existence(property_id, consistency_message)
def test_property_existence_reference(self):
self._test_property_existence('reference',
'Property existence error for property reference, this document'
' has no such property or the property has never been set')
def test_property_existence_ssl_certificate(self):
property_id = 'ssl_certificate'
consistency_message = 'Property existence error for property '\
'ssl_certificate, this document has no such property or the property'\
' has never been set'
self._test_property_existence(property_id, consistency_message)
# not required in destroy_requested state
self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested')
self.software_instance.edit(**{property_id:None})
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.software_instance.edit(**{property_id:''})
self.assertFalse(consistency_message in getMessageList(self.software_instance))
def test_property_existence_ssl_key(self):
property_id = 'ssl_key'
consistency_message = 'Property existence error for property '\
'ssl_key, this document has no such property or the property'\
' has never been set'
self._test_property_existence(property_id, consistency_message)
# not required in destroy_requested state
self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested')
self.software_instance.edit(**{property_id:None})
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.software_instance.edit(**{property_id:''})
self.assertFalse(consistency_message in getMessageList(self.software_instance))
def test_predecessor_related(self):
software_instance2 = self.portal.software_instance_module.newContent(
portal_type='Software Instance')
software_instance3 = self.portal.software_instance_module.newContent(
portal_type='Software Instance')
# fetch basic list of consistency messages
current_message_list = getMessageList(self.software_instance)
consistency_message = "There is more then one related predecessor"
# test the test: no expected message found
self.assertFalse(consistency_message in current_message_list)
# if too many, it shall cry
software_instance2.edit(predecessor=self.software_instance.getRelativeUrl())
software_instance3.edit(predecessor=self.software_instance.getRelativeUrl())
self.tic()
self.assertTrue(consistency_message in getMessageList(self.software_instance))
# one is good
software_instance2.edit(predecessor=None)
self.tic()
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.assertSameSet(current_message_list, getMessageList(self.software_instance))
# none is good
software_instance3.edit(predecessor=None)
self.tic()
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.assertSameSet(current_message_list, getMessageList(self.software_instance))
def test_setup_packing_list(self):
raise NotImplementedError('It requires not migrated resources')
def test_sla_xml(self):
# fetch basic list of consistency messages
current_message_list = getMessageList(self.software_instance)
consistency_message = "Sla XML is invalid: Start tag expected, '<' not "\ consistency_message = "Sla XML is invalid: Start tag expected, '<' not "\
"found, line 1, column 1" "found, line 1, column 1"
...@@ -24,17 +170,134 @@ class TestSlapOSSoftwareInstanceConstraint(testSlapOSMixin): ...@@ -24,17 +170,134 @@ class TestSlapOSSoftwareInstanceConstraint(testSlapOSMixin):
# test the test: no expected message found # test the test: no expected message found
self.assertFalse(consistency_message in current_message_list) self.assertFalse(consistency_message in current_message_list)
software_instance.edit(sla_xml='this is bad xml')
self.assertTrue(consistency_message in getMessageList(software_instance))
software_instance.edit(sla_xml=self.generateEmptyXml()) # sla_xml is optional
self.assertFalse(consistency_message in getMessageList(software_instance)) self.software_instance.edit(sla_xml=None)
self.assertSameSet(current_message_list, getMessageList(software_instance)) self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.assertSameSet(current_message_list, getMessageList(self.software_instance))
self.software_instance.edit(sla_xml='')
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.assertSameSet(current_message_list, getMessageList(self.software_instance))
# if available shall be correct XML
self.software_instance.edit(sla_xml='this is bad xml')
self.assertTrue(consistency_message in getMessageList(self.software_instance))
self.software_instance.edit(sla_xml=self.generateEmptyXml())
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.assertSameSet(current_message_list, getMessageList(self.software_instance))
def test_text_content(self):
# fetch basic list of consistency messages
current_message_list = getMessageList(self.software_instance)
consistency_message = "Instance XML is invalid: Start tag expected, '<' not "\
"found, line 1, column 1"
# test the test: no expected message found
self.assertFalse(consistency_message in current_message_list)
# text_content is optional
self.software_instance.edit(text_content=None)
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.assertSameSet(current_message_list, getMessageList(self.software_instance))
self.software_instance.edit(text_content='')
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.assertSameSet(current_message_list, getMessageList(self.software_instance))
# if available shall be correct XML
self.software_instance.edit(text_content='this is bad xml')
self.assertTrue(consistency_message in getMessageList(self.software_instance))
self.software_instance.edit(text_content=self.generateEmptyXml())
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.assertSameSet(current_message_list, getMessageList(self.software_instance))
class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
def afterSetUp(self):
self.software_instance = self.portal.software_instance_module.newContent(
portal_type='Slave Instance')
def beforeTearDown(self):
transaction.abort()
def test_property_existence_source_reference(self):
consistency_message = 'Property existence error for property '\
'source_reference, this document has no such property '\
'or the property has never been set'
property_id = 'source_reference'
# not required in draft state
self.software_instance.edit(**{property_id:None})
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.software_instance.edit(**{property_id:''})
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'start_requested')
self._test_property_existence(property_id, consistency_message)
def test_property_existence_text_content(self):
consistency_message = 'Property existence error for property '\
'text_content, this document has no such property '\
'or the property has never been set'
property_id = 'text_content'
# not required in draft state
self.software_instance.edit(**{property_id:None})
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.software_instance.edit(**{property_id:''})
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'start_requested')
self._test_property_existence(property_id, consistency_message)
def test_property_existence_reference(self):
self._test_property_existence('reference',
'Property existence error for property reference, this document'
' has no such property or the property has never been set')
def test_property_existence_destination_reference(self):
self._test_property_existence('destination_reference',
'Property existence error for property destination_reference, '
'this document has no such property or the property has never '
'been set')
def test_predecessor_related(self):
software_instance2 = self.portal.software_instance_module.newContent(
portal_type='Slave Instance')
software_instance3 = self.portal.software_instance_module.newContent(
portal_type='Slave Instance')
# fetch basic list of consistency messages
current_message_list = getMessageList(self.software_instance)
consistency_message = "There is more then one related predecessor"
# test the test: no expected message found
self.assertFalse(consistency_message in current_message_list)
# if too many, it shall cry
software_instance2.edit(predecessor=self.software_instance.getRelativeUrl())
software_instance3.edit(predecessor=self.software_instance.getRelativeUrl())
self.tic()
self.assertTrue(consistency_message in getMessageList(self.software_instance))
# one is good
software_instance2.edit(predecessor=None)
self.tic()
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.assertSameSet(current_message_list, getMessageList(self.software_instance))
software_instance.edit(sla_xml=None) # none is good
self.assertFalse(consistency_message in getMessageList(software_instance)) software_instance3.edit(predecessor=None)
self.assertSameSet(current_message_list, getMessageList(software_instance)) self.tic()
self.assertFalse(consistency_message in getMessageList(self.software_instance))
self.assertSameSet(current_message_list, getMessageList(self.software_instance))
software_instance.edit(sla_xml='') def test_setup_packing_list(self):
self.assertFalse(consistency_message in getMessageList(software_instance)) raise NotImplementedError('It requires not migrated resources')
self.assertSameSet(current_message_list, getMessageList(software_instance))
213 214
\ 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