コード例 #1
0
ファイル: translator.py プロジェクト: smsaladi/fire-1099
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
コード例 #2
0
def test_payer_fire_padding_zeros():
    temp = deepcopy(VALID_PAYER)
    temp["payer"]["record_sequence_number"] = "2"
    transformed = payer.xform(temp["payer"])
    test_string = payer.fire(transformed)
    sequence_num = test_string[499:507]
    assert sequence_num == "00000002"
コード例 #3
0
def test_payer_fire_padding_blanks():
    temp = deepcopy(VALID_PAYER)
    temp["payer"]["payer_shipping_address"] = "1234 ROADSTREET AVE"
    transformed = payer.xform(temp["payer"])
    test_string = payer.fire(transformed)
    addr = test_string[133:173]

    assert addr[0:19] == "1234 ROADSTREET AVE"
    assert addr[19:] == 21 * "\x00"
コード例 #4
0
def test_payer_xform_adds_system_fields():
    temp = deepcopy(VALID_PAYER)
    assert "blank_2" not in temp
    transformed = payer.xform(temp)
    assert "blank_2" in transformed
コード例 #5
0
def test_payer_xform_remove_punctuation():
    temp = deepcopy(VALID_PAYER)
    temp["payer"]["payer_telephone_number_and_ext"] = "(555)555-5555"
    transformed = payer.xform(temp["payer"])
    assert transformed["payer_telephone_number_and_ext"] == "5555555555"
コード例 #6
0
def test_payer_xform_uppercase():
    temp = deepcopy(VALID_PAYER)
    temp["payer"]["first_payer_name"] = "nocaps mclowercase"
    transformed = payer.xform(temp["payer"])
    assert transformed["first_payer_name"] == "NOCAPS MCLOWERCASE"
コード例 #7
0
def test_payer_fire_blanks_layout():
    temp = deepcopy(VALID_PAYER)
    transformed = payer.xform(temp["payer"])
    test_string = payer.fire(transformed)
    for (offset_1_indexed, inclusive_bound) in PAYER_BLANK_MAP:
        yield check_blanks, test_string[(offset_1_indexed - 1):inclusive_bound]
コード例 #8
0
def test_payer_fire_string_length():
    temp = deepcopy(VALID_PAYER)
    transformed = payer.xform(temp["payer"])
    test_string = payer.fire(transformed)
    assert len(test_string) == 750