Commit 9157ad21 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_web: testSlapOSWebSkins, use person.getUserId instead person.getReference

parent ae610908
...@@ -49,7 +49,7 @@ class SlapOSWebMixin(testSlapOSMixin, SecurityTestCase): ...@@ -49,7 +49,7 @@ class SlapOSWebMixin(testSlapOSMixin, SecurityTestCase):
person_user.validate() person_user.validate()
for assignment in person_user.contentValues(portal_type="Assignment"): for assignment in person_user.contentValues(portal_type="Assignment"):
assignment.open() assignment.open()
person_user.immediateReindexObject() person_user.immediateReindexObject()
transaction.commit() transaction.commit()
return person_user return person_user
...@@ -89,11 +89,11 @@ class SlapOSWebMixin(testSlapOSMixin, SecurityTestCase): ...@@ -89,11 +89,11 @@ class SlapOSWebMixin(testSlapOSMixin, SecurityTestCase):
sr.immediateReindexObject() sr.immediateReindexObject()
sr.updateLocalRolesOnSecurityGroups() sr.updateLocalRolesOnSecurityGroups()
if validate: if validate:
self.assertUserCanAccessDocument(person.getReference(), sr) self.assertUserCanAccessDocument(person.getUserId(), sr)
self.assertUserCanViewDocument(person.getReference(), sr) self.assertUserCanViewDocument(person.getUserId(), sr)
return sr return sr
def createUpgradeDecision(self, person, computer=None, validate=1): def createUpgradeDecision(self, person, computer=None, validate=1):
ud = self.portal.upgrade_decision_module.newContent(\ ud = self.portal.upgrade_decision_module.newContent(\
title="Upgrade Decision %s" % self.new_id, title="Upgrade Decision %s" % self.new_id,
...@@ -101,8 +101,8 @@ class SlapOSWebMixin(testSlapOSMixin, SecurityTestCase): ...@@ -101,8 +101,8 @@ class SlapOSWebMixin(testSlapOSMixin, SecurityTestCase):
ud.immediateReindexObject() ud.immediateReindexObject()
ud.updateLocalRolesOnSecurityGroups() ud.updateLocalRolesOnSecurityGroups()
# This seems odd, user can see draft SR even he is auditor # This seems odd, user can see draft SR even he is auditor
self.assertUserCanAccessDocument(person.getReference(), ud) self.assertUserCanAccessDocument(person.getUserId(), ud)
self.assertUserCanViewDocument(person.getReference(), ud) self.assertUserCanViewDocument(person.getUserId(), ud)
if computer is not None: if computer is not None:
line = ud.newContent( line = ud.newContent(
...@@ -110,7 +110,7 @@ class SlapOSWebMixin(testSlapOSMixin, SecurityTestCase): ...@@ -110,7 +110,7 @@ class SlapOSWebMixin(testSlapOSMixin, SecurityTestCase):
aggregate_value=computer) aggregate_value=computer)
line.immediateReindexObject() line.immediateReindexObject()
return ud return ud
def createRegularisationRequest(self, person, validate=1): def createRegularisationRequest(self, person, validate=1):
rr = self.portal.regularisation_request_module.newContent( rr = self.portal.regularisation_request_module.newContent(
portal_type='Regularisation Request', portal_type='Regularisation Request',
...@@ -122,11 +122,11 @@ class SlapOSWebMixin(testSlapOSMixin, SecurityTestCase): ...@@ -122,11 +122,11 @@ class SlapOSWebMixin(testSlapOSMixin, SecurityTestCase):
rr.immediateReindexObject() rr.immediateReindexObject()
rr.updateLocalRolesOnSecurityGroups() rr.updateLocalRolesOnSecurityGroups()
if validate: if validate:
self.assertUserCanAccessDocument(person.getReference(), rr) self.assertUserCanAccessDocument(person.getUserId(), rr)
self.assertUserCanViewDocument(person.getReference(), rr) self.assertUserCanViewDocument(person.getUserId(), rr)
return rr return rr
def afterSetUp(self): def afterSetUp(self):
""" bootstrap test """ """ bootstrap test """
self.login() self.login()
...@@ -138,32 +138,32 @@ class SlapOSWebMixin(testSlapOSMixin, SecurityTestCase): ...@@ -138,32 +138,32 @@ class SlapOSWebMixin(testSlapOSMixin, SecurityTestCase):
self.computer = self.createComputer(person=self.person) self.computer = self.createComputer(person=self.person)
self.hosting_subscription = self.createHostingSubscription( self.hosting_subscription = self.createHostingSubscription(
person=self.person) person=self.person)
self.support_request = self.createSupportRequest(self.person, self.support_request = self.createSupportRequest(self.person,
computer=self.computer) computer=self.computer)
self.upgrade_decision = self.createUpgradeDecision(self.person, self.upgrade_decision = self.createUpgradeDecision(self.person,
computer=self.computer) computer=self.computer)
self.hs_support_request = self.createSupportRequest(self.person, self.hs_support_request = self.createSupportRequest(self.person,
computer=self.hosting_subscription) computer=self.hosting_subscription)
self.hs_upgrade_decision = self.createUpgradeDecision(self.person, self.hs_upgrade_decision = self.createUpgradeDecision(self.person,
computer=self.hosting_subscription) computer=self.hosting_subscription)
self.regularisation_request = self.createRegularisationRequest( self.regularisation_request = self.createRegularisationRequest(
self.person) self.person)
self.cancelled_support_request = self.createSupportRequest(self.person, self.cancelled_support_request = self.createSupportRequest(self.person,
computer=self.computer, computer=self.computer,
validate=0) validate=0)
self.cancelled_upgrade_decision = self.createUpgradeDecision(self.person, self.cancelled_upgrade_decision = self.createUpgradeDecision(self.person,
computer=self.computer, computer=self.computer,
validate=0) validate=0)
self.cancelled_regularisation_request = self.createRegularisationRequest( self.cancelled_regularisation_request = self.createRegularisationRequest(
self.person, validate=0) self.person, validate=0)
self.cancelled_support_request.cancel() self.cancelled_support_request.cancel()
self.cancelled_upgrade_decision.cancel() self.cancelled_upgrade_decision.cancel()
self.cancelled_regularisation_request.cancel() self.cancelled_regularisation_request.cancel()
self.tic() self.tic()
def _test_WebSection_getUserTicketList(self): def _test_WebSection_getUserTicketList(self):
ticket_list = self.portal.WebSection_getUserTicketList() ticket_list = self.portal.WebSection_getUserTicketList()
self.assertEquals(len(ticket_list), 5) self.assertEquals(len(ticket_list), 5)
...@@ -188,23 +188,23 @@ class SlapOSWebMixin(testSlapOSMixin, SecurityTestCase): ...@@ -188,23 +188,23 @@ class SlapOSWebMixin(testSlapOSMixin, SecurityTestCase):
""" Test get Hosting Subscription RSS """ """ Test get Hosting Subscription RSS """
self.login() self.login()
ticket_list = self.hosting_subscription.Base_getOpenRelatedTicketList() ticket_list = self.hosting_subscription.Base_getOpenRelatedTicketList()
self.assertSameSet([i.getRelativeUrl() for i in ticket_list], self.assertSameSet([i.getRelativeUrl() for i in ticket_list],
[self.hs_support_request.getRelativeUrl(), [self.hs_support_request.getRelativeUrl(),
self.hs_upgrade_decision.getRelativeUrl()]) self.hs_upgrade_decision.getRelativeUrl()])
self.assertEquals(len(ticket_list), 2) self.assertEquals(len(ticket_list), 2)
class TestSlapOSWebSkin(SlapOSWebMixin): class TestSlapOSWebSkin(SlapOSWebMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSWebSkin, self).afterSetUp() super(TestSlapOSWebSkin, self).afterSetUp()
self.login(self.person.getReference()) self.login(self.person.getUserId())
self.changeSkin("Hosting") self.changeSkin("Hosting")
def test_WebSection_getUserTicketList(self): def test_WebSection_getUserTicketList(self):
""" Test get User Tickers at Hosting Skin""" """ Test get User Tickers at Hosting Skin"""
self._test_WebSection_getUserTicketList() self._test_WebSection_getUserTicketList()
def test_WebSection_getUserTicketList_new_support_request(self): def test_WebSection_getUserTicketList_new_support_request(self):
""" Test get User Tickers at Hosting Skin with new support request """ """ Test get User Tickers at Hosting Skin with new support request """
self._test_WebSection_getUserTicketList() self._test_WebSection_getUserTicketList()
...@@ -226,7 +226,7 @@ class TestSlapOSWebSkin(SlapOSWebMixin): ...@@ -226,7 +226,7 @@ class TestSlapOSWebSkin(SlapOSWebMixin):
self.assertEquals(ticket_list[0].getUid(), sr.getUid()) self.assertEquals(ticket_list[0].getUid(), sr.getUid())
finally: finally:
transaction.abort() transaction.abort()
def test_Base_getOpenRelatedTicketList_computer(self): def test_Base_getOpenRelatedTicketList_computer(self):
""" Test Base_getOpenRelatedTicketList with Hosting Subscriptions on Hosting """ Test Base_getOpenRelatedTicketList with Hosting Subscriptions on Hosting
""" """
...@@ -238,10 +238,10 @@ class TestSlapOSWebSkin(SlapOSWebMixin): ...@@ -238,10 +238,10 @@ class TestSlapOSWebSkin(SlapOSWebMixin):
self._test_Base_getOpenRelatedTicketList_hosting_subscription() self._test_Base_getOpenRelatedTicketList_hosting_subscription()
class TestSlapOSRSSSkin(SlapOSWebMixin): class TestSlapOSRSSSkin(SlapOSWebMixin):
def afterSetUp(self): def afterSetUp(self):
super(TestSlapOSRSSSkin, self).afterSetUp() super(TestSlapOSRSSSkin, self).afterSetUp()
self.login(self.person.getReference()) self.login(self.person.getUserId())
self.changeSkin("RSS") self.changeSkin("RSS")
def test_WebSection_getUserTicketList(self): def test_WebSection_getUserTicketList(self):
...@@ -253,10 +253,10 @@ class TestSlapOSRSSSkin(SlapOSWebMixin): ...@@ -253,10 +253,10 @@ class TestSlapOSRSSSkin(SlapOSWebMixin):
""" """
date_content = ticket.WebSection_getRSSDateContent() date_content = ticket.WebSection_getRSSDateContent()
description = ticket.WebSection_getRSSDescriptionContent() description = ticket.WebSection_getRSSDescriptionContent()
self.assertEquals(ticket.getModificationDate(), date_content) self.assertEquals(ticket.getModificationDate(), date_content)
self.assertEquals(ticket.getDescription(), description) self.assertEquals(ticket.getDescription(), description)
event = self.portal.event_module.newContent( event = self.portal.event_module.newContent(
portal_type="Web Message", portal_type="Web Message",
follow_up_value=ticket, follow_up_value=ticket,
...@@ -266,11 +266,11 @@ class TestSlapOSRSSSkin(SlapOSWebMixin): ...@@ -266,11 +266,11 @@ class TestSlapOSRSSSkin(SlapOSWebMixin):
) )
event.immediateReindexObject() event.immediateReindexObject()
transaction.commit() transaction.commit()
# Now the event dates and content should be showed instead of the ticket # Now the event dates and content should be showed instead of the ticket
self.assertEquals(event.getModificationDate(), self.assertEquals(event.getModificationDate(),
ticket.WebSection_getRSSDateContent()) ticket.WebSection_getRSSDateContent())
self.assertEquals(event.getTextContent(), self.assertEquals(event.getTextContent(),
ticket.WebSection_getRSSDescriptionContent()) ticket.WebSection_getRSSDescriptionContent())
# Create another event and check if it continues the same # Create another event and check if it continues the same
...@@ -287,7 +287,7 @@ class TestSlapOSRSSSkin(SlapOSWebMixin): ...@@ -287,7 +287,7 @@ class TestSlapOSRSSSkin(SlapOSWebMixin):
# Now the new event dates and content should be showed instead # Now the new event dates and content should be showed instead
self.assertEquals(new_event.getModificationDate(), self.assertEquals(new_event.getModificationDate(),
ticket.WebSection_getRSSDateContent()) ticket.WebSection_getRSSDateContent())
self.assertEquals(new_event.getTextContent(), self.assertEquals(new_event.getTextContent(),
ticket.WebSection_getRSSDescriptionContent()) ticket.WebSection_getRSSDescriptionContent())
# Catalog table dont index microseconds, so it can cause problems when search # Catalog table dont index microseconds, so it can cause problems when search
...@@ -305,7 +305,7 @@ class TestSlapOSRSSSkin(SlapOSWebMixin): ...@@ -305,7 +305,7 @@ class TestSlapOSRSSSkin(SlapOSWebMixin):
"%s is not larger them %s" % (event.getModificationDate(), new_event.getModificationDate())) "%s is not larger them %s" % (event.getModificationDate(), new_event.getModificationDate()))
# Now the first event dates and content should be showed instead # Now the first event dates and content should be showed instead
self.assertEquals(event.getTextContent(), self.assertEquals(event.getTextContent(),
ticket.WebSection_getRSSDescriptionContent()) ticket.WebSection_getRSSDescriptionContent())
self.assertEquals(event.getModificationDate(), self.assertEquals(event.getModificationDate(),
...@@ -320,7 +320,7 @@ class TestSlapOSRSSSkin(SlapOSWebMixin): ...@@ -320,7 +320,7 @@ class TestSlapOSRSSSkin(SlapOSWebMixin):
""" Test for get Date and Content for the RSS Feed for Upgrade Decision """ Test for get Date and Content for the RSS Feed for Upgrade Decision
""" """
self._test_WebSection_getRSSContent(self.upgrade_decision) self._test_WebSection_getRSSContent(self.upgrade_decision)
def test_WebSection_getRSSContents_regularisation_request(self): def test_WebSection_getRSSContents_regularisation_request(self):
""" Test for get Date + Content for the RSS Feed for Regularisation Request """ Test for get Date + Content for the RSS Feed for Regularisation Request
""" """
...@@ -333,5 +333,3 @@ class TestSlapOSRSSSkin(SlapOSWebMixin): ...@@ -333,5 +333,3 @@ class TestSlapOSRSSSkin(SlapOSWebMixin):
def test_Base_getOpenRelatedTicketList_hosting_subscription(self): def test_Base_getOpenRelatedTicketList_hosting_subscription(self):
""" Test Base_getOpenRelatedTicketList with Hosting Subscriptions on RSS """ """ Test Base_getOpenRelatedTicketList with Hosting Subscriptions on RSS """
self._test_Base_getOpenRelatedTicketList_hosting_subscription() self._test_Base_getOpenRelatedTicketList_hosting_subscription()
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