Commit 1a93df24 authored by Łukasz Nowak's avatar Łukasz Nowak

Avoid code repetition.

A lot of new tests are coming which will use same functionality.
parent a432d344
...@@ -6,26 +6,6 @@ from Products.ERP5Type.tests.utils import createZODBPythonScript ...@@ -6,26 +6,6 @@ from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestSlapOSAllocation(testSlapOSMixin): class TestSlapOSAllocation(testSlapOSMixin):
def generateNewId(self):
return self.getPortalObject().portal_ids.generateNewId(
id_group=('slapos_core_test'))
def generateNewSoftwareReleaseUrl(self):
return 'http://example.org/test%s.cfg' % self.generateNewId()
def generateNewSoftwareType(self):
return 'Type%s' % self.generateNewId()
def generateNewSoftwareTitle(self):
return 'Title%s' % self.generateNewId()
def generateSafeXml(self):
return '<?xml version="1.0" encoding="utf-8"?><instance><parameter '\
'id="param">%s</parameter></instance>' % self.generateNewId()
def generateEmptyXml(self):
return '<?xml version="1.0" encoding="utf-8"?><instance></instance>'
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSAllocation, self).afterSetUp() super(TestSlapOSAllocation, self).afterSetUp()
portal = self.getPortalObject() portal = self.getPortalObject()
......
...@@ -7,13 +7,6 @@ from Products.ERP5Type.Errors import UnsupportedWorkflowMethod ...@@ -7,13 +7,6 @@ from Products.ERP5Type.Errors import UnsupportedWorkflowMethod
class TestSlapOSCorePersonComputerSupply(testSlapOSMixin): class TestSlapOSCorePersonComputerSupply(testSlapOSMixin):
def generateNewId(self):
return self.getPortalObject().portal_ids.generateNewId(
id_group=('slapos_core_test'))
def generateNewSoftwareReleaseUrl(self):
return 'http://example.org/test%s.cfg' % self.generateNewId()
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSCorePersonComputerSupply, self).afterSetUp() super(TestSlapOSCorePersonComputerSupply, self).afterSetUp()
portal = self.getPortalObject() portal = self.getPortalObject()
......
...@@ -6,13 +6,6 @@ from Products.ERP5Type.tests.backportUnittest import expectedFailure ...@@ -6,13 +6,6 @@ from Products.ERP5Type.tests.backportUnittest import expectedFailure
class TestSlapOSCorePersonRequest(testSlapOSMixin): class TestSlapOSCorePersonRequest(testSlapOSMixin):
def generateNewId(self):
return self.getPortalObject().portal_ids.generateNewId(
id_group=('slapos_core_test'))
def generateNewSoftwareReleaseUrl(self):
return 'http://example.org/test%s.cfg' % self.generateNewId()
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSCorePersonRequest, self).afterSetUp() super(TestSlapOSCorePersonRequest, self).afterSetUp()
portal = self.getPortalObject() portal = self.getPortalObject()
......
...@@ -7,10 +7,6 @@ from AccessControl.SecurityManagement import getSecurityManager, \ ...@@ -7,10 +7,6 @@ from AccessControl.SecurityManagement import getSecurityManager, \
class TestSlapOSCorePersonRequestComputer(testSlapOSMixin): class TestSlapOSCorePersonRequestComputer(testSlapOSMixin):
def generateNewId(self):
return self.getPortalObject().portal_ids.generateNewId(
id_group=('slapos_core_test'))
def generateNewComputerTitle(self): def generateNewComputerTitle(self):
return 'My Comp %s' % self.generateNewId() return 'My Comp %s' % self.generateNewId()
......
...@@ -7,23 +7,6 @@ from Products.ERP5Type.tests.backportUnittest import expectedFailure ...@@ -7,23 +7,6 @@ from Products.ERP5Type.tests.backportUnittest import expectedFailure
class TestSlapOSCoreSoftwareInstanceRequest(testSlapOSMixin): class TestSlapOSCoreSoftwareInstanceRequest(testSlapOSMixin):
def generateNewId(self):
return self.getPortalObject().portal_ids.generateNewId(
id_group=('slapos_core_test'))
def generateNewSoftwareReleaseUrl(self):
return 'http://example.org/test%s.cfg' % self.generateNewId()
def generateNewSoftwareType(self):
return 'Type%s' % self.generateNewId()
def generateNewSoftwareTitle(self):
return 'Title%s' % self.generateNewId()
def generateSafeXml(self):
return '<?xml version="1.0" encoding="utf-8"?><instance><parameter '\
'id="param">%s</parameter></instance>' % self.generateNewId()
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSCoreSoftwareInstanceRequest, self).afterSetUp() super(TestSlapOSCoreSoftwareInstanceRequest, self).afterSetUp()
portal = self.getPortalObject() portal = self.getPortalObject()
......
146 147
\ No newline at end of file \ No newline at end of file
...@@ -32,23 +32,6 @@ class Simulator: ...@@ -32,23 +32,6 @@ class Simulator:
open(self.outfile, 'w').write(repr(l)) open(self.outfile, 'w').write(repr(l))
class TestSlapOSSlapToolMixin(testSlapOSMixin): class TestSlapOSSlapToolMixin(testSlapOSMixin):
def generateNewId(self):
return self.portal.portal_ids.generateNewId(
id_group=('slapos_core_test'))
def generateNewSoftwareReleaseUrl(self):
return 'http://example.org/test%s.cfg' % self.generateNewId()
def generateNewSoftwareType(self):
return 'Type%s' % self.generateNewId()
def generateNewSoftwareTitle(self):
return 'Title%s' % self.generateNewId()
def generateSafeXml(self):
return '<?xml version="1.0" encoding="utf-8"?><instance><parameter '\
'id="param">%s</parameter></instance>' % self.generateNewId()
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSSlapToolMixin, self).afterSetUp() super(TestSlapOSSlapToolMixin, self).afterSetUp()
self.portal_slap = self.portal.portal_slap self.portal_slap = self.portal.portal_slap
......
8 9
\ No newline at end of file \ No newline at end of file
...@@ -315,6 +315,26 @@ class testSlapOSMixin(Products.Vifib.tests.VifibMixin.testVifibMixin): ...@@ -315,6 +315,26 @@ class testSlapOSMixin(Products.Vifib.tests.VifibMixin.testVifibMixin):
self.portal.REQUEST['request_instance'] = None self.portal.REQUEST['request_instance'] = None
self.portal.REQUEST.headers = {} self.portal.REQUEST.headers = {}
def generateNewId(self):
return self.portal.portal_ids.generateNewId(
id_group=('slapos_core_test'))
def generateNewSoftwareReleaseUrl(self):
return 'http://example.org/test%s.cfg' % self.generateNewId()
def generateNewSoftwareType(self):
return 'Type%s' % self.generateNewId()
def generateNewSoftwareTitle(self):
return 'Title%s' % self.generateNewId()
def generateSafeXml(self):
return '<?xml version="1.0" encoding="utf-8"?><instance><parameter '\
'id="param">%s</parameter></instance>' % self.generateNewId()
def generateEmptyXml(self):
return '<?xml version="1.0" encoding="utf-8"?><instance></instance>'
class TestSlapOSDummy(testSlapOSMixin): class TestSlapOSDummy(testSlapOSMixin):
run_all_test = 1 run_all_test = 1
def test(self): def test(self):
......
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