def test_to_file_v2_4_chips(tmpfile, chip):
    chips = [copy.deepcopy(chip) for i in range(10)]
    for i, chip in enumerate(chips):
        chip.chip_id = i
    chips[0].config.pixel_trim_dac[12] = 0
    chips[1].config.threshold_global = 1
    to_file(tmpfile, chip_list=chips, version='2.4')
    new_chips = from_file(tmpfile, load_configs=True)['configs']
    assert [chip.chip_key
            for chip in chips] == [chip.chip_key for chip in new_chips]
    assert [chip.config
            for chip in chips] == [chip.config for chip in new_chips]
    assert new_chips[0].config.pixel_trim_dac[12] == chips[
        0].config.pixel_trim_dac[12]
    assert new_chips[1].config.threshold_global == chips[
        1].config.threshold_global

    new_chips = from_file(tmpfile, load_configs=slice(1, 4))['configs']
    assert len(new_chips) == 3
    assert new_chips[0].chip_key == chips[1].chip_key
예제 #2
0
def test_from_file_v0_0_many_packets(tmpfile, data_packet, config_read_packet,
                                     timestamp_packet):
    packets = [data_packet, config_read_packet, timestamp_packet]
    to_file(tmpfile, packets, version='0.0')
    new_packets_dict = from_file(tmpfile, version='0.0')
    assert new_packets_dict['created']
    assert new_packets_dict['version']
    assert new_packets_dict['modified']
    new_packets = new_packets_dict['packets']
    assert new_packets[0] == data_packet
    assert new_packets[1] == config_read_packet
    assert new_packets[2] == timestamp_packet
예제 #3
0
def test_from_file_v2_0_many_packets(tmpfile, data_packet_v2,
                                     config_read_packet_v2, timestamp_packet,
                                     message_packet):
    packets = [
        data_packet_v2, config_read_packet_v2, timestamp_packet, message_packet
    ]
    to_file(tmpfile, packets, version='2.0')
    new_packets_dict = from_file(tmpfile)
    assert new_packets_dict['created']
    assert new_packets_dict['version']
    assert new_packets_dict['modified']
    new_packets = new_packets_dict['packets']
    _ = [
        print(str(packet) + '\n' + str(packets[i]))
        for i, packet in enumerate(new_packets)
    ]
    assert new_packets[0] == data_packet_v2
    assert new_packets[1] == config_read_packet_v2
    assert new_packets[2] == timestamp_packet
    assert new_packets[3] == message_packet
예제 #4
0
def test_from_file_incompatible(tmpfile):
    to_file(tmpfile, [], version='0.0')
    with pytest.raises(RuntimeError):
        from_file(tmpfile, version='1.0')
        pytest.fail('Should identify incompatible version')