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