def testDelete(self): postArguments = [] def _httppost(**kwargs): postArguments.append(kwargs) raise StopIteration(('HTTP/1.0 200 OK\r\n\r\n', SRU_UPDATE_RESPONSE % ("success", ''))) yield sruUpdate = SruUpdateClient(host='localhost', port=1234, userAgent="testAgent") sruUpdate._httppost = _httppost list(compose(sruUpdate.delete(identifier='anIdentifier'))) self.assertEquals(1, len(postArguments)) arguments = postArguments[0] self.assertEquals('localhost', arguments['host']) self.assertEquals(1234, arguments['port']) self.assertEquals('/update', arguments['request']) self.assertEquals({"User-Agent": "testAgent", "Host": 'localhost'}, arguments['headers']) self.assertEqualsWS("""<?xml version="1.0" encoding="UTF-8"?> <ucp:updateRequest xmlns:srw="http://www.loc.gov/zing/srw/" xmlns:ucp="info:lc/xmlns/update-v1"> <srw:version>1.0</srw:version> <ucp:action>info:srw/action/1/delete</ucp:action> <ucp:recordIdentifier>anIdentifier</ucp:recordIdentifier> <srw:record> <srw:recordPacking>xml</srw:recordPacking> <srw:recordSchema>ignored</srw:recordSchema> <srw:recordData><ignored/></srw:recordData> </srw:record> </ucp:updateRequest>""", arguments['body'])
def testDelete(self): postArguments = [] def _httppost(**kwargs): postArguments.append(kwargs) raise StopIteration(('HTTP/1.0 200 OK\r\n\r\n', SRU_UPDATE_RESPONSE % ("success", ''))) yield sruUpdate = SruUpdateClient(host='localhost', port=1234, userAgent="testAgent") sruUpdate._httppost = _httppost list(compose(sruUpdate.delete(identifier='anIdentifier'))) self.assertEquals(1, len(postArguments)) arguments = postArguments[0] self.assertEquals('localhost', arguments['host']) self.assertEquals(1234, arguments['port']) self.assertEquals('/update', arguments['request']) self.assertEquals({ "User-Agent": "testAgent", "Host": 'localhost' }, arguments['headers']) self.assertEqualsWS( """<?xml version="1.0" encoding="UTF-8"?> <ucp:updateRequest xmlns:srw="http://www.loc.gov/zing/srw/" xmlns:ucp="info:lc/xmlns/update-v1"> <srw:version>1.0</srw:version> <ucp:action>info:srw/action/1/delete</ucp:action> <ucp:recordIdentifier>anIdentifier</ucp:recordIdentifier> <srw:record> <srw:recordPacking>xml</srw:recordPacking> <srw:recordSchema>ignored</srw:recordSchema> <srw:recordData><ignored/></srw:recordData> </srw:record> </ucp:updateRequest>""", arguments['body'])