def test_ws_createItemWithWarnings(self): """ Test that during item creation, if non blocker errors occur (warnings), it is displayed in the response """ # if the proposed HTML of one of the rich field is wrong # it is reworked by BeautifulSoup and a warning is displayed self.changeUser('pmCreator1') req = self._prepareCreationData() wrongHTML = '<p>Wrong HTML<strong></p></strong>' req._creationData._decision = wrongHTML newItem, response = self._createItem(req) resp = deserialize(response) expected = """<ns1:createItemResponse xmlns:ns1="http://ws4pm.imio.be" """ \ """xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" """ \ """xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" """ \ """xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" """ \ """xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <UID>%s</UID> <warnings>%s</warnings> </ns1:createItemResponse> """ % (newItem.UID(), translate(WRONG_HTML_WARNING, domain='imio.pm.ws', mapping={'item_path': newItem.absolute_url_path(), 'creator': 'pmCreator1'}, context=self.request)) self.assertEqual(expected, resp) # now test warnings around file mimetype data = {'title': 'My annex with spécial char and no filename', 'filename': '', 'file': 'octetStreamTestFile.bin', 'annexTypeId': 'budget-analysis'} req._creationData._annexes = [self._prepareAnnexInfo(**data)] # several extensions found and no valid filename extension, the annex is not created and a warning is added newItem, response = self._createItem(req) resp = deserialize(response) # 2 warnings are returned expected = """<ns1:createItemResponse xmlns:ns1="http://ws4pm.imio.be" """ \ """xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" """ \ """xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" """ \ """xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" """ \ """xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <UID>%s</UID> <warnings>%s</warnings> <warnings>%s</warnings> </ns1:createItemResponse> """ % (newItem.UID(), translate( WRONG_HTML_WARNING, domain='imio.pm.ws', mapping={'item_path': newItem.absolute_url_path(), 'creator': 'pmCreator1'}, context=self.request), translate( MULTIPLE_EXTENSION_FOR_MIMETYPE_OF_ANNEX_WARNING, domain='imio.pm.ws', mapping={'mime': 'application/octet-stream', 'annex_path': unicode(data['title'], 'utf-8'), 'item_path': newItem.absolute_url_path()}, context=self.request)) expected = expected.encode('utf-8') self.assertEqual(expected, resp)
def test_ws_getUserInfosShowGroups(self): """ Test getting user informations including groups """ # use pmManager that is member of 2 groups but only creator for one self.changeUser('pmManager') req = getUserInfosRequest() req._userId = 'pmManager' req._showGroups = True responseHolder = getUserInfosResponse() response = SOAPView(self.portal, req).getUserInfosRequest(req, responseHolder) resp = deserialize(response) expected = """<ns1:getUserInfosResponse xmlns:ns1="http://ws4pm.imio.be" """ \ """xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" """ \ """xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" """ \ """xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" """ \ """xmlns:xsd="http://www.w3.org/2001/XMLSchema" """ \ """xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <fullname>M. PMManager</fullname> <email>[email protected]</email> <groups xsi:type="ns1:BasicInfo"> <UID>%s</UID> <id>developers</id> <title>Developers</title> <description/> </groups> <groups xsi:type="ns1:BasicInfo"> <UID>%s</UID> <id>vendors</id> <title>Vendors</title> <description/> </groups> </ns1:getUserInfosResponse>\n""" % (self.developers_uid, self.vendors_uid) self.assertEquals(expected, resp) # if we specify a particular suffix, only groups of this suffix are returned req._suffix = 'creators' responseHolder = getUserInfosResponse() response = SOAPView(self.portal, req).getUserInfosRequest(req, responseHolder) resp = deserialize(response) expected = """<ns1:getUserInfosResponse xmlns:ns1="http://ws4pm.imio.be" """ \ """xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" """ \ """xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" """ \ """xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" """ \ """xmlns:xsd="http://www.w3.org/2001/XMLSchema" """ \ """xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <fullname>M. PMManager</fullname> <email>[email protected]</email> <groups xsi:type="ns1:BasicInfo"> <UID>%s</UID> <id>developers</id> <title>Developers</title> <description/> </groups> </ns1:getUserInfosResponse>\n""" % (self.developers_uid, )
def test_ws_showCategoriesForUser(self): """ Test while getting configInfos with categories and using userToShowCategoriesFor. """ # first of all, we need to be a Manager/MeetingManager to use userToShowCategoriesFor self.changeUser('pmCreator1') req = getConfigInfosRequest() req._showCategories = True req._userToShowCategoriesFor = 'pmCreator1' responseHolder = getConfigInfosResponse() with self.assertRaises(ZSI.Fault) as cm: SOAPView(self.portal, req).getConfigInfosRequest(req, responseHolder) self.assertEquals( cm.exception.string, "You need to be 'Manager' or 'MeetingManager' to get available categories for a user!" ) # now try with a 'pmManager' self.changeUser('pmManager') req._userToShowCategoriesFor = 'unexistingUserId' # the userToShowCategoriesFor must exists! cleanRamCacheFor('Products.PloneMeeting.ToolPloneMeeting.userIsAmong') with self.assertRaises(ZSI.Fault) as cm: SOAPView(self.portal, req).getConfigInfosRequest(req, responseHolder) self.assertEquals( cm.exception.string, "Trying to get avaialble categories for an unexisting user 'unexistingUserId'!" ) # now get it. The 'subproducts' category is only available to vendors (pmCreator2) req._userToShowCategoriesFor = 'pmCreator1' cleanRamCacheFor('Products.PloneMeeting.ToolPloneMeeting.userIsAmong') response = SOAPView(self.portal, req).getConfigInfosRequest(req, responseHolder) resp = deserialize(response) # for 'pmCreator1', subproducts is not available self.assertFalse('<id>subproducts</id>' in resp) req._userToShowCategoriesFor = 'pmCreator2' cleanRamCacheFor('Products.PloneMeeting.ToolPloneMeeting.userIsAmong') response = SOAPView(self.portal, req).getConfigInfosRequest(req, responseHolder) resp = deserialize(response) # but for 'pmCreator2', subproducts is available self.assertTrue('<id>subproducts</id>' in resp)
def test_ws_getConfigInfosItemPositiveDecidedStates(self): """This will return the MeetingConfig.itemPositiveDecidedStates.""" self.changeUser('pmCreator1') req = getConfigInfosRequest() responseHolder = getConfigInfosResponse() response = SOAPView(self.portal, req).getConfigInfosRequest(req, responseHolder) cfg = self.tool.getActiveConfigs()[0] # we have defined itemPositiveDecidedStates self.assertTrue(cfg.getItemPositiveDecidedStates()) self.assertEqual(response._configInfo[0]._itemPositiveDecidedStates, cfg.getItemPositiveDecidedStates()) self.assertTrue(deserialize(response)) # works if no itemPositiveDecidedStates defined cfg.getItemPositiveDecidedStates = lambda: () response = SOAPView(self.portal, req).getConfigInfosRequest(req, responseHolder) self.assertEqual(response._configInfo[0]._itemPositiveDecidedStates, ()) self.assertTrue(deserialize(response))
def test_ws_showCategories(self): """ Test while getting configInfos with categories. """ self.changeUser('pmCreator1') req = getConfigInfosRequest() req._showCategories = True # Serialize the request so it can be easily tested responseHolder = getConfigInfosResponse() response = SOAPView(self.portal, req).getConfigInfosRequest(req, responseHolder) resp = deserialize(response) expected = """<ns1:getConfigInfosResponse xmlns:ns1="http://ws4pm.imio.be" """ \ """xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" """ \ """xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" """ \ """xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" """ \ """xmlns:xsd="http://www.w3.org/2001/XMLSchema" """ \ """xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">""" # _configInfo for cfg in self.tool.getActiveConfigs(): expected += """ <configInfo xsi:type="ns1:ConfigInfo"> <UID>%s</UID> <id>%s</id> <title>%s</title> <description>%s</description>%s%s </configInfo>""" % (cfg.UID(), cfg.getId(), cfg.Title(), cfg.Description(), self._getItemPositiveDecidedStatesFromConfig(cfg), self._getResultCategoriesForConfig(cfg)) # _groupInfo for grp in get_organizations(): expected += """ <groupInfo xsi:type="ns1:GroupInfo"> <UID>%s</UID> <id>%s</id> <title>%s</title> <description>%s</description> </groupInfo>""" % (grp.UID(), grp.getId(), grp.Title(), grp.Description()) # footer. Empty description is represented like <description/> expected = expected.replace('<description></description>', '<description/>') \ + "\n</ns1:getConfigInfosResponse>\n" self.assertEquals(expected, resp) # the category 'subproducts' is only available to vendors self.assertFalse('<id>subproducts</id>' in resp)
def test_ws_createItemRequest(self): """ In the default test configuration, the user 'pmCreator1' can create an item for proposingGroup 'developers' in the MeetingConfig 'plonegov-assembly' """ # by default no item exists self.changeUser('pmCreator1') self.failUnless(len(self.portal.portal_catalog(portal_type='MeetingItemPga')) == 0) req = self._prepareCreationData() # This is what the sent enveloppe should looks like, note that the decision is "Décision<strong>wrongTagd</p>" # instead of '<p>Décision</p>' so we check accents and missing <p></p> req._creationData._decision = 'Décision<strong>wrongTagd</p>' # Serialize the request so it can be easily tested request = serializeRequest(req) expected = """POST /plone/createItemRequest HTTP/1.0 Authorization: Basic %s:%s Content-Length: 102 Content-Type: text/xml SOAPAction: / <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" """ \ """xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" """ \ """xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">""" \ """<SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body xmlns:ns1="http://ws4pm.imio.be"><ns1:createItemRequest>""" \ """<meetingConfigId>plonegov-assembly</meetingConfigId><proposingGroupId>developers</proposingGroupId>""" \ """<creationData xsi:type="ns1:CreationData"><title>My new item title</title><category>development</category>""" \ """<description><p>Description</p></description>""" \ """<detailedDescription><p>Detailed description</p></detailedDescription>""" \ """<decision>D\xc3\xa9cision<strong>wrongTagd</p></decision></creationData><cleanHtml>true</cleanHtml>""" \ """</ns1:createItemRequest>""" \ """</SOAP-ENV:Body></SOAP-ENV:Envelope>""" % ('pmCreator1', 'meeting') result = """POST /plone/createItemRequest HTTP/1.0 Authorization: Basic %s:%s Content-Length: 102 Content-Type: text/xml SOAPAction: / %s""" % ('pmCreator1', 'meeting', request) self.assertEqual(expected, result) # now really use the SOAP method to create an item newItem, response = self._createItem(req) newItemUID = newItem.UID() resp = deserialize(response) expected = """<ns1:createItemResponse xmlns:ns1="http://ws4pm.imio.be" """ \ """xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" """\ """xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" """ \ """xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" """ \ """xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <UID>%s</UID> <warnings>%s</warnings> </ns1:createItemResponse> """ % (newItemUID, translate(WRONG_HTML_WARNING, domain='imio.pm.ws', mapping={'item_path': newItem.absolute_url_path(), 'creator': 'pmCreator1'}, context=self.request) ) self.assertEqual(expected, resp) # the item is actually created self.failUnless(len(self.portal.portal_catalog(portal_type='MeetingItemPga', UID=newItemUID)) == 1) # responseHolder for tests here above responseHolder = createItemResponse() # check that we can create an item with a NoneType HTML field req._creationData._decision = None newItemWithEmptyDecisionUID = SOAPView(self.portal, req).createItemRequest(req, responseHolder)._UID self.failUnless(len(self.portal.portal_catalog(portal_type='MeetingItemPga', UID=newItemWithEmptyDecisionUID)) == 1) # No matter how the item is created, with or without a decision, every HTML fields are surrounded by <p></p> obj = self.portal.portal_catalog(portal_type='MeetingItemPga', UID=newItemWithEmptyDecisionUID)[0].getObject() self.failIf(obj.getDecision(keepWithNext=False) != '<p></p>')
def test_ws_getConfigInfosRequest(self): """ Test that getting informations about the configuration returns valuable informations """ # any PM user can have these configuration informations self.changeUser('pmCreator1') req = getConfigInfosRequest() # Serialize the request so it can be easily tested request = serializeRequest(req) # This is what the sent enveloppe should looks like expected = """<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" """ \ """xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" """ \ """xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" """ \ """xmlns:xsd="http://www.w3.org/2001/XMLSchema" """ \ """xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">""" \ """<SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body xmlns:ns1="http://ws4pm.imio.be">""" \ """<ns1:getConfigInfosRequest><showCategories>false</showCategories></ns1:getConfigInfosRequest>""" \ """</SOAP-ENV:Body></SOAP-ENV:Envelope>""" result = """%s""" % request self.assertEquals(expected, result) # now really use the SOAP method to get informations about the configuration responseHolder = getConfigInfosResponse() response = SOAPView(self.portal, req).getConfigInfosRequest(req, responseHolder) resp = deserialize(response) # construct the expected result : header + content + footer # header expected = """<ns1:getConfigInfosResponse xmlns:ns1="http://ws4pm.imio.be" """ \ """xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" """ \ """xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" """ \ """xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" """ \ """xmlns:xsd="http://www.w3.org/2001/XMLSchema" """ \ """xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">""" # _configInfo for cfg in self.tool.getActiveConfigs(): expected += """ <configInfo xsi:type="ns1:ConfigInfo"> <UID>%s</UID> <id>%s</id> <title>%s</title> <description>%s</description>%s </configInfo>""" % (cfg.UID(), cfg.getId(), cfg.Title(), cfg.Description(), self._getItemPositiveDecidedStatesFromConfig(cfg)) # _groupInfo for grp in get_organizations(): expected += """ <groupInfo xsi:type="ns1:GroupInfo"> <UID>%s</UID> <id>%s</id> <title>%s</title> <description>%s</description> </groupInfo>""" % (grp.UID(), grp.getId(), grp.Title(), grp.Description()) # footer. Empty description is represented like <description/> expected = expected.replace('<description></description>', '<description/>') \ + "\n</ns1:getConfigInfosResponse>\n" self.assertEquals(expected, resp) # elements are correctly stored cfg = self.tool.getActiveConfigs()[0] self.assertEqual(response._configInfo[0]._id, cfg.id) self.assertEqual(response._configInfo[0]._title, cfg.Title())
def test_ws_searchItemsRequest(self): """ Test that searching with given parameters returns valuable informations """ # by default no item exists self.changeUser('pmCreator1') self.assertEqual( len(self.portal.portal_catalog(portal_type='MeetingItemPga')), 0) # prepare data for a default item req = self._prepareCreationData() req._creationData._externalIdentifier = 'my_external_app_identifier' # use the SOAP service to create one newItem, response = self._createItem(req) # make sure created enough in the past or sort_on 'created' returns random result newItem.setCreationDate(DateTime() - 5) newItem.reindexObject() newItemUID = newItem.UID() # externalIdentifier is actually set self.assertEqual(newItem.externalIdentifier, 'my_external_app_identifier') # now an item exists, get informations about it req = searchItemsRequest() req._Title = 'item' req._getCategory = 'development' # Serialize the request so it can be easily tested request = serializeRequest(req) # This is what the sent enveloppe should looks like expected = """<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" """ \ """xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" """ \ """xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" """ \ """xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">""" \ """<SOAP-ENV:Header></SOAP-ENV:Header>""" \ """<SOAP-ENV:Body xmlns:ns1="http://ws4pm.imio.be"><ns1:searchItemsRequest>""" \ """<Title>%s</Title><getCategory>%s</getCategory></ns1:searchItemsRequest>""" \ """</SOAP-ENV:Body></SOAP-ENV:Envelope>""" % (req._Title, req._getCategory) result = """%s""" % request self.assertEqual(expected, result) # now really use the SOAP method to get informations about the item resp = self._searchItems(req) # the item is not in a meeting so the meeting date is 1950-01-01 expected = """<ns1:searchItemsResponse xmlns:ns1="http://ws4pm.imio.be" """ \ """xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" """ \ """xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" """ \ """xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" """ \ """xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <itemInfo xsi:type="ns1:ItemInfo"> <UID>{0}</UID> <id>my-new-item-title</id> <title>My new item title</title> <creator>pmCreator1</creator> <creation_date>{1}</creation_date> <modification_date>{2}</modification_date> <category>development</category> <description><p>Description</p></description> <detailedDescription><p>Detailed description</p></detailedDescription> <decision><p>Décision</p></decision> <preferredMeeting/> <preferred_meeting_date>1950-01-01T00:00:00.006Z</preferred_meeting_date> <review_state>itemcreated</review_state> <meeting_date>1950-01-01T00:00:00.006Z</meeting_date> <absolute_url>http://nohost/plone/Members/pmCreator1/mymeetings/plonegov-assembly/my-new-item-title</absolute_url> <externalIdentifier>my_external_app_identifier</externalIdentifier> <extraInfos/> </itemInfo> </ns1:searchItemsResponse> """.format(newItemUID, gDateTime.get_formatted_content(gDateTime(), localtime(newItem.created())), gDateTime.get_formatted_content(gDateTime(), localtime(newItem.modified()))) self.assertEqual(expected, resp) # if the item is in a meeting, the result is a bit different because # we have valid informations about the meeting_date # use the 'plonegov-assembly' MeetingConfig that use real categories, # not useGroupsAsCategories self.changeUser('pmManager') meeting = self._createMeetingWithItems() itemInMeeting = meeting.get_items(ordered=True)[0] # by default, PloneMeeting creates item without title/description/decision... itemInMeeting.setTitle('My new item title') itemInMeeting.setDescription('<p>Description</p>', mimetype='text/x-html-safe') itemInMeeting.setDecision('<p>Décision</p>', mimetype='text/x-html-safe') itemInMeeting.reindexObject() req._Title = 'item title' req._getCategory = '' resp = self._searchItems(req) itemInMeetingUID = itemInMeeting.UID() meetingDate = gDateTime.get_formatted_content( gDateTime(), meeting.date.utctimetuple()) # searching for items can returns several items # for example here, searching for 'item title' in existing items title will returns 2 items... expected = """<ns1:searchItemsResponse xmlns:ns1="http://ws4pm.imio.be" """ \ """xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" """ \ """xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" """ \ """xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" """ \ """xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <itemInfo xsi:type="ns1:ItemInfo"> <UID>{0}</UID> <id>my-new-item-title</id> <title>My new item title</title> <creator>pmCreator1</creator> <creation_date>{1}</creation_date> <modification_date>{2}</modification_date> <category>development</category> <description><p>Description</p></description> <detailedDescription><p>Detailed description</p></detailedDescription> <decision><p>Décision</p></decision> <preferredMeeting/> <preferred_meeting_date>1950-01-01T00:00:00.006Z</preferred_meeting_date> <review_state>itemcreated</review_state> <meeting_date>1950-01-01T00:00:00.006Z</meeting_date> <absolute_url>http://nohost/plone/Members/pmCreator1/mymeetings/plonegov-assembly/my-new-item-title</absolute_url> <externalIdentifier>my_external_app_identifier</externalIdentifier> <extraInfos/> </itemInfo> <itemInfo xsi:type="ns1:ItemInfo"> <UID>{3}</UID> <id>item-2</id> <title>My new item title</title> <creator>pmManager</creator> <creation_date>{4}</creation_date> <modification_date>{5}</modification_date> <category>development</category> <description><p>Description</p></description> <detailedDescription/> <decision><p>Décision</p></decision> <preferredMeeting/> <preferred_meeting_date>1950-01-01T00:00:00.006Z</preferred_meeting_date> <review_state>presented</review_state> <meeting>{6}</meeting> <meeting_date>{7}</meeting_date> <absolute_url>http://nohost/plone/Members/pmManager/mymeetings/plonegov-assembly/item-2</absolute_url> <externalIdentifier/> <extraInfos/> </itemInfo> </ns1:searchItemsResponse> """.format(newItemUID, gDateTime.get_formatted_content(gDateTime(), localtime(newItem.created())), gDateTime.get_formatted_content(gDateTime(), localtime(newItem.modified())), itemInMeetingUID, gDateTime.get_formatted_content(gDateTime(), localtime(itemInMeeting.created())), gDateTime.get_formatted_content(gDateTime(), localtime(itemInMeeting.modified())), meeting.UID(), meetingDate) self.assertEqual(expected, resp) # if the search params do not return an existing UID, the response is empty req._Title = 'aWrongTitle' resp = self._searchItems(req) expected = """<ns1:searchItemsResponse xmlns:ns1="http://ws4pm.imio.be" """ \ """xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" """ \ """xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" """ \ """xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" """ \ """xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/> """ self.assertEqual(resp, expected) # if not search params is pass, a ZSI.Fault is raised req._Title = '' responseHolder = searchItemsResponse() with self.assertRaises(ZSI.Fault) as cm: SOAPView(self.portal, req).searchItemsRequest(req, responseHolder) self.assertEqual(cm.exception.string, 'Define at least one search parameter!') # if a 'meetingConfigId' is passed, items of this meetingConfig are taken into account # create an item for 'plonemeeting-assembly' with same data as one created for 'plonegov-assembly' here above req = self._prepareCreationData() req._meetingConfigId = 'plonemeeting-assembly' # in 'plonemeeting-assembly', the category is not used, useGroupsAsCategories is True req._creationData._category = '' newItem, response = self._createItem(req) pmItem = self.portal.portal_catalog(UID=response._UID)[0].getObject() pmItemUID = pmItem.UID() # searching items with Title like 'item title' returns the 3 created elements req = searchItemsRequest() req._Title = 'item title' responseHolder = searchItemsResponse() response = SOAPView(self.portal, req).searchItemsRequest(req, responseHolder) resp = deserialize(response) self.failUnless(itemInMeetingUID in resp and newItemUID in resp and pmItemUID in resp) req._meetingConfigId = 'plonemeeting-assembly' response = SOAPView(self.portal, req).searchItemsRequest(req, responseHolder) resp = deserialize(response) self.failUnless(itemInMeetingUID not in resp and newItemUID not in resp and pmItemUID in resp) # passing a wrong meetingConfigId will raise a ZSI.Fault req._meetingConfigId = 'wrongMeetingConfigId' with self.assertRaises(ZSI.Fault) as cm: SOAPView(self.portal, req).searchItemsRequest(req, responseHolder) self.assertEqual(cm.exception.string, "Unknown meetingConfigId : 'wrongMeetingConfigId'!")