Commit 25ec1d12 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Add test for SoftwareProduct_getSoftwareReleaseAsHateoas

parent 65cfd8d9
...@@ -259,7 +259,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template): ...@@ -259,7 +259,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_hal_json_style/SaleInvoiceTransaction_getRelatedPaymentTransactionIntegrationId', 'slapos_hal_json_style/SaleInvoiceTransaction_getRelatedPaymentTransactionIntegrationId',
'slapos_hal_json_style/SoftwareInstallation_getSoftwareReleaseInformation', 'slapos_hal_json_style/SoftwareInstallation_getSoftwareReleaseInformation',
'slapos_hal_json_style/SoftwareInstance_getReportedState', 'slapos_hal_json_style/SoftwareInstance_getReportedState',
'slapos_hal_json_style/SoftwareProduct_getSoftwareReleaseAsHateoas',
'slapos_hal_json_style/SoftwareRelease_requestInstanceTree', 'slapos_hal_json_style/SoftwareRelease_requestInstanceTree',
'slapos_hal_json_style/SoftwareRelease_requestSoftwareInstallation', 'slapos_hal_json_style/SoftwareRelease_requestSoftwareInstallation',
'slapos_hal_json_style/SupportRequest_close', 'slapos_hal_json_style/SupportRequest_close',
......
...@@ -1739,4 +1739,64 @@ class TestInstanceTree_getFastInputDict(TestSlapOSHalJsonStyleMixin): ...@@ -1739,4 +1739,64 @@ class TestInstanceTree_getFastInputDict(TestSlapOSHalJsonStyleMixin):
self.assertEqual({ self.assertEqual({
'enabled': True, 'enabled': True,
'sla_xml': '<parameter id="instance_guid">%s</parameter>' % software_instance.getReference() 'sla_xml': '<parameter id="instance_guid">%s</parameter>' % software_instance.getReference()
}, self.instance_tree.InstanceTree_getFastInputDict()) }, self.instance_tree.InstanceTree_getFastInputDict())
\ No newline at end of file
class TestSoftwareProduct_getSoftwareReleaseAsHateoas(TestSlapOSHalJsonStyleMixin):
@simulate('SoftwareProduct_getSortedSoftwareReleaseList',
'software_product_reference=None, software_release_url=None, strict=None', """
assert software_product_reference == 'fake'
assert software_release_url is None
assert strict is None
return context.REQUEST['test_software_release_list']""")
def test_product_reference(self):
sr = self._makeSoftwareRelease()
self.changeSkin('RJS')
self.portal.REQUEST['test_software_release_list'] = [sr]
self.assertEqual(
sr.getRelativeUrl(),
json.loads(
self.portal.SoftwareProduct_getSoftwareReleaseAsHateoas("product.fake"))
)
@simulate('SoftwareProduct_getSortedSoftwareReleaseList',
'software_product_reference=None, software_release_url=None, strict=None', """
assert software_product_reference is None
assert software_release_url == 'fake'
assert strict is False
return context.REQUEST['test_software_release_list']""")
def test_software_release(self):
sr = self._makeSoftwareRelease()
self.changeSkin('RJS')
self.portal.REQUEST['test_software_release_list'] = [sr]
self.assertEqual(
sr.getRelativeUrl(),
json.loads(
self.portal.SoftwareProduct_getSoftwareReleaseAsHateoas("fake"))
)
@simulate('SoftwareProduct_getSortedSoftwareReleaseList',
'software_product_reference=None, software_release_url=None, strict=None', """
assert software_product_reference is None
assert software_release_url == 'fake'
assert strict is True
return []""")
def test_software_release_not_found(self):
self.changeSkin('RJS')
self.assertEqual(
'',
json.loads(
self.portal.SoftwareProduct_getSoftwareReleaseAsHateoas("fake", True))
)
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