Example #1
0
def load_full_schema(data):
    """
    Merges data into the master schema for records, including fields that were
    not specified in the data originally loaded (such as system-generated fields
    and optional fields).

    Parameters
    ----------
    data : dict
        JSON data to be merged into master schema

    Returns
    ----------
    dict
        Master schema with all fields provided in input parameter included

    """
    merged_data = {
        "transmitter": "",
        "payer": "",
        "payees": [],
        "end_of_payer": "",
        "end_of_transmission": ""
    }
    merged_data["transmitter"] = transmitter.xform(data["transmitter"])
    merged_data["payer"] = payer.xform(data["payer"])
    merged_data["payees"] = payees.xform(data["payees"])
    merged_data["end_of_payer"] = end_of_payer.xform({})
    merged_data["end_of_transmission"] = end_of_transmission.xform({})

    return merged_data
Example #2
0
def test_payee_fire_padding_zeros():
    temp = deepcopy(VALID_PAYEE)
    temp[0]["record_sequence_number"] = "2"
    transformed = payees.xform(temp)
    test_string = payees.fire(transformed)
    sequence_num = test_string[499:507]
    assert sequence_num == "00000002"
Example #3
0
def test_payee_fire_padding_blanks():
    temp = deepcopy(VALID_PAYEE)
    temp[0]["payee_mailing_address"] = "1234 ROADSTREET AVE"
    transformed = payees.xform(temp)
    test_string = payees.fire(transformed)
    addr = test_string[367:407]

    assert addr[0:19] == "1234 ROADSTREET AVE"
    assert addr[19:] == 21*"\x00"
Example #4
0
def test_payee_xform_adds_system_fields():
    temp = deepcopy(VALID_PAYEE)
    assert "blank_2" not in temp
    transformed = payees.xform(temp)
    assert "blank_2" in transformed[0]
Example #5
0
def test_payee_xform_remove_punctuation():
    temp = deepcopy(VALID_PAYEE)
    temp[0]["payees_tin"] = "12-1234567"
    transformed = payees.xform(temp)
    assert transformed[0]["payees_tin"] == "121234567"
Example #6
0
def test_payee_xform_uppercase():
    temp = deepcopy(VALID_PAYEE)
    temp[0]["first_payee_name_line"] = "nocaps mclowercase"
    transformed = payees.xform(temp)
    assert transformed[0]["first_payee_name_line"] == "NOCAPS MCLOWERCASE"
Example #7
0
def test_payee_fire_blanks_layout():
    temp = deepcopy(VALID_PAYEE)
    transformed = payees.xform(temp)
    test_string = payees.fire(transformed)
    for (offset_1_indexed, inclusive_bound) in PAYEE_BLANK_MAP:
        yield check_blanks, test_string[(offset_1_indexed -1):inclusive_bound]
Example #8
0
def test_payee_fire_string_length():
    temp = deepcopy(VALID_PAYEE)
    transformed = payees.xform(temp)
    test_string = payees.fire(transformed)
    assert len(test_string) == 750*len(temp)