Commit 3a49e5b5 authored by Romain Courteaud's avatar Romain Courteaud

Move Computer Partition constraint

parent c1ad9a6a
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
<portal_type id="Computer"> <portal_type id="Computer">
<item>SlaposCapacity</item> <item>SlaposCapacity</item>
</portal_type> </portal_type>
<portal_type id="Computer Partition">
<item>SlaposComputerPartitionConstraint</item>
</portal_type>
<portal_type id="Hosting Subscription"> <portal_type id="Hosting Subscription">
<item>HostingSubscription</item> <item>HostingSubscription</item>
<item>SoftwareInstance</item> <item>SoftwareInstance</item>
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>VifibComputerPartitionConstraint</string> </value> <value> <string>SlaposComputerPartitionConstraint</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \ from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin testSlapOSMixin
import transaction
from Products.ERP5Type.tests.backportUnittest import expectedFailure
class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin): class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin):
def afterSetUp(self): def afterSetUp(self):
...@@ -18,21 +16,6 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin): ...@@ -18,21 +16,6 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin):
self.computer.validate() self.computer.validate()
self.tic() self.tic()
def _makePerson(self):
new_id = self.generateNewId()
self.person_user = self.portal.person_module.template_member.\
Base_createCloneDocument(batch_mode=1)
self.person_user.edit(
title="live_test_%s" % new_id,
reference="live_test_%s" % new_id,
default_email_text="live_test_%s@example.org" % new_id,
)
self.person_user.validate()
for assignment in self.person_user.contentValues(portal_type="Assignment"):
assignment.open()
self.tic()
def beforeTearDown(self): def beforeTearDown(self):
super(TestSlapOSCoreComputerSlapInterfaceWorkflow, self).beforeTearDown() super(TestSlapOSCoreComputerSlapInterfaceWorkflow, self).beforeTearDown()
self.portal.REQUEST['computer_key'] = None self.portal.REQUEST['computer_key'] = None
...@@ -61,16 +44,28 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin): ...@@ -61,16 +44,28 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin):
self.assertEqual(None, self.portal.REQUEST.get('computer_certificate')) self.assertEqual(None, self.portal.REQUEST.get('computer_certificate'))
def test_approveComputerRegistration(self): def test_approveComputerRegistration(self):
self._makePerson() # Clone person document
self.login(self.person_user.getReference())
new_id = self.generateNewId() new_id = self.generateNewId()
person_user = self.portal.person_module.template_member.\
Base_createCloneDocument(batch_mode=1)
person_user.edit(
title="live_test_%s" % new_id,
reference="live_test_%s" % new_id,
default_email_text="live_test_%s@example.org" % new_id,
)
person_user.validate()
for assignment in person_user.contentValues(portal_type="Assignment"):
assignment.open()
self.tic()
self.login(person_user.getReference())
computer = self.portal.computer_module.newContent(portal_type='Computer', computer = self.portal.computer_module.newContent(portal_type='Computer',
title="Computer %s for %s" % (new_id, self.person_user.getReference()), title="Computer %s for %s" % (new_id, person_user.getReference()),
reference="TESTCOMP-%s" % new_id) reference="TESTCOMP-%s" % new_id)
computer.requestComputerRegistration() computer.requestComputerRegistration()
computer.approveComputerRegistration() computer.approveComputerRegistration()
self.assertEqual('open/personal', computer.getAllocationScope()) self.assertEqual('open/personal', computer.getAllocationScope())
self.assertEqual(self.person_user.getRelativeUrl(), self.assertEqual(person_user.getRelativeUrl(),
computer.getSourceAdministration()) computer.getSourceAdministration())
self.assertEqual('validated', computer.getValidationState()) self.assertEqual('validated', computer.getValidationState())
...@@ -127,108 +122,3 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin): ...@@ -127,108 +122,3 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin):
self._countInstanceBang(destroyed_instance1, comment)) self._countInstanceBang(destroyed_instance1, comment))
self.assertEqual(destroyed_instance2_bang_count, self.assertEqual(destroyed_instance2_bang_count,
self._countInstanceBang(destroyed_instance2, comment)) self._countInstanceBang(destroyed_instance2, comment))
def test_requestSoftwareRelease_software_release_url_required(self):
self._makePerson()
self.computer.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getReference())
self.assertRaises(TypeError, self.computer.requestSoftwareRelease,
state='available')
transaction.abort()
def test_requestSoftwareRelease_state_required(self):
self._makePerson()
self.computer.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getReference())
url = self.generateNewSoftwareReleaseUrl()
self.assertRaises(TypeError, self.computer.requestSoftwareRelease,
software_release_url=url)
transaction.abort()
def test_requestSoftwareRelease_available(self):
self._makePerson()
self.computer.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getReference())
url = self.generateNewSoftwareReleaseUrl()
self.computer.requestSoftwareRelease(software_release_url=url,
state='available')
self.tic()
self.login()
software_installation = self.computer.getAggregateRelatedValue(
portal_type='Software Installation')
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual(url, software_installation.getUrlString())
self.assertEqual('validated', software_installation.getValidationState())
def test_requestSoftwareRelease_destroyed(self):
self._makePerson()
self.computer.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getReference())
url = self.generateNewSoftwareReleaseUrl()
self.computer.requestSoftwareRelease(software_release_url=url,
state='destroyed')
self.tic()
self.login()
software_installation = self.computer.getAggregateRelatedValue(
portal_type='Software Installation')
self.assertEqual(None, software_installation)
def test_requestSoftwareRelease_available_destroyed(self):
self._makePerson()
self.computer.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getReference())
url = self.generateNewSoftwareReleaseUrl()
self.computer.requestSoftwareRelease(software_release_url=url,
state='available')
self.tic()
self.login()
software_installation = self.computer.getAggregateRelatedValue(
portal_type='Software Installation')
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual(url, software_installation.getUrlString())
self.assertEqual('validated', software_installation.getValidationState())
self.login(self.person_user.getReference())
self.computer.requestSoftwareRelease(software_release_url=url,
state='destroyed')
self.tic()
self.login()
software_installation = self.computer.getAggregateRelatedValue(
portal_type='Software Installation')
self.assertEqual('destroy_requested', software_installation.getSlapState())
self.assertEqual(url, software_installation.getUrlString())
self.assertEqual('validated', software_installation.getValidationState())
def test_requestSoftwareRelease_not_indexed(self):
self._makePerson()
self.computer.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getReference())
url = self.generateNewSoftwareReleaseUrl()
self.computer.requestSoftwareRelease(software_release_url=url,
state='available')
transaction.commit()
self.assertRaises(NotImplementedError,
self.computer.requestSoftwareRelease, software_release_url=url,
state='available')
transaction.abort()
@expectedFailure
def test_requestSoftwareRelease_same_transaction(self):
self._makePerson()
self.computer.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getReference())
url = self.generateNewSoftwareReleaseUrl()
self.computer.requestSoftwareRelease(software_release_url=url,
state='available')
self.assertRaises(NotImplementedError,
self.computer.requestSoftwareRelease, software_release_url=url,
state='available')
transaction.abort()
161 162
\ No newline at end of file \ No newline at end of file
Assignment | SlaposAssignmentConstraint Assignment | SlaposAssignmentConstraint
Computer Partition | SlaposComputerPartitionConstraint
Computer | SlaposCapacity Computer | SlaposCapacity
Hosting Subscription | HostingSubscription Hosting Subscription | HostingSubscription
Hosting Subscription | SoftwareInstance Hosting Subscription | SoftwareInstance
......
SoftwareInstanceConstraint SoftwareInstanceConstraint
SlaposComputerPartitionConstraint
SlaveInstanceConstraint SlaveInstanceConstraint
SoftwareInstance SoftwareInstance
HostingSubscription HostingSubscription
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
<portal_type id="Computer"> <portal_type id="Computer">
<item>VifibComputerConstraint</item> <item>VifibComputerConstraint</item>
</portal_type> </portal_type>
<portal_type id="Computer Partition">
<item>VifibComputerPartitionConstraint</item>
</portal_type>
<portal_type id="Email"> <portal_type id="Email">
<item>VifibEmailConstraint</item> <item>VifibEmailConstraint</item>
</portal_type> </portal_type>
......
544 545
\ No newline at end of file \ No newline at end of file
Computer Partition | VifibComputerPartitionConstraint
Computer | VifibComputerConstraint Computer | VifibComputerConstraint
Email | VifibEmailConstraint Email | VifibEmailConstraint
Hosting Subscription | VifibHostingSubscriptionConstraint Hosting Subscription | VifibHostingSubscriptionConstraint
......
VifibPersonConstraint VifibPersonConstraint
VifibComputerPartitionConstraint
VifibEmailConstraint VifibEmailConstraint
VifibComputerConstraint VifibComputerConstraint
VifibInternalPackingListConstraint VifibInternalPackingListConstraint
......
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