Commit 5d8fc4dd authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud/SlapOSTestCaseMixin: Make API more reusable for other tests

This prevents re-declaration to set a diferent default.definition
parent 9ef501cf
# -*- coding:utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2002-2018 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2018 Nexedi SA and Contributors. All Rights Reserved.
...@@ -82,11 +83,11 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -82,11 +83,11 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
def afterSetUp(self): def afterSetUp(self):
testSlapOSMixin.afterSetUp(self) testSlapOSMixin.afterSetUp(self)
self.new_id = self.generateNewId() self.new_id = self.generateNewId()
instance_template = self.portal.software_instance_module.template_software_instance instance_template = self.portal.software_instance_module.template_software_instance
if len(instance_template.objectValues()): if len(instance_template.objectValues()):
instance_template.manage_delObjects( instance_template.manage_delObjects(
ids=[i.getId() for i in instance_template.objectValues()]) ids=[i.getId() for i in instance_template.objectValues()])
def makePerson(self, new_id=None, index=True, user=True): def makePerson(self, new_id=None, index=True, user=True):
...@@ -188,7 +189,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -188,7 +189,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
self.requested_software_instance.validate() self.requested_software_instance.validate()
self.tic() self.tic()
def _makeComputer(self, owner=None): def _makeComputer(self, owner=None, allocation_scope=None):
self.computer = self.portal.computer_module.template_computer\ self.computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1) .Base_createCloneDocument(batch_mode=1)
reference = 'TESTCOMP-%s' % self.generateNewId() reference = 'TESTCOMP-%s' % self.generateNewId()
...@@ -215,6 +216,9 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -215,6 +216,9 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
self.computer.edit( self.computer.edit(
source_administration_value=owner, source_administration_value=owner,
) )
if allocation_scope is not None:
self.computer.edit(allocation_scope = allocation_scope)
return self.computer, self.partition return self.computer, self.partition
def _makeComputerNetwork(self): def _makeComputerNetwork(self):
...@@ -421,7 +425,9 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -421,7 +425,9 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
self.tic() self.tic()
self._cleaupREQUEST() self._cleaupREQUEST()
def _makeSoftwareProduct(self, new_id): def _makeSoftwareProduct(self, new_id=None):
if new_id is None:
new_id = self.generateNewId()
software_product = self.portal.software_product_module\ software_product = self.portal.software_product_module\
.template_software_product.Base_createCloneDocument(batch_mode=1) .template_software_product.Base_createCloneDocument(batch_mode=1)
software_product.edit( software_product.edit(
...@@ -431,7 +437,10 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -431,7 +437,10 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
software_product.publish() software_product.publish()
return software_product return software_product
def _makeSoftwareRelease(self, new_id): def _makeSoftwareRelease(self, new_id=None):
if new_id is None:
new_id = self.generateNewId()
software_release = self.portal.software_release_module\ software_release = self.portal.software_release_module\
.template_software_release.Base_createCloneDocument(batch_mode=1) .template_software_release.Base_createCloneDocument(batch_mode=1)
software_release.edit( software_release.edit(
...@@ -441,6 +450,15 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -441,6 +450,15 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
) )
software_release.release() software_release.release()
return software_release return software_release
def _makeCustomSoftwareRelease(self, software_product_url, software_url):
software_release = self._makeSoftwareRelease()
software_release.edit(
aggregate_value=software_product_url,
url_string=software_url
)
software_release.publish()
return software_release
def generateNewSoftwareReleaseUrl(self): def generateNewSoftwareReleaseUrl(self):
return 'http://example.org/têst%s.cfg' % self.generateNewId() return 'http://example.org/têst%s.cfg' % self.generateNewId()
......
...@@ -45,13 +45,7 @@ ...@@ -45,13 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W:441, 0: Cannot decode using encoding "ascii", unexpected byte at position 32 (invalid-encoded-data)</string>
<string>W:444, 0: Cannot decode using encoding "ascii", unexpected byte at position 17 (invalid-encoded-data)</string>
<string>W:447, 0: Cannot decode using encoding "ascii", unexpected byte at position 18 (invalid-encoded-data)</string>
<string>W:452, 0: Cannot decode using encoding "ascii", unexpected byte at position 13 (invalid-encoded-data)</string>
<string>W:463, 0: Cannot decode using encoding "ascii", unexpected byte at position 14 (invalid-encoded-data)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
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