예제 #1
0
def create_place_of_performance_object(db_row_dict: dict) -> OrderedDict:
    return OrderedDict(
        [
            ("location_country_code", db_row_dict["_pop_location_country_code"]),
            ("country_name", db_row_dict["_pop_country_name"]),
            ("county_code", db_row_dict["_pop_county_code"]),
            ("county_name", db_row_dict["_pop_county_name"]),
            ("city_name", db_row_dict["_pop_city_name"]),
            (
                "state_code",
                db_row_dict["_pop_state_code"]
                if db_row_dict["_pop_state_code"]
                else state_code_from_name(db_row_dict["_pop_state_name"]),
            ),
            (
                "state_name",
                db_row_dict["_pop_state_name"]
                if db_row_dict["_pop_state_name"]
                else state_name_from_code(db_row_dict["_pop_state_code"]),
            ),
            ("congressional_code", db_row_dict["_pop_congressional_code"]),
            ("zip4", db_row_dict["_pop_zip4"]),
            ("zip5", db_row_dict["_pop_zip5"]),
            ("address_line1", None),
            ("address_line2", None),
            ("address_line3", None),
            ("foreign_province", db_row_dict.get("_pop_foreign_province")),
            ("foreign_postal_code", None),
        ]
    )
예제 #2
0
def test_code_to_name():
    assert state_name_from_code("MD") == "Maryland"
    assert state_name_from_code("MH") == "Marshall Islands"
    assert state_name_from_code(None) is None