def test_8bitReceiving(self): d = defer.Deferred() rvr = client.ResponseReceiver(d, decode_utf8=False) data = util.eight_bit_test_string() d.addCallback(lambda out: self.assertEqual(out, data)) for c in data: rvr.dataReceived(c) rvr.connectionLost(Failure(ResponseDone()))
def test_openDocAttachment(self): """ Test opening an attachment with openDoc. """ attachment_name = 'bindata.dat' attachment_data = util.eight_bit_test_string() doc_id = 'foo' body = {"value": "mybody"} self.db.addAttachments(body, {attachment_name: attachment_data}) yield self._saveDoc(body, doc_id) retrieved_data = yield self.db.openDoc(self.db_name, doc_id, attachment=attachment_name) self.assertEquals(retrieved_data, attachment_data)