def testAddFailed(self): postArguments = [] def _httppost(**kwargs): postArguments.append(kwargs) raise StopIteration(('HTTP/1.0 200 OK\r\n\r\n', SRU_UPDATE_RESPONSE % ("fail", SRU_DIAGNOSTICS))) yield sruUpdate = SruUpdateClient() sruUpdate._httppost = _httppost sruUpdate.updateHostAndPort('localhost', 12345) try: list(compose(sruUpdate.add(identifier='anIdentifier', data='<xml/>'))) self.fail("should not get here") except SruUpdateException, e: self.assertEquals(e.url, 'http://localhost:12345/update') self.assertEquals(e.status, 'fail') self.assertEquals(e.diagnostics, 'Traceback: some traceback')
def testAddFailed(self): postArguments = [] def _httppost(**kwargs): postArguments.append(kwargs) raise StopIteration( ('HTTP/1.0 200 OK\r\n\r\n', SRU_UPDATE_RESPONSE % ("fail", SRU_DIAGNOSTICS))) yield sruUpdate = SruUpdateClient() sruUpdate._httppost = _httppost sruUpdate.updateHostAndPort('localhost', 12345) try: list( compose(sruUpdate.add(identifier='anIdentifier', data='<xml/>'))) self.fail("should not get here") except SruUpdateException, e: self.assertEquals(e.url, 'http://localhost:12345/update') self.assertEquals(e.status, 'fail') self.assertEquals(e.diagnostics, 'Traceback: some traceback')
def testAddFailed(self): postArguments = [] def _httppost(**kwargs): postArguments.append(kwargs) return [ dict(StatusCode="200"), SRU_UPDATE_RESPONSE % (b"fail", SRU_DIAGNOSTICS) ] yield sruUpdate = SruUpdateClient() sruUpdate._httppost = _httppost sruUpdate.updateHostAndPort('localhost', 12345) try: list( compose( sruUpdate.add(identifier='anIdentifier', data=b'<xml/>'))) self.fail("should not get here") except SruUpdateException as e: self.assertEqual(e.url, 'http://localhost:12345/update') self.assertEqual(e.status, 'fail') self.assertEqual(e.diagnostics, 'Traceback: some traceback')