Commit 6fc83f2f authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Add tests and fix RSS feed for Open Tickets

Include tests for Support Request, Regularisation Request and Upgrade Decisions.
parent 57c9bf76
Pipeline #1562 skipped
kw['simulation_state'] = ['validated','submitted']
kw['simulation_state'] = ['validated','submitted', 'suspended', 'invalidated',
# Unfortunally Upgrade decision uses diferent states.
'confirmed', 'delivered']
kw['sort_on'] = [('modification_date', 'DESC'),]
return context.searchFolder(**kw)
......@@ -487,7 +487,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: cell.SupportRequest_getLatestEvent() and cell.SupportRequest_getLatestEvent().getModificationDate() or cell.getModificationDate()</string> </value>
<value> <string>python: cell.Ticket_getLatestEvent() and cell.Ticket_getLatestEvent().getModificationDate() or cell.getModificationDate()</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -118,7 +118,9 @@
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -152,6 +154,10 @@
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>input_type</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
......@@ -257,4 +263,17 @@
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: "[%s] %s" % (cell.getSimulationStateTitle(), cell.getTitle())</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
return portal.portal_catalog.getResultValue(
follow_up_uid=context.getUid(),
portal_type=portal.getPortalEventTypeList(),
validation_state=["started", "stopped", "deliveried"],
simulation_state=["confirmed", "started", "stopped", "delivered"],
sort_on=(("modification_date", 'DESC'),))
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SupportRequest_getLatestEvent</string> </value>
<value> <string>Ticket_getLatestEvent</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -27,6 +27,248 @@ def simulate(script_id, params_string, code_string):
return decorated
return upperWrap
class TestSlapOSFolder_getOpenTicketList(testSlapOSMixin):
def beforeTearDown(self):
transaction.abort()
def afterSetUp(self):
super(TestSlapOSFolder_getOpenTicketList, self).afterSetUp()
self.new_id = self.generateNewId()
self.person = self.portal.person_module.newContent(
portal_type='Person',
title="Person %s" % self.new_id,
reference="TESTPERS-%s" % self.new_id,
default_email_text="live_test_%s@example.org" % self.new_id,
)
def _test_ticket(self, ticket, expected_amount):
module = ticket.getParentValue()
open_ticket_list = module.Folder_getOpenTicketList(title=ticket.getTitle())
self.assertEquals(len(open_ticket_list), expected_amount-1)
ticket.submit()
ticket.immediateReindexObject()
open_ticket_list = module.Folder_getOpenTicketList(title=ticket.getTitle())
self.assertEquals(len(open_ticket_list), expected_amount)
self.assertEquals(open_ticket_list[0].getUid(), ticket.getUid())
ticket.validate()
ticket.immediateReindexObject()
open_ticket_list = module.Folder_getOpenTicketList(title=ticket.getTitle())
self.assertEquals(len(open_ticket_list), expected_amount)
self.assertEquals(open_ticket_list[0].getUid(), ticket.getUid())
ticket.suspend()
ticket.immediateReindexObject()
open_ticket_list = module.Folder_getOpenTicketList(title=ticket.getTitle())
self.assertEquals(len(open_ticket_list), expected_amount)
self.assertEquals(open_ticket_list[0].getUid(), ticket.getUid())
ticket.invalidate()
ticket.immediateReindexObject()
open_ticket_list = module.Folder_getOpenTicketList(title=ticket.getTitle())
self.assertEquals(len(open_ticket_list), expected_amount)
self.assertEquals(open_ticket_list[0].getUid(), ticket.getUid())
def _test_upgrade_decision(self, ticket, expected_amount):
module = ticket.getParentValue()
open_ticket_list = module.Folder_getOpenTicketList(title=ticket.getTitle())
self.assertEquals(len(open_ticket_list), expected_amount-1)
ticket.plan()
ticket.immediateReindexObject()
open_ticket_list = module.Folder_getOpenTicketList(title=ticket.getTitle())
self.assertEquals(len(open_ticket_list), expected_amount-1)
ticket.confirm()
ticket.immediateReindexObject()
open_ticket_list = module.Folder_getOpenTicketList(title=ticket.getTitle())
self.assertEquals(len(open_ticket_list), expected_amount)
self.assertEquals(open_ticket_list[0].getUid(), ticket.getUid())
ticket.start()
ticket.immediateReindexObject()
open_ticket_list = module.Folder_getOpenTicketList(title=ticket.getTitle())
self.assertEquals(len(open_ticket_list), expected_amount-1)
ticket.stop()
ticket.immediateReindexObject()
open_ticket_list = module.Folder_getOpenTicketList(title=ticket.getTitle())
self.assertEquals(len(open_ticket_list), expected_amount-1)
ticket.deliver()
ticket.immediateReindexObject()
open_ticket_list = module.Folder_getOpenTicketList(title=ticket.getTitle())
self.assertEquals(len(open_ticket_list), expected_amount)
self.assertEquals(open_ticket_list[0].getUid(), ticket.getUid())
def test_support_request(self):
def newSupportRequest():
sr = self.portal.support_request_module.newContent(\
title="Test Support Request %s" % self.new_id)
sr.immediateReindexObject()
return sr
ticket = newSupportRequest()
self._test_ticket(ticket, 1)
ticket = newSupportRequest()
self._test_ticket(ticket, 2)
def test_regularisation_request(self):
def newRegularisationRequest():
ticket = self.portal.regularisation_request_module.newContent(
portal_type='Regularisation Request',
title="Test Reg. Req.%s" % self.new_id,
reference="TESTREGREQ-%s" % self.new_id
)
ticket.immediateReindexObject()
return ticket
ticket = newRegularisationRequest()
self._test_ticket(ticket, 1)
ticket = newRegularisationRequest()
self._test_ticket(ticket, 2)
def test_upgrade_decision(self):
def newUpgradeDecision():
ticket = self.portal.upgrade_decision_module.newContent(
portal_type='Upgrade Decision',
title="Upgrade Decision Test %s" % self.new_id,
reference="TESTUD-%s" % self.new_id
)
ticket.immediateReindexObject()
return ticket
ticket = newUpgradeDecision()
self._test_upgrade_decision(ticket, 1)
ticket = newUpgradeDecision()
self._test_upgrade_decision(ticket, 2)
class TestSlapOSTicket_getLatestEvent(testSlapOSMixin):
def beforeTearDown(self):
transaction.abort()
def afterSetUp(self):
super(TestSlapOSTicket_getLatestEvent, self).afterSetUp()
self.new_id = self.generateNewId()
self.person = self.portal.person_module.newContent(
portal_type='Person',
title="Person %s" % self.new_id,
reference="TESTPERS-%s" % self.new_id,
default_email_text="live_test_%s@example.org" % self.new_id,
)
def _test_event(self, ticket):
def newEvent(ticket):
event = self.portal.event_module.newContent(
title="Test Event %s" % self.new_id,
portal_type="Web Message",
follow_up_value=ticket)
event.immediateReindexObject()
return event
last_event = ticket.Ticket_getLatestEvent()
self.assertEquals(last_event, None)
event = newEvent(ticket)
last_event = ticket.Ticket_getLatestEvent()
self.assertEquals(last_event, None)
event.plan()
event.immediateReindexObject()
self.assertEquals(last_event, None)
event.confirm()
event.immediateReindexObject()
last_event = ticket.Ticket_getLatestEvent()
self.assertEquals(last_event, event)
event.start()
event.immediateReindexObject()
last_event = ticket.Ticket_getLatestEvent()
self.assertEquals(last_event, event)
event.stop()
event.immediateReindexObject()
last_event = ticket.Ticket_getLatestEvent()
self.assertEquals(last_event, event)
event.deliver()
event.immediateReindexObject()
last_event = ticket.Ticket_getLatestEvent()
self.assertEquals(last_event, event)
# Now we test unwanted cases (deleted and cancelled)
another_event = newEvent(ticket)
last_event = ticket.Ticket_getLatestEvent()
self.assertEquals(last_event, event)
another_event.cancel()
event.immediateReindexObject()
last_event = ticket.Ticket_getLatestEvent()
self.assertEquals(last_event, event)
another_event = newEvent(ticket)
last_event = ticket.Ticket_getLatestEvent()
self.assertEquals(last_event, event)
another_event.delete()
event.immediateReindexObject()
last_event = ticket.Ticket_getLatestEvent()
self.assertEquals(last_event, event)
def test_support_request(self):
ticket = self.portal.support_request_module.newContent(\
title="Test Support Request %s" % self.new_id,
resource="service_module/slapos_crm_monitoring",
destination_decision_value=self.person)
ticket.immediateReindexObject()
self._test_event(ticket)
def test_regularisation_request(self):
ticket = self.portal.regularisation_request_module.newContent(
portal_type='Regularisation Request',
title="Test Reg. Req.%s" % self.new_id,
reference="TESTREGREQ-%s" % self.new_id
)
ticket.immediateReindexObject()
self._test_event(ticket)
def test_upgrade_decision(self):
ticket = self.portal.upgrade_decision_module.newContent(
portal_type='Upgrade Decision',
title="Upgrade Decision Test %s" % self.new_id,
reference="TESTUD-%s" % self.new_id
)
ticket.immediateReindexObject()
self._test_event(ticket)
class TestSlapOSPerson_checkToCreateRegularisationRequest(testSlapOSMixin):
......
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