def test_call_inactive(): obj = KeyValueComposer() obj.ArrayReader = MockArrayReader obj.active = False event = MockEvent() assert () == obj(event)
def test_call_2Keys_1Val(): obj = KeyValueComposer() obj.active = True obj._lenkey = 2 obj.binnings = (MockBinningFloor(max=30), MockBinningFloor(max=50)) array_reader = MockArrayReader() obj._array_reader = array_reader event = MockEvent() array_reader.ret = ((15.3, 22.8, 101.1), ) assert ( ((15, 22), (101.1, )), ) == obj(event) array_reader.ret = ((45.3, 22.8, 101.1), ) # 1st element out of range assert () == obj(event) array_reader.ret = ((15.3, 52.8, 101.1), ) # 2nd element out of range assert () == obj(event) array_reader.ret = ((45.3, 52.8, 101.1), ) # both out of range assert () == obj(event)
def test_call_inactive(): obj = KeyValueComposer() obj.ArrayReader = MockArrayReader obj.active = False event = MockEvent() assert () == obj(event)
def test_call_raise(): obj = KeyValueComposer() obj.active = True array_reader = MockArrayReaderRaise() obj._array_reader = array_reader event = MockEvent() with pytest.raises(Exception): obj(event)
def test_call_raise(): obj = KeyValueComposer() obj.active = True array_reader = MockArrayReaderRaise() obj._array_reader = array_reader event = MockEvent() with pytest.raises(Exception): obj(event)
def test_call_NoneKey_NoneVal(): obj = KeyValueComposer() obj.active = True obj._lenkey = 0 obj.binnings = None array_reader = MockArrayReader() obj._array_reader = array_reader event = MockEvent() array_reader.ret = ((), ) assert (((), ()), ) == obj(event)
def test_call_2Keys_1Val_NoneBinnings(): obj = KeyValueComposer() obj.active = True obj._lenkey = 2 obj.binnings = None array_reader = MockArrayReader() obj._array_reader = array_reader event = MockEvent() array_reader.ret = ((15.3, 22.8, 101.1), ) assert (((15.3, 22.8), (101.1, )), ) == obj(event)
def test_call_NoneKey_1Val(): obj = KeyValueComposer() obj.active = True obj._lenkey = 0 obj.binnings = None array_reader = MockArrayReader() obj._array_reader = array_reader event = MockEvent() array_reader.ret = ((12.8, ), ) assert (((), (12.8, )), ) == obj(event)
def test_call_2Keys_1Val_NoneBinnings(): obj = KeyValueComposer() obj.active = True obj._lenkey = 2 obj.binnings = None array_reader = MockArrayReader() obj._array_reader = array_reader event = MockEvent() array_reader.ret = ((15.3, 22.8, 101.1), ) assert ( ((15.3, 22.8), (101.1, )), ) == obj(event)
def test_call_1Key_1Val(): obj = KeyValueComposer() obj.active = True obj._lenkey = 1 obj.binnings = (MockBinningFloor(max=30), ) array_reader = MockArrayReader() obj._array_reader = array_reader event = MockEvent() array_reader.ret = ((12.5, 20.3), ) assert (((12, ), (20.3, )), ) == obj(event) array_reader.ret = ((32.5, 20.3), ) assert () == obj(event)
def test_call_1Key_1Val(): obj = KeyValueComposer() obj.active = True obj._lenkey = 1 obj.binnings = (MockBinningFloor(max=30), ) array_reader = MockArrayReader() obj._array_reader = array_reader event = MockEvent() array_reader.ret = ((12.5, 20.3), ) assert ( ((12, ), (20.3, )), ) == obj(event) array_reader.ret = ((32.5, 20.3), ) assert () == obj(event)
def test_call_2Keys_1Val(): obj = KeyValueComposer() obj.active = True obj._lenkey = 2 obj.binnings = (MockBinningFloor(max=30), MockBinningFloor(max=50)) array_reader = MockArrayReader() obj._array_reader = array_reader event = MockEvent() array_reader.ret = ((15.3, 22.8, 101.1), ) assert (((15, 22), (101.1, )), ) == obj(event) array_reader.ret = ((45.3, 22.8, 101.1), ) # 1st element out of range assert () == obj(event) array_reader.ret = ((15.3, 52.8, 101.1), ) # 2nd element out of range assert () == obj(event) array_reader.ret = ((45.3, 52.8, 101.1), ) # both out of range assert () == obj(event)