Commit acff838f authored by Łukasz Nowak's avatar Łukasz Nowak

Check that non instantiated SI does not raise.

parent de8bdf26
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
import unittest import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from slapos import slap
import random
class TestVifibSlapBug(TestVifibSlapWebServiceMixin): class TestVifibSlapBug(TestVifibSlapWebServiceMixin):
def test_bug_Person_request_more_then_one_instance(self): def test_bug_Person_request_more_then_one_instance(self):
...@@ -1076,6 +1078,53 @@ class TestVifibSlapBug(TestVifibSlapWebServiceMixin): ...@@ -1076,6 +1078,53 @@ class TestVifibSlapBug(TestVifibSlapWebServiceMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def stepSetRequestedStateStarted(self, sequence, **kw):
sequence['state'] = 'started'
def stepSetRequestedReferenceRandom(self, sequence, **kw):
sequence['requested_reference'] = str(random.random())
def test_request_start_non_instantiated_partition(self):
"""Prove that requesting start of non instantiated partition will not
result in any error"""
self.computer_partition_amount = 0
sequence_list = SequenceList()
sequence_string = self.prepare_published_software_release + \
self.prepare_formated_computer + """
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
SlapLoginTestVifibCustomer
SetRequestedStateStarted
SetRequestedReferenceRandom
PersonRequestSlapSoftwareInstance
Tic
SlapLogout
LoginDefaultUser
SetCurrentPersonSlapRequestedSoftwareInstance
SoftwareInstanceSaleOrderConfirmRaisesValueError
Logout
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstance
Tic
SlapLogout
LoginDefaultUser
SoftwareInstanceSaleOrderConfirmRaisesValueError
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapBug)) suite.addTest(unittest.makeSuite(TestVifibSlapBug))
......
...@@ -21,59 +21,10 @@ class TestVifibSlapOpenOrderRequest(TestVifibSlapWebServiceMixin): ...@@ -21,59 +21,10 @@ class TestVifibSlapOpenOrderRequest(TestVifibSlapWebServiceMixin):
partition_reference=sequence.get('requested_reference', partition_reference=sequence.get('requested_reference',
'requested_reference'), 'requested_reference'),
partition_parameter_kw=sequence.get('requested_parameter_dict', {}), partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
filter_kw=sequence.get('requested_filter_dict', {}) filter_kw=sequence.get('requested_filter_dict', {}),
state=sequence.get('requested_state')
) )
def stepPersonRequestSlapSoftwareInstance(self, sequence, **kw):
software_release = sequence['software_release_uri']
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
open_order = self.slap.registerOpenOrder()
requested_slap_computer_partition = open_order.request(
software_release=software_release,
software_type=sequence.get('software_type', 'software_type'),
partition_reference=sequence['requested_reference'],
partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
filter_kw=sequence.get('requested_filter_dict', {}))
sequence.edit(
requested_slap_computer_partition=requested_slap_computer_partition,
requested_computer_partition_reference=\
requested_slap_computer_partition.getId())
def stepSetCurrentPersonSlapRequestedSoftwareInstance(self, sequence, **kw):
software_instance_list = self.portal.portal_catalog(
portal_type=self.software_instance_portal_type,
title=sequence['requested_reference'])
self.assertEqual(1, len(software_instance_list))
software_instance = software_instance_list[0]
sequence.edit(
software_instance_uid=software_instance.getUid(),
software_instance_reference=software_instance.getReference(),
hosting_subscription_uid=software_instance.getAggregateRelatedValue(
portal_type='Sale Order Line').getAggregateValue(
portal_type='Hosting Subscription').getUid())
def stepSoftwareInstanceSaleOrderConfirmRaisesValueError(self, sequence,
**kw):
"""Checks that current software instance is realted only with sale order
and that this sale order cannot be confirmed
In Vifib implementation sale order which cannot find free computer partition
raises ValueError"""
software_instance = self.portal.portal_catalog.getResultValue(
uid=sequence['software_instance_uid'])
aggregate_value_list = software_instance.getAggregateRelatedValueList(portal_type=[self.sale_packing_list_line_portal_type, self.sale_order_line_portal_type])
self.assertEqual(1, len(aggregate_value_list))
self.assertTrue(self.sale_order_line_portal_type in [q.getPortalType() for\
q in aggregate_value_list])
sale_order_line = aggregate_value_list[0]
sale_order = sale_order_line.getParentValue()
self.assertRaises(ValueError, sale_order.confirm)
def test_person_request_ComputerPartition_filter_computer_guid(self): def test_person_request_ComputerPartition_filter_computer_guid(self):
"""Check that requesting with computer_guid in filter_kw works as """Check that requesting with computer_guid in filter_kw works as
expected in case of person request""" expected in case of person request"""
......
...@@ -178,6 +178,60 @@ class TestVifibSlapWebServiceMixin(testVifibMixin): ...@@ -178,6 +178,60 @@ class TestVifibSlapWebServiceMixin(testVifibMixin):
######################################## ########################################
# Steps -- scenarios # Steps -- scenarios
######################################## ########################################
def stepPersonRequestSlapSoftwareInstance(self, sequence, **kw):
software_release = sequence['software_release_uri']
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
open_order = self.slap.registerOpenOrder()
requested_slap_computer_partition = open_order.request(
software_release=software_release,
software_type=sequence.get('software_type', 'software_type'),
partition_reference=sequence.get('requested_reference',
'requested_reference'),
partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
filter_kw=sequence.get('requested_filter_dict', {}),
state=sequence.get('requested_state'))
sequence.edit(
requested_slap_computer_partition=requested_slap_computer_partition,
requested_computer_partition_reference=\
requested_slap_computer_partition.getId())
def stepSetCurrentPersonSlapRequestedSoftwareInstance(self, sequence, **kw):
software_instance_list = self.portal.portal_catalog(
portal_type=self.software_instance_portal_type,
title=sequence['requested_reference'])
self.assertEqual(1, len(software_instance_list))
software_instance = software_instance_list[0]
sequence.edit(
software_instance_uid=software_instance.getUid(),
software_instance_reference=software_instance.getReference(),
hosting_subscription_uid=software_instance.getAggregateRelatedValue(
portal_type='Sale Order Line').getAggregateValue(
portal_type='Hosting Subscription').getUid())
def stepSoftwareInstanceSaleOrderConfirmRaisesValueError(self, sequence,
**kw):
"""Checks that current software instance is realted only with sale order
and that this sale order cannot be confirmed
In Vifib implementation sale order which cannot find free computer partition
raises ValueError"""
software_instance = self.portal.portal_catalog.getResultValue(
uid=sequence['software_instance_uid'])
aggregate_value_list = software_instance.getAggregateRelatedValueList(
portal_type=[self.sale_packing_list_line_portal_type,
self.sale_order_line_portal_type])
self.assertEqual(1, len(aggregate_value_list))
self.assertTrue(self.sale_order_line_portal_type in [q.getPortalType() for\
q in aggregate_value_list])
sale_order_line = aggregate_value_list[0]
sale_order = sale_order_line.getParentValue()
self.assertRaises(ValueError, sale_order.confirm)
def stepCheckViewCurrentSoftwareInstance(self, sequence, **kw): def stepCheckViewCurrentSoftwareInstance(self, sequence, **kw):
software_instance = self.portal.portal_catalog.getResultValue( software_instance = self.portal.portal_catalog.getResultValue(
uid=sequence['software_instance_uid']) uid=sequence['software_instance_uid'])
......
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