Commit 731299cf authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: More tests

parent 8ca0f757
...@@ -216,76 +216,96 @@ class TestSlapOSFolder_getOpenTicketList(TestCRMSkinsMixin): ...@@ -216,76 +216,96 @@ class TestSlapOSFolder_getOpenTicketList(TestCRMSkinsMixin):
class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin): class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin):
def test_support_request_related_to_computer(self): def test_getOpenRelatedTicketList_support_request_related_to_computer(self):
computer = self._makeComputer()[0] self._test_getOpenRelatedTicketList_support_request_related(
self._makeComputer()[0])
def test_getOpenRelatedTicketList_support_request_related_to_hosting_subscription(self):
self._test_getOpenRelatedTicketList_support_request_related(
self._makeHostingSubscription())
def _test_getOpenRelatedTicketList_support_request_related(self, document):
ticket = self.portal.support_request_module.newContent(\ ticket = self.portal.support_request_module.newContent(\
title="Test Support Request %s" % self.new_id) title="Test Support Request %s" % self.new_id)
ticket.setAggregateValue(computer) ticket.setAggregateValue(document)
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
# Not indexed yet # Not indexed yet
self.assertEqual(len(open_related_ticket_list), 0) self.assertEqual(len(open_related_ticket_list), 0)
self.tic() self.tic()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid()) self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.submit() ticket.submit()
ticket.immediateReindexObject() ticket.immediateReindexObject()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid()) self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.validate() ticket.validate()
ticket.immediateReindexObject() ticket.immediateReindexObject()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid()) self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.suspend() ticket.suspend()
ticket.immediateReindexObject() ticket.immediateReindexObject()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid()) self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.invalidate() ticket.invalidate()
ticket.immediateReindexObject() ticket.immediateReindexObject()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid()) self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
def test_cancelled_support_request_related_to_computer(self): def test_getOpenRelatedTicketList_cancelled_support_request_related_to_computer(self):
computer = self._makeComputer()[0] self._test_getOpenRelatedTicketList_cancelled_support_request_related(
self._makeComputer()[0])
def test_getOpenRelatedTicketList_cancelled_support_request_related_to_hosting_subscription(self):
self._test_getOpenRelatedTicketList_cancelled_support_request_related(
self._makeHostingSubscription())
def _test_getOpenRelatedTicketList_cancelled_support_request_related(self, document):
ticket = self.portal.support_request_module.newContent(\ ticket = self.portal.support_request_module.newContent(\
title="Test Support Request %s" % self.new_id) title="Test Support Request %s" % self.new_id)
ticket.setAggregateValue(computer) ticket.setAggregateValue(document)
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
# Not indexed yet # Not indexed yet
self.assertEqual(len(open_related_ticket_list), 0) self.assertEqual(len(open_related_ticket_list), 0)
self.tic() self.tic()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid()) self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.submit() ticket.submit()
ticket.immediateReindexObject() ticket.immediateReindexObject()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid()) self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.cancel() ticket.cancel()
ticket.immediateReindexObject() ticket.immediateReindexObject()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 0) self.assertEqual(len(open_related_ticket_list), 0)
def test_upgrade_decision_related_to_computer(self): def test_getOpenRelatedTicketList_upgrade_decision_related_to_computer(self):
computer = self._makeComputer()[0] self._test_getOpenRelatedTicketList_upgrade_decision_related(
self._makeComputer()[0])
def test_getOpenRelatedTicketList_upgrade_decision_related_to_hosting_subscription(self):
self._test_getOpenRelatedTicketList_upgrade_decision_related(
self._makeHostingSubscription())
def _test_getOpenRelatedTicketList_upgrade_decision_related(self, document):
def newUpgradeDecision(): def newUpgradeDecision():
ticket = self.portal.upgrade_decision_module.newContent( ticket = self.portal.upgrade_decision_module.newContent(
portal_type='Upgrade Decision', portal_type='Upgrade Decision',
...@@ -298,50 +318,56 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin): ...@@ -298,50 +318,56 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin):
ticket.newContent( ticket.newContent(
portal_type="Upgrade Decision Line" portal_type="Upgrade Decision Line"
).setAggregateValue(computer) ).setAggregateValue(document)
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
# Not indexed yet # Not indexed yet
self.assertEqual(len(open_related_ticket_list), 0) self.assertEqual(len(open_related_ticket_list), 0)
self.tic() self.tic()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid()) self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.plan() ticket.plan()
ticket.immediateReindexObject() ticket.immediateReindexObject()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid()) self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.confirm() ticket.confirm()
ticket.immediateReindexObject() ticket.immediateReindexObject()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid()) self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.start() ticket.start()
ticket.immediateReindexObject() ticket.immediateReindexObject()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid()) self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.stop() ticket.stop()
ticket.immediateReindexObject() ticket.immediateReindexObject()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid()) self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.deliver() ticket.deliver()
ticket.immediateReindexObject() ticket.immediateReindexObject()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid()) self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
def test_getOpenRelatedTicketList_cancelled_upgrade_decision_related_to_computer(self):
self._test_getOpenRelatedTicketList_cancelled_upgrade_decision_related(
self._makeComputer()[0])
def test_getOpenRelatedTicketList_cancelled_upgrade_decision_related_to_hosting_subscription(self):
self._test_getOpenRelatedTicketList_cancelled_upgrade_decision_related(
self._makeHostingSubscription())
def test_cancelled_upgrade_decision_related_to_computer(self): def _test_getOpenRelatedTicketList_cancelled_upgrade_decision_related(self, document):
computer = self._makeComputer()[0]
def newUpgradeDecision(): def newUpgradeDecision():
ticket = self.portal.upgrade_decision_module.newContent( ticket = self.portal.upgrade_decision_module.newContent(
portal_type='Upgrade Decision', portal_type='Upgrade Decision',
...@@ -354,20 +380,20 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin): ...@@ -354,20 +380,20 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin):
ticket.newContent( ticket.newContent(
portal_type="Upgrade Decision Line" portal_type="Upgrade Decision Line"
).setAggregateValue(computer) ).setAggregateValue(document)
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
# Not indexed yet # Not indexed yet
self.assertEqual(len(open_related_ticket_list), 0) self.assertEqual(len(open_related_ticket_list), 0)
self.tic() self.tic()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid()) self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.cancel() ticket.cancel()
ticket.immediateReindexObject() ticket.immediateReindexObject()
open_related_ticket_list = computer.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 0) self.assertEqual(len(open_related_ticket_list), 0)
class TestSlapOSTicketEvent(TestCRMSkinsMixin): class TestSlapOSTicketEvent(TestCRMSkinsMixin):
......
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