def test_ipv6_interface_address(self): config = recv.UdpIbvConfig(endpoints=[('239.255.88.88', 8888)], interface_address='::1') stream = recv.Stream(spead2.ThreadPool(), recv.StreamConfig(), recv.RingStreamConfig()) with pytest.raises(ValueError, match='interface address'): stream.add_udp_ibv_reader(config)
def test_bad_interface_address(self): config = recv.UdpIbvConfig( endpoints=[('239.255.88.88', 8888)], interface_address='this is not an interface address') stream = recv.Stream(spead2.ThreadPool(), recv.StreamConfig(), recv.RingStreamConfig()) with pytest.raises(RuntimeError, match='Host not found'): stream.add_udp_ibv_reader(config)
def test_default_construct(self): config = recv.UdpIbvConfig() assert config.endpoints == [] assert config.interface_address == '' assert config.buffer_size == recv.UdpIbvConfig.DEFAULT_BUFFER_SIZE assert config.max_size == recv.UdpIbvConfig.DEFAULT_MAX_SIZE assert config.comp_vector == 0 assert config.max_poll == spead2.send.UdpIbvConfig.DEFAULT_MAX_POLL
def test_ipv6_endpoints(self): config = recv.UdpIbvConfig(endpoints=[('::1', 8888)], interface_address='10.0.0.1') stream = recv.Stream(spead2.ThreadPool(), recv.StreamConfig(), recv.RingStreamConfig()) with pytest.raises(ValueError, match='endpoint is not an IPv4 address'): stream.add_udp_ibv_reader(config)
def test_kwargs_construct(self): config = recv.UdpIbvConfig(endpoints=[('hello', 1234), ('goodbye', 2345)], interface_address='1.2.3.4', buffer_size=100, max_size=4321, comp_vector=-1, max_poll=1000) assert config.endpoints == [('hello', 1234), ('goodbye', 2345)] assert config.interface_address == '1.2.3.4' assert config.buffer_size == 100 assert config.max_size == 4321 assert config.comp_vector == -1 assert config.max_poll == 1000
def test_no_endpoints(self): config = recv.UdpIbvConfig(interface_address='10.0.0.1') stream = recv.Stream(spead2.ThreadPool(), recv.StreamConfig(), recv.RingStreamConfig()) with pytest.raises(ValueError, match='endpoints is empty'): stream.add_udp_ibv_reader(config)
def test_bad_max_size(self): config = recv.UdpIbvConfig() with pytest.raises(ValueError): config.max_size = 0
def test_bad_max_poll(self): config = recv.UdpIbvConfig() with pytest.raises(ValueError): config.max_poll = 0 with pytest.raises(ValueError): config.max_poll = -1
def test_default_buffer_size(self): config = recv.UdpIbvConfig() config.buffer_size = 0 assert config.buffer_size == recv.UdpIbvConfig.DEFAULT_BUFFER_SIZE