Commit 31c04abe authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Fixup Tests

parent eabd7e10
Pipeline #19299 failed with stage
in 0 seconds
...@@ -38,9 +38,17 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort): ...@@ -38,9 +38,17 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort):
maxDiff = None maxDiff = None
def afterSetUp(self): def afterSetUp(self):
SlapOSTestCaseMixinWithAbort.afterSetUp(self) SlapOSTestCaseMixinWithAbort.afterSetUp(self)
self.created_at = rfc1123_date(DateTime()) d = DateTime()
self.pinDateTime(d)
self.created_at = rfc1123_date(d)
self.changeSkin('Hal') self.changeSkin('Hal')
def beforeTearDown(self):
SlapOSTestCaseMixinWithAbort.beforeTearDown(self)
self.unpinDateTime()
def _logFakeAccess(self, reference, text="#access OK", state='start_requested'): def _logFakeAccess(self, reference, text="#access OK", state='start_requested'):
value = json.dumps({ value = json.dumps({
'user': 'SlapOS Master', 'user': 'SlapOS Master',
...@@ -71,8 +79,8 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort): ...@@ -71,8 +79,8 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort):
.template_software_instance.Base_createCloneDocument(batch_mode=1) .template_software_instance.Base_createCloneDocument(batch_mode=1)
instance.edit(reference="TESTSOFTINST-%s" % instance.getId()) instance.edit(reference="TESTSOFTINST-%s" % instance.getId())
instance.validate() instance.validate()
self.changeSkin('Hal')
self.tic() self.tic()
self.changeSkin('Hal')
return instance return instance
def _makeSlaveInstance(self): def _makeSlaveInstance(self):
...@@ -80,6 +88,7 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort): ...@@ -80,6 +88,7 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort):
.template_slave_instance.Base_createCloneDocument(batch_mode=1) .template_slave_instance.Base_createCloneDocument(batch_mode=1)
instance.validate() instance.validate()
self.tic() self.tic()
self.changeSkin('Hal')
return instance return instance
def _makeComputeNode(self, owner=None, allocation_scope='open/public'): def _makeComputeNode(self, owner=None, allocation_scope='open/public'):
...@@ -179,7 +188,10 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -179,7 +188,10 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
self.tic() self.tic()
self.changeSkin('Hal') self.changeSkin('Hal')
news_dict = instance_tree.InstanceTree_getNewsDict() news_dict = instance_tree.InstanceTree_getNewsDict()
expected_news_dict = {'instance': [{'no_data': 1, expected_news_dict = {'instance': [{'created_at': self.created_at,
'no_data': 1,
'since': self.created_at,
'state': '',
'text': '#error no data found for %s' % instance.getReference(), 'text': '#error no data found for %s' % instance.getReference(),
'user': 'SlapOS Master'}]} 'user': 'SlapOS Master'}]}
self.assertEqual(news_dict, expected_news_dict) self.assertEqual(news_dict, expected_news_dict)
...@@ -208,12 +220,18 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -208,12 +220,18 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
self.tic() self.tic()
self.changeSkin('Hal') self.changeSkin('Hal')
news_dict = instance_tree.InstanceTree_getNewsDict() news_dict = instance_tree.InstanceTree_getNewsDict()
expected_news_dict = {'instance': [{'no_data': 1, expected_news_dict = {'instance': [{'created_at': self.created_at,
'no_data': 1,
'since': self.created_at,
'state': '',
'text': '#error no data found for %s' % instance0.getReference(), 'text': '#error no data found for %s' % instance0.getReference(),
'user': 'SlapOS Master'}, 'user': 'SlapOS Master'},
{'no_data': 1, {'created_at': self.created_at,
'text': '#error no data found for %s' % instance.getReference(), 'no_data': 1,
'user': 'SlapOS Master'}]} 'since': self.created_at,
'state': '',
'text': '#error no data found for %s' % instance.getReference(),
'user': 'SlapOS Master'}]}
self.assertEqual(news_dict["instance"], expected_news_dict["instance"]) self.assertEqual(news_dict["instance"], expected_news_dict["instance"])
# Ensure it don't raise error when converting to JSON # Ensure it don't raise error when converting to JSON
json.dumps(news_dict) json.dumps(news_dict)
...@@ -224,13 +242,13 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -224,13 +242,13 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
instance = self._makeInstance() instance = self._makeInstance()
self._logFakeAccess(instance.getReference()) self._logFakeAccess(instance.getReference())
news_dict = instance.SoftwareInstance_getNewsDict() news_dict = instance.SoftwareInstance_getNewsDict()
expected_news_dict = {u'created_at': self.created_at, expected_news_dict = {'created_at': self.created_at,
'no_data_since_15_minutes': 0, 'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0, 'no_data_since_5_minutes': 0,
'since': self.created_at, 'since': self.created_at,
'state': 'start_requested', 'state': 'start_requested',
'text': u'#access OK', 'text': '#access OK',
u'user': u'SlapOS Master'} 'user': 'SlapOS Master'}
self.assertEqual(news_dict, expected_news_dict) self.assertEqual(news_dict, expected_news_dict)
# Ensure it don't raise error when converting to JSON # Ensure it don't raise error when converting to JSON
json.dumps(news_dict) json.dumps(news_dict)
...@@ -238,6 +256,8 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -238,6 +256,8 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
def test_no_data(self): def test_no_data(self):
instance = self._makeInstance() instance = self._makeInstance()
self.changeSkin('Hal')
news_dict = instance.SoftwareInstance_getNewsDict() news_dict = instance.SoftwareInstance_getNewsDict()
expected_news_dict = {'created_at': self.created_at, expected_news_dict = {'created_at': self.created_at,
'no_data': 1, 'no_data': 1,
...@@ -291,13 +311,13 @@ class TestSoftwareInstallation_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -291,13 +311,13 @@ class TestSoftwareInstallation_getNewsDict(TestSlapOSHalJsonStyleMixin):
installation = self._makeSoftwareInstallation() installation = self._makeSoftwareInstallation()
self._logFakeAccess(installation.getReference()) self._logFakeAccess(installation.getReference())
news_dict = installation.SoftwareInstallation_getNewsDict() news_dict = installation.SoftwareInstallation_getNewsDict()
expected_news_dict = {u'created_at': self.created_at, expected_news_dict = {'created_at': self.created_at,
'no_data_since_15_minutes': 0, 'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0, 'no_data_since_5_minutes': 0,
'since': self.created_at, 'since': self.created_at,
'state': 'start_requested', 'state': 'start_requested',
'text': u'#access OK', 'text': '#access OK',
u'user': u'SlapOS Master'} 'user': 'SlapOS Master'}
self.assertEqual(news_dict, expected_news_dict) self.assertEqual(news_dict, expected_news_dict)
# Ensure it don't raise error when converting to JSON # Ensure it don't raise error when converting to JSON
json.dumps(news_dict) json.dumps(news_dict)
...@@ -309,13 +329,13 @@ class TestSoftwareInstallation_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -309,13 +329,13 @@ class TestSoftwareInstallation_getNewsDict(TestSlapOSHalJsonStyleMixin):
news_dict = installation.SoftwareInstallation_getNewsDict() news_dict = installation.SoftwareInstallation_getNewsDict()
installation.getSlapState = fakeStopRequestedSlapState installation.getSlapState = fakeStopRequestedSlapState
expected_news_dict = {u'created_at': self.created_at, expected_news_dict = {'created_at': self.created_at,
'no_data_since_15_minutes': 0, 'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0, 'no_data_since_5_minutes': 0,
'since': self.created_at, 'since': self.created_at,
'state': 'stop_requested', 'state': 'stop_requested',
'text': u'#access OK', 'text': '#access OK',
u'user': u'SlapOS Master'} 'user': 'SlapOS Master'}
self.assertEqual(news_dict, expected_news_dict) self.assertEqual(news_dict, expected_news_dict)
# Ensure it don't raise error when converting to JSON # Ensure it don't raise error when converting to JSON
json.dumps(news_dict) json.dumps(news_dict)
...@@ -327,13 +347,13 @@ class TestSoftwareInstallation_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -327,13 +347,13 @@ class TestSoftwareInstallation_getNewsDict(TestSlapOSHalJsonStyleMixin):
news_dict = installation.SoftwareInstallation_getNewsDict() news_dict = installation.SoftwareInstallation_getNewsDict()
installation.getSlapState = fakeDestroyRequestedSlapState installation.getSlapState = fakeDestroyRequestedSlapState
expected_news_dict = {u'created_at': self.created_at, expected_news_dict = {'created_at': self.created_at,
'no_data_since_15_minutes': 0, 'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0, 'no_data_since_5_minutes': 0,
'since': self.created_at, 'since': self.created_at,
'state': 'destroy_requested', 'state': 'destroy_requested',
'text': u'#access OK', 'text': '#access OK',
u'user': u'SlapOS Master'} 'user': 'SlapOS Master'}
self.assertEqual(news_dict, expected_news_dict) self.assertEqual(news_dict, expected_news_dict)
# Ensure it don't raise error when converting to JSON # Ensure it don't raise error when converting to JSON
json.dumps(news_dict) json.dumps(news_dict)
...@@ -358,13 +378,13 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -358,13 +378,13 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
self._logFakeAccess(compute_node.getReference()) self._logFakeAccess(compute_node.getReference())
news_dict = compute_node.ComputeNode_getNewsDict() news_dict = compute_node.ComputeNode_getNewsDict()
expected_news_dict = {'compute_node': expected_news_dict = {'compute_node':
{u'created_at': self.created_at, {'created_at': self.created_at,
'no_data_since_15_minutes': 0, 'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0, 'no_data_since_5_minutes': 0,
'since': self.created_at, 'since': self.created_at,
'state': 'start_requested', 'state': 'start_requested',
'text': u'#access OK', 'text': '#access OK',
u'user': u'SlapOS Master'}, 'user': 'SlapOS Master'},
'partition': {} 'partition': {}
} }
self.assertEqual(news_dict, expected_news_dict) self.assertEqual(news_dict, expected_news_dict)
...@@ -405,8 +425,8 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -405,8 +425,8 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
'no_data_since_5_minutes': 0, 'no_data_since_5_minutes': 0,
'since': self.created_at, 'since': self.created_at,
'state': 'destroy_requested', 'state': 'destroy_requested',
'text': u'#access OK', 'text': '#access OK',
'user': u'SlapOS Master'}, 'user': 'SlapOS Master'},
'partition': {} 'partition': {}
} }
self.assertEqual(news_dict, expected_news_dict) self.assertEqual(news_dict, expected_news_dict)
...@@ -438,14 +458,17 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -438,14 +458,17 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
self._logFakeAccess(compute_node.getReference()) self._logFakeAccess(compute_node.getReference())
news_dict = compute_node.ComputeNode_getNewsDict() news_dict = compute_node.ComputeNode_getNewsDict()
expected_news_dict = {'compute_node': expected_news_dict = {'compute_node':
{'created_at': self.created_at, {u'created_at': u'%s' % self.created_at,
'no_data_since_15_minutes': 0, 'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0, 'no_data_since_5_minutes': 0,
'since': self.created_at, u'since': u'%s' % self.created_at,
'state': 'start_requested', u'state': u'start_requested',
'text': '#access OK', u'text': u'#access OK',
'user': 'SlapOS Master'}, u'user': u'SlapOS Master'},
'partition': {'slappart0': {'no_data': 1, 'partition': {'slappart0': {'created_at': self.created_at,
'no_data': 1,
'since': self.created_at,
'state': '',
'text': '#error no data found for %s' % (instance.getReference()), 'text': '#error no data found for %s' % (instance.getReference()),
'user': 'SlapOS Master'}} 'user': 'SlapOS Master'}}
} }
...@@ -467,22 +490,25 @@ class TestComputerNetwork_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -467,22 +490,25 @@ class TestComputerNetwork_getNewsDict(TestSlapOSHalJsonStyleMixin):
news_dict = network.ComputerNetwork_getNewsDict() news_dict = network.ComputerNetwork_getNewsDict()
expected_news_dict = {'compute_node': expected_news_dict = {'compute_node':
{ compute_node.getReference(): { compute_node.getReference():
{'created_at': self.created_at, {u'created_at': u'%s' % self.created_at,
'no_data_since_15_minutes': 0, 'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0, 'no_data_since_5_minutes': 0,
'since': self.created_at, u'since': u'%s' % self.created_at,
'state': 'start_requested', u'state': u'start_requested',
'text': '#access OK', u'text': u'#access OK',
'user': 'SlapOS Master'} u'user': u'SlapOS Master'}},
}, 'partition':
'partition': { compute_node.getReference():
{ compute_node.getReference(): {'slappart0': {'created_at': self.created_at,
{'slappart0': {'no_data': 1, 'no_data': 1,
'text': '#error no data found for %s' % (instance.getReference()), 'since': self.created_at,
'user': 'SlapOS Master'} 'state': '',
'text': '#error no data found for %s' % (instance.getReference()),
'user': 'SlapOS Master'}
}
} }
} }
}
self.assertEqual(news_dict, expected_news_dict) self.assertEqual(news_dict, expected_news_dict)
# Ensure it don't raise error when converting to JSON # Ensure it don't raise error when converting to JSON
...@@ -513,22 +539,25 @@ class TestOrganisation_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -513,22 +539,25 @@ class TestOrganisation_getNewsDict(TestSlapOSHalJsonStyleMixin):
news_dict = organisation.Organisation_getNewsDict() news_dict = organisation.Organisation_getNewsDict()
expected_news_dict = {'compute_node': expected_news_dict = {'compute_node':
{ compute_node.getReference(): { compute_node.getReference():
{'created_at': self.created_at, {u'created_at': u'%s' % self.created_at,
'no_data_since_15_minutes': 0, 'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0, 'no_data_since_5_minutes': 0,
'since': self.created_at, u'since': u'%s' % self.created_at,
'state': 'start_requested', u'state': u'start_requested',
'text': '#access OK', u'text': u'#access OK',
'user': 'SlapOS Master'} u'user': u'SlapOS Master'}},
}, 'partition':
'partition': { compute_node.getReference():
{ compute_node.getReference(): {'slappart0': {'created_at': self.created_at,
{'slappart0': {'no_data': 1, 'no_data': 1,
'text': '#error no data found for %s' % (instance.getReference()), 'since': self.created_at,
'user': 'SlapOS Master'} 'state': '',
'text': '#error no data found for %s' % (instance.getReference()),
'user': 'SlapOS Master'}
}
} }
} }
}
self.assertEqual(news_dict, expected_news_dict) self.assertEqual(news_dict, expected_news_dict)
# Ensure it don't raise error when converting to JSON # Ensure it don't raise error when converting to JSON
...@@ -558,22 +587,25 @@ class TestProject_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -558,22 +587,25 @@ class TestProject_getNewsDict(TestSlapOSHalJsonStyleMixin):
news_dict = project.Project_getNewsDict() news_dict = project.Project_getNewsDict()
expected_news_dict = {'compute_node': expected_news_dict = {'compute_node':
{ compute_node.getReference(): { compute_node.getReference():
{'created_at': self.created_at, {u'created_at': u'%s' % self.created_at,
'no_data_since_15_minutes': 0, 'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0, 'no_data_since_5_minutes': 0,
'since': self.created_at, u'since': u'%s' % self.created_at,
'state': 'start_requested', u'state': u'start_requested',
'text': '#access OK', u'text': u'#access OK',
'user': 'SlapOS Master'} u'user': u'SlapOS Master'}},
}, 'partition':
'partition': { compute_node.getReference():
{ compute_node.getReference(): {'slappart0': {'created_at': self.created_at,
{'slappart0': {'no_data': 1, 'no_data': 1,
'text': '#error no data found for %s' % (instance.getReference()), 'since': self.created_at,
'user': 'SlapOS Master'} 'state': '',
'text': '#error no data found for %s' % (instance.getReference()),
'user': 'SlapOS Master'}
}
} }
} }
}
self.assertEqual(news_dict, expected_news_dict) self.assertEqual(news_dict, expected_news_dict)
# Ensure it don't raise error when converting to JSON # Ensure it don't raise error when converting to JSON
...@@ -1166,12 +1198,4 @@ class TestInstanceTree_edit(TestSlapOSHalJsonStyleMixin): ...@@ -1166,12 +1198,4 @@ class TestInstanceTree_edit(TestSlapOSHalJsonStyleMixin):
self.instance_tree.getTextContent()) self.instance_tree.getTextContent())
self.assertEqual(new_parameter, self.assertEqual(new_parameter,
self.instance_tree.getTextContent()) self.instance_tree.getTextContent())
\ 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