예제 #1
0
        async def inner_test() -> None:
            async with TestServer(handler=BinaryHandler(self), ip="::1") as sa:
                assert sa.ip and sa.port
                async with get_client(BinaryService, host=sa.ip,
                                      port=sa.port) as client:
                    val: Any
                    val = await client.sendRecvBinaries(
                        Binaries(
                            no_special_type=b'c1',
                            iobuf_val=IOBuf(b'c2'),
                            iobuf_ptr=IOBuf(b'c3'),
                            fbstring=b'c4',
                            nonstandard_type=b'c5',
                        ))
                    self.assertEqual(val.no_special_type, b's1')
                    self.assertEqual(bytes(val.iobuf_val), b's2')
                    assert val.iobuf_ptr is not None
                    self.assertEqual(bytes(val.iobuf_ptr), b's3')
                    self.assertEqual(val.fbstring, b's4')
                    self.assertEqual(val.nonstandard_type, b's5')

                    val = await client.sendRecvBinary(b'cv1')
                    self.assertEqual(val, b'sv1')

                    val = await client.sendRecvIOBuf(IOBuf(b'cv2'))
                    self.assertEqual(bytes(val), b'sv2')

                    val = await client.sendRecvIOBufPtr(IOBuf(b'cv3'))
                    self.assertEqual(bytes(val), b'sv3')

                    val = await client.sendRecvFbstring(b'cv4')
                    self.assertEqual(val, b'sv4')

                    val = await client.sendRecvBuffer(b'cv5')
                    self.assertEqual(val, b'sv5')
예제 #2
0
 async def sendRecvBinaries(self, val: Binaries) -> Binaries:
     self.unit_test.assertEqual(val.no_special_type, b"c1")
     self.unit_test.assertEqual(bytes(val.iobuf_val), b"c2")
     assert val.iobuf_ptr is not None
     self.unit_test.assertEqual(bytes(val.iobuf_ptr), b"c3")
     self.unit_test.assertEqual(val.fbstring, b"c4")
     self.unit_test.assertEqual(val.nonstandard_type, b"c5")
     return Binaries(
         no_special_type=b"s1",
         iobuf_val=IOBuf(b"s2"),
         iobuf_ptr=IOBuf(b"s3"),
         fbstring=b"s4",
         nonstandard_type=b"s5",
     )
예제 #3
0
 def test_various_binary_types(self) -> None:
     val = Binaries(
         no_special_type=b"abcdef",
         iobuf_val=IOBuf(b"mnopqr"),
         iobuf_ptr=IOBuf(b"ghijkl"),
         fbstring=b"stuvwx",
         nonstandard_type=b"yzabcd",
     )
     self.assertEqual(val.no_special_type, b"abcdef")
     self.assertEqual(bytes(val.iobuf_val), b"mnopqr")
     assert val.iobuf_ptr is not None
     self.assertEqual(bytes(val.iobuf_ptr), b"ghijkl")
     self.assertEqual(val.fbstring, b"stuvwx")
     self.assertEqual(val.nonstandard_type, b"yzabcd")
예제 #4
0
 async def sendRecvBinaries(self, val: Binaries) -> Binaries:
     self.unit_test.assertEqual(val.no_special_type, b'c1')
     self.unit_test.assertEqual(bytes(val.iobuf_val), b'c2')
     assert val.iobuf_ptr is not None
     self.unit_test.assertEqual(bytes(val.iobuf_ptr), b'c3')
     self.unit_test.assertEqual(val.fbstring, b'c4')
     self.unit_test.assertEqual(val.nonstandard_type, b'c5')
     return Binaries(
         no_special_type=b's1',
         iobuf_val=IOBuf(b's2'),
         iobuf_ptr=IOBuf(b's3'),
         fbstring=b's4',
         nonstandard_type=b's5',
     )
예제 #5
0
 def test_various_binary_types(self) -> None:
     val = Binaries(
         no_special_type=b'abcdef',
         iobuf_val=IOBuf(b'mnopqr'),
         iobuf_ptr=IOBuf(b'ghijkl'),
         fbstring=b'stuvwx',
         nonstandard_type=b'yzabcd',
     )
     self.assertEqual(val.no_special_type, b'abcdef')
     self.assertEqual(bytes(val.iobuf_val), b'mnopqr')
     assert val.iobuf_ptr is not None
     self.assertEqual(bytes(val.iobuf_ptr), b'ghijkl')
     self.assertEqual(val.fbstring, b'stuvwx')
     self.assertEqual(val.nonstandard_type, b'yzabcd')
예제 #6
0
파일: binary.py 프로젝트: nathacof/fbthrift
        async def inner_test() -> None:
            async with TestServer(handler=BinaryHandler(self), ip="::1") as sa:
                ip, port = sa.ip, sa.port
                assert ip and port
                # pyre-fixme[6]: Expected `Union[ipaddress.IPv4Address,
                #  ipaddress.IPv6Address, str]` for 2nd param but got `Union[None,
                #  ipaddress.IPv4Address, ipaddress.IPv6Address]`.
                async with get_client(BinaryService, host=ip,
                                      port=port) as client:
                    val: Any
                    val = await client.sendRecvBinaries(
                        Binaries(
                            no_special_type=b"c1",
                            iobuf_val=IOBuf(b"c2"),
                            iobuf_ptr=IOBuf(b"c3"),
                            fbstring=b"c4",
                            nonstandard_type=b"c5",
                        ))
                    self.assertEqual(val.no_special_type, b"s1")
                    self.assertEqual(bytes(val.iobuf_val), b"s2")
                    assert val.iobuf_ptr is not None
                    self.assertEqual(bytes(val.iobuf_ptr), b"s3")
                    self.assertEqual(val.fbstring, b"s4")
                    self.assertEqual(val.nonstandard_type, b"s5")

                    val = await client.sendRecvBinary(b"cv1")
                    self.assertEqual(val, b"sv1")

                    val = await client.sendRecvIOBuf(IOBuf(b"cv2"))
                    self.assertEqual(bytes(val), b"sv2")

                    val = await client.sendRecvIOBufPtr(IOBuf(b"cv3"))
                    self.assertEqual(bytes(val), b"sv3")

                    val = await client.sendRecvFbstring(b"cv4")
                    self.assertEqual(val, b"sv4")

                    val = await client.sendRecvBuffer(b"cv5")
                    self.assertEqual(val, b"sv5")

                    bu = BinaryUnion(iobuf_val=IOBuf(b"cv6"))
                    val = await client.sendRecBinaryUnion(bu)
                    self.assertEqual(bytes(val.iobuf_val), b"sv6")
예제 #7
0
        async def inner_test() -> None:
            async with TestServer(handler=BinaryHandler(self), ip="::1") as sa:
                ip, port = sa.ip, sa.port
                assert ip and port
                async with get_client(BinaryService, host=ip,
                                      port=port) as client:
                    # pyre-fixme[33]: Given annotation cannot be `Any`.
                    val: Any
                    val = await client.sendRecvBinaries(
                        Binaries(
                            no_special_type=b"c1",
                            iobuf_val=IOBuf(b"c2"),
                            iobuf_ptr=IOBuf(b"c3"),
                            fbstring=b"c4",
                            nonstandard_type=b"c5",
                        ))
                    self.assertEqual(val.no_special_type, b"s1")
                    self.assertEqual(bytes(val.iobuf_val), b"s2")
                    assert val.iobuf_ptr is not None
                    self.assertEqual(bytes(val.iobuf_ptr), b"s3")
                    self.assertEqual(val.fbstring, b"s4")
                    self.assertEqual(val.nonstandard_type, b"s5")

                    val = await client.sendRecvBinary(b"cv1")
                    self.assertEqual(val, b"sv1")

                    val = await client.sendRecvIOBuf(IOBuf(b"cv2"))
                    self.assertEqual(bytes(val), b"sv2")

                    val = await client.sendRecvIOBufPtr(IOBuf(b"cv3"))
                    self.assertEqual(bytes(val), b"sv3")

                    val = await client.sendRecvFbstring(b"cv4")
                    self.assertEqual(val, b"sv4")

                    val = await client.sendRecvBuffer(b"cv5")
                    self.assertEqual(val, b"sv5")

                    bu = BinaryUnion(iobuf_val=IOBuf(b"cv6"))
                    val = await client.sendRecBinaryUnion(bu)
                    self.assertEqual(bytes(val.iobuf_val), b"sv6")