コード例 #1
0
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)
コード例 #2
0
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)
コード例 #3
0
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)
コード例 #4
0
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)
コード例 #5
0
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)
コード例 #6
0
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)
コード例 #7
0
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)
コード例 #8
0
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)