Commit ccbf6e16 authored by Rafael Monnerat's avatar Rafael Monnerat

Improve code for stable assertions

See merge request nexedi/slapos.core!615
parents 90f756ea 926841f6
...@@ -1403,7 +1403,7 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder): ...@@ -1403,7 +1403,7 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
self.assertFalse(transaction_line.hasStopDate()) self.assertFalse(transaction_line.hasStopDate())
self.assertEqual([], transaction_line.contentValues( self.assertEqual([], transaction_line.contentValues(
portal_type='Delivery Cell')) portal_type='Delivery Cell'))
self.assertTrue(simulation_movement.getRelativeUrl() in self.assertIn(simulation_movement.getRelativeUrl(),
transaction_line.getDeliveryRelatedList( transaction_line.getDeliveryRelatedList(
portal_type='Simulation Movement')) portal_type='Simulation Movement'))
...@@ -1741,7 +1741,7 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis ...@@ -1741,7 +1741,7 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
self.assertFalse(transaction_line.hasStopDate()) self.assertFalse(transaction_line.hasStopDate())
self.assertEqual([], transaction_line.contentValues( self.assertEqual([], transaction_line.contentValues(
portal_type='Delivery Cell')) portal_type='Delivery Cell'))
self.assertTrue(simulation_movement.getRelativeUrl() in self.assertIn(simulation_movement.getRelativeUrl(),
transaction_line.getDeliveryRelatedList( transaction_line.getDeliveryRelatedList(
portal_type='Simulation Movement')) portal_type='Simulation Movement'))
......
...@@ -138,7 +138,7 @@ class SlapOSCacheMixin: ...@@ -138,7 +138,7 @@ class SlapOSCacheMixin:
'state': state, 'state': state,
'reference': self.getReference(), 'reference': self.getReference(),
'portal_type': self.getPortalType() 'portal_type': self.getPortalType()
}) }, sort_keys=True)
cache_duration = self._getAccessStatusCacheFactory().cache_duration cache_duration = self._getAccessStatusCacheFactory().cache_duration
self._getAccessStatusPlugin().set(self._getAccessStatusCacheKey(), self._getAccessStatusPlugin().set(self._getAccessStatusCacheKey(),
......
...@@ -125,7 +125,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -125,7 +125,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
def requestComputeNode(self, title): def requestComputeNode(self, title):
requestXml = self.portal.portal_slap.requestComputer(title) requestXml = self.portal.portal_slap.requestComputer(title)
self.tic() self.tic()
self.assertTrue('marshal' in requestXml) self.assertIn('marshal', requestXml)
compute_node = xml_marshaller.xml_marshaller.loads(requestXml) compute_node = xml_marshaller.xml_marshaller.loads(requestXml)
compute_node_id = getattr(compute_node, '_computer_id', None) compute_node_id = getattr(compute_node, '_computer_id', None)
self.assertNotEqual(None, compute_node_id) self.assertNotEqual(None, compute_node_id)
......
...@@ -115,7 +115,9 @@ class TestSlapOSCloudSlapOSCacheMixin( ...@@ -115,7 +115,9 @@ class TestSlapOSCloudSlapOSCacheMixin(
'since': '%s' % since, 'since': '%s' % since,
'state': "", 'state': "",
"text": "#access TEST123 %s" % doc.getUid() "text": "#access TEST123 %s" % doc.getUid()
}) },
sort_keys=True,
)
def getBaseExpectedDict(doc): def getBaseExpectedDict(doc):
return _decode_with_json({ return _decode_with_json({
"portal_type": doc.getPortalType(), "portal_type": doc.getPortalType(),
...@@ -187,7 +189,9 @@ class TestSlapOSCloudSlapOSCacheMixin( ...@@ -187,7 +189,9 @@ class TestSlapOSCloudSlapOSCacheMixin(
'since': '%s' % since, 'since': '%s' % since,
'state': "", 'state': "",
"text": "#access TEST123 %s" % doc.getUid() "text": "#access TEST123 %s" % doc.getUid()
}) },
sort_keys=True,
)
def getBaseExpectedDict(doc): def getBaseExpectedDict(doc):
return _decode_with_json({ return _decode_with_json({
"portal_type": doc.getPortalType(), "portal_type": doc.getPortalType(),
...@@ -267,7 +271,9 @@ class TestSlapOSCloudSlapOSCacheMixin( ...@@ -267,7 +271,9 @@ class TestSlapOSCloudSlapOSCacheMixin(
'since': '%s' % since, 'since': '%s' % since,
'state': "", 'state': "",
"text": "#error TEST123 %s" % doc.getUid() "text": "#error TEST123 %s" % doc.getUid()
}) },
sort_keys=True,
)
def getBaseExpectedDict(doc): def getBaseExpectedDict(doc):
return _decode_with_json({ return _decode_with_json({
"portal_type": doc.getPortalType(), "portal_type": doc.getPortalType(),
...@@ -338,7 +344,9 @@ class TestSlapOSCloudSlapOSCacheMixin( ...@@ -338,7 +344,9 @@ class TestSlapOSCloudSlapOSCacheMixin(
'since': '%s' % since, 'since': '%s' % since,
'state': "", 'state': "",
"text": "#building TEST123 %s" % doc.getUid() "text": "#building TEST123 %s" % doc.getUid()
}) },
sort_keys=True,
)
def getBaseExpectedDict(doc): def getBaseExpectedDict(doc):
return _decode_with_json({ return _decode_with_json({
"portal_type": doc.getPortalType(), "portal_type": doc.getPortalType(),
......
...@@ -17,11 +17,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm( ...@@ -17,11 +17,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm(
self.tic() self.tic()
# check that no interaction has recreated the instance # check that no interaction has recreated the instance
self.assertFalse(self.instance_tree.getTitle() in self.assertNotIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
self.instance_tree.InstanceTree_assertSuccessor() self.instance_tree.InstanceTree_assertSuccessor()
self.assertTrue(self.instance_tree.getTitle() in self.assertIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
def test_InstanceTree_assertSuccessor_stop_requested(self): def test_InstanceTree_assertSuccessor_stop_requested(self):
...@@ -31,11 +31,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm( ...@@ -31,11 +31,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm(
self.tic() self.tic()
# check that no interaction has recreated the instance # check that no interaction has recreated the instance
self.assertFalse(self.instance_tree.getTitle() in self.assertNotIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
self.instance_tree.InstanceTree_assertSuccessor() self.instance_tree.InstanceTree_assertSuccessor()
self.assertTrue(self.instance_tree.getTitle() in self.assertIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
def test_InstanceTree_assertSuccessor_destroy_requested(self): def test_InstanceTree_assertSuccessor_destroy_requested(self):
...@@ -45,11 +45,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm( ...@@ -45,11 +45,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm(
self.tic() self.tic()
# check that no interaction has recreated the instance # check that no interaction has recreated the instance
self.assertFalse(self.instance_tree.getTitle() in self.assertNotIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
self.instance_tree.InstanceTree_assertSuccessor() self.instance_tree.InstanceTree_assertSuccessor()
self.assertFalse(self.instance_tree.getTitle() in self.assertNotIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
def test_InstanceTree_assertSuccessor_archived(self): def test_InstanceTree_assertSuccessor_archived(self):
...@@ -58,11 +58,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm( ...@@ -58,11 +58,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm(
self.tic() self.tic()
# check that no interaction has recreated the instance # check that no interaction has recreated the instance
self.assertFalse(self.instance_tree.getTitle() in self.assertNotIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
self.instance_tree.InstanceTree_assertSuccessor() self.instance_tree.InstanceTree_assertSuccessor()
self.assertFalse(self.instance_tree.getTitle() in self.assertNotIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
def test_alarm_renamed(self): def test_alarm_renamed(self):
......
...@@ -59,8 +59,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -59,8 +59,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self.assertNotEqual(certificate_login.getReference(), None) self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None) self.assertNotEqual(certificate_login.getDestinationReference(), None)
serial = '0x%x' % int(certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(certificate_login.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
def test_generateCertificate_twice(self): def test_generateCertificate_twice(self):
self.login(self.compute_node.getUserId()) self.login(self.compute_node.getUserId())
...@@ -78,8 +78,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -78,8 +78,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self.assertNotEqual(certificate_login.getReference(), None) self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None) self.assertNotEqual(certificate_login.getDestinationReference(), None)
serial = '0x%x' % int(certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(certificate_login.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertRaises(ValueError, self.compute_node.generateCertificate) self.assertRaises(ValueError, self.compute_node.generateCertificate)
self.assertEqual(None, self.portal.REQUEST.get('compute_node_key')) self.assertEqual(None, self.portal.REQUEST.get('compute_node_key'))
...@@ -271,8 +271,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -271,8 +271,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self.assertNotEqual(certificate_login.getReference(), None) self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None) self.assertNotEqual(certificate_login.getDestinationReference(), None)
serial = '0x%x' % int(certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(certificate_login.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertNotEqual(certificate_login.getReference(), self.assertNotEqual(certificate_login.getReference(),
self.compute_node.getReference()) self.compute_node.getReference())
...@@ -305,8 +305,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -305,8 +305,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self.assertNotEqual(certificate_login.getReference(), None) self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None) self.assertNotEqual(certificate_login.getDestinationReference(), None)
serial = '0x%x' % int(certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(certificate_login.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertNotEqual(certificate_login.getReference(), self.assertNotEqual(certificate_login.getReference(),
self.compute_node.getReference()) self.compute_node.getReference())
...@@ -340,8 +340,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -340,8 +340,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self.assertNotEqual(certificate_login.getReference(), None) self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None) self.assertNotEqual(certificate_login.getDestinationReference(), None)
serial = '0x%x' % int(certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(certificate_login.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertNotEqual(certificate_login.getReference(), self.assertNotEqual(certificate_login.getReference(),
self.compute_node.getReference()) self.compute_node.getReference())
self.assertNotEqual(None, destination_reference) self.assertNotEqual(None, destination_reference)
...@@ -375,9 +375,9 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -375,9 +375,9 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
serial = '0x%x' % int(new_certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(new_certificate_login.getDestinationReference(), 16)
compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate') compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate')
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(new_certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(new_certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertFalse(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertNotIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertNotEqual(certificate_login.getReference(), self.assertNotEqual(certificate_login.getReference(),
self.compute_node.getReference()) self.compute_node.getReference())
...@@ -399,8 +399,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -399,8 +399,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self.assertNotEqual(certificate_login.getReference(), None) self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None) self.assertNotEqual(certificate_login.getDestinationReference(), None)
serial = '0x%x' % int(certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(certificate_login.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertNotEqual(certificate_login.getReference(), self.assertNotEqual(certificate_login.getReference(),
self.compute_node.getReference()) self.compute_node.getReference())
self.assertNotEqual(None, destination_reference) self.assertNotEqual(None, destination_reference)
...@@ -434,9 +434,9 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -434,9 +434,9 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
serial = '0x%x' % int(new_certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(new_certificate_login.getDestinationReference(), 16)
compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate') compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate')
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(new_certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(new_certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertFalse(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertNotIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertNotEqual(certificate_login.getReference(), self.assertNotEqual(certificate_login.getReference(),
self.compute_node.getReference()) self.compute_node.getReference())
...@@ -471,9 +471,9 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -471,9 +471,9 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
serial = '0x%x' % int(third_certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(third_certificate_login.getDestinationReference(), 16)
compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate') compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate')
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(third_certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(third_certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertFalse(new_certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertNotIn(new_certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertNotEqual(third_certificate_login.getReference(), self.assertNotEqual(third_certificate_login.getReference(),
self.compute_node.getReference()) self.compute_node.getReference())
......
...@@ -1337,8 +1337,8 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflowTransfer(SlapOSTestCaseMixin): ...@@ -1337,8 +1337,8 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflowTransfer(SlapOSTestCaseMixin):
self.assertNotEqual(certificate_login.getReference(), None) self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None) self.assertNotEqual(certificate_login.getDestinationReference(), None)
serial = '0x%x' % int(certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(certificate_login.getDestinationReference(), 16)
self.assertTrue(serial in self.software_instance.getSslCertificate()) self.assertIn(serial, self.software_instance.getSslCertificate())
self.assertTrue(certificate_login.getReference() in \ self.assertIn(certificate_login.getReference(), \
self.software_instance.getSslCertificate().decode('string_escape')) self.software_instance.getSslCertificate().decode('string_escape'))
self.assertRaises(ValueError, self.software_instance.generateCertificate) self.assertRaises(ValueError, self.software_instance.generateCertificate)
......
...@@ -100,7 +100,7 @@ class TestSlapOSComputeNodeSecurity(TestSlapOSSecurityMixin): ...@@ -100,7 +100,7 @@ class TestSlapOSComputeNodeSecurity(TestSlapOSSecurityMixin):
self.login(user_id) self.login(user_id)
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-COMPUTER'], self.assertSameSet(['R-COMPUTER'],
user.getGroups()) user.getGroups())
...@@ -136,7 +136,7 @@ class TestSlapOSSoftwareInstanceSecurity(TestSlapOSSecurityMixin): ...@@ -136,7 +136,7 @@ class TestSlapOSSoftwareInstanceSecurity(TestSlapOSSecurityMixin):
# instance w/o subscription is loggable and it has some roles # instance w/o subscription is loggable and it has some roles
self.login(user_id) self.login(user_id)
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-INSTANCE'], self.assertSameSet(['R-INSTANCE'],
user.getGroups()) user.getGroups())
...@@ -154,7 +154,7 @@ class TestSlapOSSoftwareInstanceSecurity(TestSlapOSSecurityMixin): ...@@ -154,7 +154,7 @@ class TestSlapOSSoftwareInstanceSecurity(TestSlapOSSecurityMixin):
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
self.login(user_id) self.login(user_id)
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-INSTANCE', subscription_reference], self.assertSameSet(['R-INSTANCE', subscription_reference],
user.getGroups()) user.getGroups())
...@@ -196,7 +196,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin): ...@@ -196,7 +196,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
self.login(person.getUserId()) self.login(person.getUserId())
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet([], user.getGroups()) self.assertSameSet([], user.getGroups())
...@@ -209,7 +209,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin): ...@@ -209,7 +209,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
self.login(person.getUserId()) self.login(person.getUserId())
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['G-COMPANY'], user.getGroups()) self.assertSameSet(['G-COMPANY'], user.getGroups())
# add to role category # add to role category
...@@ -220,7 +220,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin): ...@@ -220,7 +220,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
self.login(person.getUserId()) self.login(person.getUserId())
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-MEMBER', 'G-COMPANY'], user.getGroups()) self.assertSameSet(['R-MEMBER', 'G-COMPANY'], user.getGroups())
# add to role for project # add to role for project
...@@ -236,7 +236,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin): ...@@ -236,7 +236,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
self.login(person.getUserId()) self.login(person.getUserId())
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-MEMBER', 'G-COMPANY', project.getReference()], user.getGroups()) self.assertSameSet(['R-MEMBER', 'G-COMPANY', project.getReference()], user.getGroups())
# add to role for project # add to role for project
...@@ -253,7 +253,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin): ...@@ -253,7 +253,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
self.login(person.getUserId()) self.login(person.getUserId())
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-MEMBER', 'G-COMPANY', organisation.getReference(), self.assertSameSet(['R-MEMBER', 'G-COMPANY', organisation.getReference(),
project.getReference()], user.getGroups()) project.getReference()], user.getGroups())
......
...@@ -54,7 +54,7 @@ class TestSlapOSShadowPerson(TestSlapOSSecurityMixin): ...@@ -54,7 +54,7 @@ class TestSlapOSShadowPerson(TestSlapOSSecurityMixin):
self.login(shadow_user_id) self.login(shadow_user_id)
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-SHADOW-PERSON', 'SHADOW-%s' % user_id], self.assertSameSet(['R-SHADOW-PERSON', 'SHADOW-%s' % user_id],
user.getGroups()) user.getGroups())
...@@ -95,7 +95,7 @@ class TestSlapOSShadowComputeNode(TestSlapOSSecurityMixin): ...@@ -95,7 +95,7 @@ class TestSlapOSShadowComputeNode(TestSlapOSSecurityMixin):
self.login(shadow_user_id) self.login(shadow_user_id)
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-SHADOW-COMPUTENODE', 'SHADOW-%s' % user_id], self.assertSameSet(['R-SHADOW-COMPUTENODE', 'SHADOW-%s' % user_id],
user.getGroups()) user.getGroups())
...@@ -135,7 +135,7 @@ class TestSlapOSShadowSoftwareInstance(TestSlapOSSecurityMixin): ...@@ -135,7 +135,7 @@ class TestSlapOSShadowSoftwareInstance(TestSlapOSSecurityMixin):
self.login(shadow_user_id) self.login(shadow_user_id)
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-SHADOW-SOFTWAREINSTANCE', 'SHADOW-%s' % user_id], self.assertSameSet(['R-SHADOW-SOFTWAREINSTANCE', 'SHADOW-%s' % user_id],
user.getGroups()) user.getGroups())
......
...@@ -32,29 +32,29 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -32,29 +32,29 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
) )
# Nothing to migrate # Nothing to migrate
self.assertFalse(migration_message in getMessageList(instance_nothing_to_migrate)) self.assertNotIn(migration_message, getMessageList(instance_nothing_to_migrate))
self.assertFalse(error_message in getMessageList(instance_nothing_to_migrate)) self.assertNotIn(error_message, getMessageList(instance_nothing_to_migrate))
# Migrate # Migrate
self.assertTrue(migration_message in getMessageList(instance_to_migrate)) self.assertIn(migration_message, getMessageList(instance_to_migrate))
self.assertFalse(error_message in getMessageList(instance_to_migrate)) self.assertNotIn(error_message, getMessageList(instance_to_migrate))
instance_to_migrate.fixConsistency() instance_to_migrate.fixConsistency()
self.assertEqual(None, instance_to_migrate.getPredecessor()) self.assertEqual(None, instance_to_migrate.getPredecessor())
self.assertEqual(instance_nothing_to_migrate.getRelativeUrl(), self.assertEqual(instance_nothing_to_migrate.getRelativeUrl(),
instance_to_migrate.getSuccessor()) instance_to_migrate.getSuccessor())
self.assertFalse(migration_message in getMessageList(instance_to_migrate)) self.assertNotIn(migration_message, getMessageList(instance_to_migrate))
self.assertFalse(error_message in getMessageList(instance_to_migrate)) self.assertNotIn(error_message, getMessageList(instance_to_migrate))
# Error # Error
self.assertFalse(migration_message in getMessageList(instance_badly_migrated)) self.assertNotIn(migration_message, getMessageList(instance_badly_migrated))
self.assertTrue(error_message in getMessageList(instance_badly_migrated)) self.assertIn(error_message, getMessageList(instance_badly_migrated))
instance_badly_migrated.fixConsistency() instance_badly_migrated.fixConsistency()
self.assertEqual(instance_nothing_to_migrate.getRelativeUrl(), self.assertEqual(instance_nothing_to_migrate.getRelativeUrl(),
instance_badly_migrated.getPredecessor()) instance_badly_migrated.getPredecessor())
self.assertEqual(instance_nothing_to_migrate.getRelativeUrl(), self.assertEqual(instance_nothing_to_migrate.getRelativeUrl(),
instance_badly_migrated.getSuccessor()) instance_badly_migrated.getSuccessor())
self.assertFalse(migration_message in getMessageList(instance_badly_migrated)) self.assertNotIn(migration_message, getMessageList(instance_badly_migrated))
self.assertTrue(error_message in getMessageList(instance_badly_migrated)) self.assertIn(error_message, getMessageList(instance_badly_migrated))
def test_upgrade_software_instance_predecessor(self): def test_upgrade_software_instance_predecessor(self):
return self.check_upgrade_instance_predecessor('Software Instance') return self.check_upgrade_instance_predecessor('Software Instance')
...@@ -107,10 +107,10 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -107,10 +107,10 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
self.tic() self.tic()
# Nothing to migrate # Nothing to migrate
self.assertFalse(migration_message in getMessageList(hosting_subscription_nothing_to_migrate)) self.assertNotIn(migration_message, getMessageList(hosting_subscription_nothing_to_migrate))
# To migrate # To migrate
self.assertTrue(migration_message in getMessageList(hosting_subscription_to_migrate)) self.assertIn(migration_message, getMessageList(hosting_subscription_to_migrate))
hosting_subscription_to_migrate.fixConsistency() hosting_subscription_to_migrate.fixConsistency()
self.commit() self.commit()
...@@ -145,8 +145,8 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -145,8 +145,8 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
migrated_instance_tree.getCreationDate()) migrated_instance_tree.getCreationDate())
# self.assertEqual(modification_date, # self.assertEqual(modification_date,
# migrated_instance_tree.getModificationDate()) # migrated_instance_tree.getModificationDate())
self.assertFalse('hosting_subscription_workflow' in migrated_instance_tree.workflow_history) self.assertNotIn('hosting_subscription_workflow', migrated_instance_tree.workflow_history)
self.assertFalse(migration_message in getMessageList(migrated_instance_tree)) self.assertNotIn(migration_message, getMessageList(migrated_instance_tree))
self.assertEqual(migrated_instance_tree.getRelativeUrl(), self.assertEqual(migrated_instance_tree.getRelativeUrl(),
software_instance.getAggregate()) software_instance.getAggregate())
self.assertEqual(1, len(self.portal.portal_catalog(uid=migrated_instance_tree.getUid()))) self.assertEqual(1, len(self.portal.portal_catalog(uid=migrated_instance_tree.getUid())))
...@@ -213,10 +213,10 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -213,10 +213,10 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
self.tic() self.tic()
# Nothing to migrate # Nothing to migrate
self.assertFalse(migration_message in getMessageList(computer_nothing_to_migrate)) self.assertNotIn(migration_message, getMessageList(computer_nothing_to_migrate))
# To migrate # To migrate
self.assertTrue(migration_message in getMessageList(computer_to_migrate)) self.assertIn(migration_message, getMessageList(computer_to_migrate))
computer_to_migrate.fixConsistency() computer_to_migrate.fixConsistency()
self.commit() self.commit()
...@@ -258,9 +258,9 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -258,9 +258,9 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
migrated_compute_node.getCreationDate()) migrated_compute_node.getCreationDate())
# self.assertEqual(modification_date, # self.assertEqual(modification_date,
# migrated_compute_node.getModificationDate()) # migrated_compute_node.getModificationDate())
self.assertFalse('computer_slap_interface_workflow' in migrated_compute_node.workflow_history) self.assertNotIn('computer_slap_interface_workflow', migrated_compute_node.workflow_history)
self.assertFalse(migration_message in getMessageList(migrated_compute_node)) self.assertNotIn(migration_message, getMessageList(migrated_compute_node))
self.assertEqual(migrated_compute_node.getRelativeUrl(), self.assertEqual(migrated_compute_node.getRelativeUrl(),
software_installation.getAggregate()) software_installation.getAggregate())
self.assertEqual(migrated_computer_partition.getRelativeUrl(), self.assertEqual(migrated_computer_partition.getRelativeUrl(),
...@@ -318,10 +318,10 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -318,10 +318,10 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
self.tic() self.tic()
# Nothing to migrate # Nothing to migrate
self.assertFalse(migration_message in getMessageList(computer_nothing_to_migrate)) self.assertNotIn(migration_message, getMessageList(computer_nothing_to_migrate))
# To migrate # To migrate
self.assertTrue(migration_message in getMessageList(computer_partition_to_migrate)) self.assertIn(migration_message, getMessageList(computer_partition_to_migrate))
computer_partition_to_migrate.fixConsistency() computer_partition_to_migrate.fixConsistency()
self.commit() self.commit()
...@@ -344,8 +344,8 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -344,8 +344,8 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
migrated_computer_partition.getCreationDate()) migrated_computer_partition.getCreationDate())
# self.assertEqual(modification_date, # self.assertEqual(modification_date,
# migrated_compute_node.getModificationDate()) # migrated_compute_node.getModificationDate())
self.assertFalse('computer_partition_slap_interface_workflow' in migrated_computer_partition.workflow_history) self.assertNotIn('computer_partition_slap_interface_workflow', migrated_computer_partition.workflow_history)
self.assertFalse(migration_message in getMessageList(computer_partition_to_migrate)) self.assertNotIn(migration_message, getMessageList(computer_partition_to_migrate))
self.assertEqual(1, len(self.portal.portal_catalog(uid=migrated_computer_partition.getUid()))) self.assertEqual(1, len(self.portal.portal_catalog(uid=migrated_computer_partition.getUid())))
...@@ -37,7 +37,9 @@ class TestSlapOSRenderJSOSSUIHalStyle(SlapOSTestCaseMixin, ERP5TypeFunctionalTes ...@@ -37,7 +37,9 @@ class TestSlapOSRenderJSOSSUIHalStyle(SlapOSTestCaseMixin, ERP5TypeFunctionalTes
ERP5TypeFunctionalTestCase.afterSetUp(self) ERP5TypeFunctionalTestCase.afterSetUp(self)
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
# Ensuring the default available language is "en" for English UI test # Ensuring the default available language is "en" for English UI test
self.getPortalObject().web_site_module.renderjs_oss.setDefaultAvailableLanguage('en') self.portal.web_site_module.renderjs_oss.setDefaultAvailableLanguage('en')
# fix consistency to update translation
self.portal.web_site_module.renderjs_oss.fixConsistency()
self.tic() self.tic()
def test_suite(): def test_suite():
......
...@@ -37,7 +37,9 @@ class TestSlapOSUIZHHalStyle(SlapOSTestCaseMixin, ERP5TypeFunctionalTestCase): ...@@ -37,7 +37,9 @@ class TestSlapOSUIZHHalStyle(SlapOSTestCaseMixin, ERP5TypeFunctionalTestCase):
ERP5TypeFunctionalTestCase.afterSetUp(self) ERP5TypeFunctionalTestCase.afterSetUp(self)
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
# set default available language as "zh" for Chinese UI test # set default available language as "zh" for Chinese UI test
self.getPortalObject().web_site_module.hostingjs.setDefaultAvailableLanguage('zh') self.portal.web_site_module.hostingjs.setDefaultAvailableLanguage('zh')
# fix consistency to update translation
self.portal.web_site_module.hostingjs.fixConsistency()
self.tic() self.tic()
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
......
...@@ -241,11 +241,11 @@ class TestSlapOSDestroySoftwareInstallationWithArchivedSoftwareReleaseAlarm(Slap ...@@ -241,11 +241,11 @@ class TestSlapOSDestroySoftwareInstallationWithArchivedSoftwareReleaseAlarm(Slap
self.tic() self.tic()
v = 'Visited by SoftwareRelease_findAndDestroySoftwareInstallation' v = 'Visited by SoftwareRelease_findAndDestroySoftwareInstallation'
self.assertFalse(v in self.assertNotIn(v,
[q['comment'] for q in published_software_release.workflow_history['edit_workflow']]) [q['comment'] for q in published_software_release.workflow_history['edit_workflow']])
self.assertTrue(v in self.assertIn(v,
[q['comment'] for q in archived_cleaned_software_release.workflow_history['edit_workflow']]) [q['comment'] for q in archived_cleaned_software_release.workflow_history['edit_workflow']])
self.assertTrue(v in self.assertIn(v,
[q['comment'] for q in archived_software_release.workflow_history['edit_workflow']]) [q['comment'] for q in archived_software_release.workflow_history['edit_workflow']])
@simulateByEditWorkflowMark('SoftwareInstallation_destroyWithSoftwareReleaseArchived') @simulateByEditWorkflowMark('SoftwareInstallation_destroyWithSoftwareReleaseArchived')
...@@ -304,9 +304,9 @@ class TestSlapOSDestroySoftwareInstallationWithArchivedSoftwareReleaseAlarm(Slap ...@@ -304,9 +304,9 @@ class TestSlapOSDestroySoftwareInstallationWithArchivedSoftwareReleaseAlarm(Slap
self.tic() self.tic()
v = 'Visited by SoftwareInstallation_destroyWithSoftwareReleaseArchived' v = 'Visited by SoftwareInstallation_destroyWithSoftwareReleaseArchived'
self.assertTrue(v in self.assertIn(v,
[q['comment'] for q in software_installation_validated_request_start.workflow_history['edit_workflow']]) [q['comment'] for q in software_installation_validated_request_start.workflow_history['edit_workflow']])
self.assertFalse(v in self.assertNotIn(v,
[q['comment'] for q in software_installation_validated_request_destroy.workflow_history['edit_workflow']]) [q['comment'] for q in software_installation_validated_request_destroy.workflow_history['edit_workflow']])
self.assertFalse(v in self.assertNotIn(v,
[q['comment'] for q in software_installation_invalidated_request_destroy.workflow_history['edit_workflow']]) [q['comment'] for q in software_installation_invalidated_request_destroy.workflow_history['edit_workflow']])
\ No newline at end of file
...@@ -127,7 +127,7 @@ class TestSlapOSEvent_getRSSTextContent(TestRSSSyleSkinsMixin): ...@@ -127,7 +127,7 @@ class TestSlapOSEvent_getRSSTextContent(TestRSSSyleSkinsMixin):
self.portal.portal_skins.changeSkin('RSS') self.portal.portal_skins.changeSkin('RSS')
text_content = event.Event_getRSSTextContent() text_content = event.Event_getRSSTextContent()
self.assertTrue(event.getTextContent() in text_content) self.assertIn(event.getTextContent(), text_content)
self.assertTrue("Sender: " in text_content, "Sender: not in %s" % text_content) self.assertTrue("Sender: " in text_content, "Sender: not in %s" % text_content)
self.assertTrue("Recipient: " in text_content, "Recipient: not in %s" % text_content) self.assertTrue("Recipient: " in text_content, "Recipient: not in %s" % text_content)
self.assertTrue("Content:" in text_content, "Content: not in %s" % text_content) self.assertTrue("Content:" in text_content, "Content: not in %s" % text_content)
......
...@@ -88,7 +88,7 @@ class TestSlapOSCoreComputeNodeUpdateFromDict(SlapOSTestCaseMixinWithAbort): ...@@ -88,7 +88,7 @@ class TestSlapOSCoreComputeNodeUpdateFromDict(SlapOSTestCaseMixinWithAbort):
self.assertEqual(address.getIpAddress(), 'e') self.assertEqual(address.getIpAddress(), 'e')
self.assertEqual(address.getNetmask(), 'f') self.assertEqual(address.getNetmask(), 'f')
# Existing document should be edited if possible # Existing document should be edited if possible
self.assertTrue(address.getId() in ('foo', 'bar')) self.assertIn(address.getId(), ('foo', 'bar'))
############################################# #############################################
# Compute Partition network information # Compute Partition network information
......
...@@ -35,6 +35,11 @@ for i in range(amount): ...@@ -35,6 +35,11 @@ for i in range(amount):
xml_parameter = """<?xml version="1.0" encoding="utf-8"?> xml_parameter = """<?xml version="1.0" encoding="utf-8"?>
<instance> <instance>
<parameter id="_">%s</parameter> <parameter id="_">%s</parameter>
</instance>""" % json.dumps(json_parameter, indent=2) </instance>""" % json.dumps(json_parameter,
indent=2,
sort_keys=True,
# BBB PY2 https://github.com/python/cpython/issues/60537#issuecomment-1093598422
separators=(',', ': '),
)
return xml_parameter return xml_parameter
...@@ -966,9 +966,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -966,9 +966,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
"TestSubscriptionSkins Notification Message %s %s" % ( "TestSubscriptionSkins Notification Message %s %s" % (
subscription_request.getLanguage(), notification_message), subscription_request.getLanguage(), notification_message),
mail_message.getTitle()) mail_message.getTitle())
self.assertTrue(subscription_request.getDefaultEmailText() in \ self.assertIn(subscription_request.getDefaultEmailText(), \
mail_message.getTextContent()) mail_message.getTextContent())
self.assertTrue(subscription_request.getDestinationSectionTitle() in \ self.assertIn(subscription_request.getDestinationSectionTitle(), \
mail_message.getTextContent()) mail_message.getTextContent())
def checkEmailPaymentNotification(self, subscription_request, def checkEmailPaymentNotification(self, subscription_request,
...@@ -984,9 +984,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -984,9 +984,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
mail_message.getTitle()) mail_message.getTitle())
invoice = subscription_request.SubscriptionRequest_verifyPaymentBalanceIsReady() invoice = subscription_request.SubscriptionRequest_verifyPaymentBalanceIsReady()
self.assertEqual(invoice.getSimulationState(), 'stopped') self.assertEqual(invoice.getSimulationState(), 'stopped')
self.assertTrue(invoice.getRelativeUrl() in \ self.assertIn(invoice.getRelativeUrl(), \
mail_message.getTextContent()) mail_message.getTextContent())
self.assertTrue(subscription_request.getDestinationSectionTitle() in \ self.assertIn(subscription_request.getDestinationSectionTitle(), \
mail_message.getTextContent()) mail_message.getTextContent())
def checkEmailInstanceNotification(self, subscription_request, def checkEmailInstanceNotification(self, subscription_request,
...@@ -1002,9 +1002,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -1002,9 +1002,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
mail_message.getTitle()) mail_message.getTitle())
instance_tree = subscription_request.getAggregateValue() instance_tree = subscription_request.getAggregateValue()
self.assertEqual(instance_tree.getSlapState(), 'start_requested') self.assertEqual(instance_tree.getSlapState(), 'start_requested')
self.assertTrue(instance_tree.getRelativeUrl() in \ self.assertIn(instance_tree.getRelativeUrl(), \
mail_message.getTextContent()) mail_message.getTextContent())
self.assertTrue(subscription_request.getDestinationSectionTitle() in \ self.assertIn(subscription_request.getDestinationSectionTitle(), \
mail_message.getTextContent()) mail_message.getTextContent())
def checkRelatedInstance(self, subscription_request): def checkRelatedInstance(self, subscription_request):
......
...@@ -122,11 +122,11 @@ class TestSubscriptionCondition_renderKVMClusterParameter(TestSubscriptionSkinsM ...@@ -122,11 +122,11 @@ class TestSubscriptionCondition_renderKVMClusterParameter(TestSubscriptionSkinsM
"KVM0": { "KVM0": {
"cpu-count": 40, "cpu-count": 40,
"cpu-max-count": 41, "cpu-max-count": 41,
"ram-size": 245760, "disable-ansible-promise": true,
"ram-max-size": 245761,
"disk-device-path": "/dev/sdb", "disk-device-path": "/dev/sdb",
"project-guid": "PROJ-XXXX", "project-guid": "PROJ-XXXX",
"disable-ansible-promise": true "ram-max-size": 245761,
"ram-size": 245760
} }
} }
}</parameter> }</parameter>
...@@ -144,13 +144,13 @@ class TestSubscriptionCondition_renderKVMClusterParameter(TestSubscriptionSkinsM ...@@ -144,13 +144,13 @@ class TestSubscriptionCondition_renderKVMClusterParameter(TestSubscriptionSkinsM
<parameter id="_">{ <parameter id="_">{
"kvm-partition-dict": { "kvm-partition-dict": {
"KVM0": { "KVM0": {
"disable-ansible-promise": true, "cpu-count": 40,
"disk-device-path": "/dev/sdb", "cpu-max-count": 41,
"cpu-count": 40, "disable-ansible-promise": true,
"ram-max-size": 245761, "disk-device-path": "/dev/sdb",
"ram-size": 245760, "project-guid": "PROJ-XXXX",
"project-guid": "PROJ-XXXX", "ram-max-size": 245761,
"cpu-max-count": 41, "ram-size": 245760,
"sticky-computer": true "sticky-computer": true
} }
} }
...@@ -163,23 +163,23 @@ class TestSubscriptionCondition_renderKVMClusterParameter(TestSubscriptionSkinsM ...@@ -163,23 +163,23 @@ class TestSubscriptionCondition_renderKVMClusterParameter(TestSubscriptionSkinsM
<parameter id="_">{ <parameter id="_">{
"kvm-partition-dict": { "kvm-partition-dict": {
"KVM0": { "KVM0": {
"disable-ansible-promise": true, "cpu-count": 40,
"disk-device-path": "/dev/sdb", "cpu-max-count": 41,
"cpu-count": 40, "disable-ansible-promise": true,
"ram-max-size": 245761, "disk-device-path": "/dev/sdb",
"ram-size": 245760, "project-guid": "PROJ-XXXX",
"project-guid": "PROJ-XXXX", "ram-max-size": 245761,
"cpu-max-count": 41, "ram-size": 245760,
"sticky-computer": true "sticky-computer": true
}, },
"KVM1": { "KVM1": {
"disk-device-path": "/dev/sdb", "cpu-count": 40,
"cpu-count": 40, "cpu-max-count": 41,
"ram-max-size": 245761, "disable-ansible-promise": true,
"cpu-max-count": 41, "disk-device-path": "/dev/sdb",
"disable-ansible-promise": true, "project-guid": "PROJ-XXXX",
"ram-size": 245760, "ram-max-size": 245761,
"project-guid": "PROJ-XXXX" "ram-size": 245760
} }
} }
}</parameter> }</parameter>
......
...@@ -664,7 +664,7 @@ class RunPromise(GenericPromise): ...@@ -664,7 +664,7 @@ class RunPromise(GenericPromise):
def test_method(result): def test_method(result):
self.assertTrue(isinstance(result, PromiseQueueResult)) self.assertTrue(isinstance(result, PromiseQueueResult))
self.assertTrue(isinstance(result.item, TestResult)) self.assertTrue(isinstance(result.item, TestResult))
self.assertTrue(result.name in [promise_failed, promise_name]) self.assertIn(result.name, [promise_failed, promise_name])
if result.name == promise_failed: if result.name == promise_failed:
self.assertEqual(result.item.hasFailed(), True) self.assertEqual(result.item.hasFailed(), True)
self.assertEqual(result.item.message, "failed") self.assertEqual(result.item.message, "failed")
...@@ -705,7 +705,7 @@ class RunPromise(GenericPromise): ...@@ -705,7 +705,7 @@ class RunPromise(GenericPromise):
def test_method(result): def test_method(result):
self.assertTrue(isinstance(result, PromiseQueueResult)) self.assertTrue(isinstance(result, PromiseQueueResult))
self.assertTrue(isinstance(result.item, TestResult)) self.assertTrue(isinstance(result.item, TestResult))
self.assertTrue(result.name in [first_promise, second_promise, third_promise]) self.assertIn(result.name, [first_promise, second_promise, third_promise])
self.assertEqual(result.item.hasFailed(), False) self.assertEqual(result.item.hasFailed(), False)
self.assertEqual(result.item.message, "success") self.assertEqual(result.item.message, "success")
self.counter += 1 self.counter += 1
...@@ -771,7 +771,7 @@ class RunPromise(GenericPromise): ...@@ -771,7 +771,7 @@ class RunPromise(GenericPromise):
self.counter = 0 self.counter = 0
def test_method_first(result): def test_method_first(result):
self.assertTrue(result.name in [first_promise, second_promise]) self.assertIn(result.name, [first_promise, second_promise])
self.assertEqual(result.item.hasFailed(), False) self.assertEqual(result.item.hasFailed(), False)
self.assertEqual(result.item.message, "success") self.assertEqual(result.item.message, "success")
self.counter += 1 self.counter += 1
...@@ -809,7 +809,7 @@ class RunPromise(GenericPromise): ...@@ -809,7 +809,7 @@ class RunPromise(GenericPromise):
self.counter = 0 self.counter = 0
def test_method(result): def test_method(result):
self.assertTrue(result.name in [first_promise, second_promise]) self.assertIn(result.name, [first_promise, second_promise])
self.assertEqual(result.item.hasFailed(), False) self.assertEqual(result.item.hasFailed(), False)
self.assertEqual(result.item.message, "success") self.assertEqual(result.item.message, "success")
self.counter += 1 self.counter += 1
...@@ -956,7 +956,7 @@ class RunPromise(GenericPromise): ...@@ -956,7 +956,7 @@ class RunPromise(GenericPromise):
self.counter = 0 self.counter = 0
def test_method(result): def test_method(result):
self.assertTrue(result.name in [first_promise, second_promise]) self.assertIn(result.name, [first_promise, second_promise])
self.assertEqual(result.item.hasFailed(), False) self.assertEqual(result.item.hasFailed(), False)
self.assertEqual(result.item.message, "success") self.assertEqual(result.item.message, "success")
self.counter += 1 self.counter += 1
...@@ -1082,7 +1082,7 @@ exit 0 ...@@ -1082,7 +1082,7 @@ exit 0
self.counter = 0 self.counter = 0
self.check_list = [first_promise, second_promise, third_promise] self.check_list = [first_promise, second_promise, third_promise]
def test_method(result): def test_method(result):
self.assertTrue(result.name in self.check_list) self.assertIn(result.name, self.check_list)
self.assertEqual(result.item.hasFailed(), False) self.assertEqual(result.item.hasFailed(), False)
self.assertEqual(result.item.message, "success") self.assertEqual(result.item.message, "success")
self.counter += 1 self.counter += 1
...@@ -1110,7 +1110,7 @@ exit 0 ...@@ -1110,7 +1110,7 @@ exit 0
self.counter = 0 self.counter = 0
self.check_list = [first_promise, second_promise, third_promise] self.check_list = [first_promise, second_promise, third_promise]
def test_method(result): def test_method(result):
self.assertTrue(result.name in self.check_list) self.assertIn(result.name, self.check_list)
self.assertEqual(result.item.hasFailed(), False) self.assertEqual(result.item.hasFailed(), False)
self.assertEqual(result.item.message, "success") self.assertEqual(result.item.message, "success")
self.counter += 1 self.counter += 1
...@@ -1186,7 +1186,7 @@ exit 0 ...@@ -1186,7 +1186,7 @@ exit 0
self.assertTrue(result.execution_time >= 1) self.assertTrue(result.execution_time >= 1)
self.assertEqual(result.title, 'my_promise') self.assertEqual(result.title, 'my_promise')
self.assertEqual(result.name, promise_name) self.assertEqual(result.name, promise_name)
self.assertTrue("Promise timed out after" in result.item.message) self.assertIn("Promise timed out after", result.item.message)
self.assertEqual(result.item.hasFailed(), True) self.assertEqual(result.item.hasFailed(), True)
self.configureLauncher(save_method=test_method, enable_anomaly=True, timeout=1) self.configureLauncher(save_method=test_method, enable_anomaly=True, timeout=1)
...@@ -1218,7 +1218,7 @@ echo "success" ...@@ -1218,7 +1218,7 @@ echo "success"
self.assertEqual(result.title, promise_name) self.assertEqual(result.title, promise_name)
self.assertEqual(result.name, promise_name) self.assertEqual(result.name, promise_name)
self.assertEqual(result.path, promise_path) self.assertEqual(result.path, promise_path)
self.assertTrue("Promise timed out after" in result.item.message) self.assertIn("Promise timed out after", result.item.message)
self.assertEqual(result.item.hasFailed(), True) self.assertEqual(result.item.hasFailed(), True)
self.assertTrue(isinstance(result.item.date, datetime)) self.assertTrue(isinstance(result.item.date, datetime))
......
...@@ -2392,7 +2392,7 @@ class TestSlapgridCPWithMasterPromise(MasterMixin, unittest.TestCase): ...@@ -2392,7 +2392,7 @@ class TestSlapgridCPWithMasterPromise(MasterMixin, unittest.TestCase):
log_file = '%s/.slapgrid/log/instance.log' % instance.partition_path log_file = '%s/.slapgrid/log/instance.log' % instance.partition_path
with open(log_file) as f: with open(log_file) as f:
self.assertTrue('Error Promise 254554802' in f.read()) self.assertIn('Error Promise 254554802', f.read())
self.assertTrue(instance.error) self.assertTrue(instance.error)
self.assertIsNone(instance.state) self.assertIsNone(instance.state)
...@@ -3135,7 +3135,7 @@ exit 0 ...@@ -3135,7 +3135,7 @@ exit 0
self._wait_prerm_script_finished(partition.partition_path) self._wait_prerm_script_finished(partition.partition_path)
with open(os.path.join(partition.partition_path, '.0-prerm_slapos_pre_delete.log')) as f: with open(os.path.join(partition.partition_path, '.0-prerm_slapos_pre_delete.log')) as f:
# the script is well finished... # the script is well finished...
self.assertTrue("finished prerm script." in f.read()) self.assertIn("finished prerm script.", f.read())
self.assertEqual(self.grid.agregateAndSendUsage(), slapgrid.SLAPGRID_SUCCESS) self.assertEqual(self.grid.agregateAndSendUsage(), slapgrid.SLAPGRID_SUCCESS)
# Assert partition directory is empty # Assert partition directory is empty
......
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