"""Synthetic conversation records for the native speaker report.""" import csv import pathlib import struct import subprocess import sys import tempfile import unittest sys.path.insert(0, str(pathlib.Path(__file__).parent)) from test_psin_data import make_container, ptr # noqa: E402 from test_psin_index import joaat # noqa: E402 from psin_dialogue import speaker_rows # noqa: E402 ROOT = pathlib.Path(__file__).resolve().parents[1] # Schema identifiers and offsets describe the disk format. Payloads and names below are invented. SCHEMA = [ (0xEDAF33B4, 1, 88, 3, [(0x827F53FD, 16, 0x52, 0, 0, 0), (0xCDE324D0, 32, 0x52, 0, 0, 0)]), (0x1638FDAA, 2, 20, 2, [(0xB2A5A79B, 0, 0x4A, 0, 0, 0), (0xBD6915B4, 4, 0x14, 0, 0, 0)]), (0x06A04D25, 3, 64, 3, [(0x53C6B42D, 0, 0x52, 0, 0, 0), (0x59519816, 24, 0x15, 0, 0, 0)]), (0x7622C7F9, 4, 40, 3, [(0x9624A3B6, 0, 0x42, 0, 0, 0), (0x66FB3A21, 8, 0x42, 0, 0, 0)]), ] SPEAKERS = (joaat("InventedFirst"), joaat("InventedSecond")) def sample(*, second_slot=7, array_capacity=1, invalid_string=False, wrong_schema=False, duplicate_slot=False): # The same cue, label and slot are used in two conversations with different participants. groups = bytearray(176) participants = bytearray(40) turns = bytearray(128) lines = bytearray(80) cue = b"FISHING_CUE\0" strings = cue + b"FICTIONAL_AB_1\0" for i, character in enumerate(SPEAKERS): struct.pack_into("