Пример #1
0
def test_create_dictionaries_many2():
    """
    Should return array with dictionaries as elements if splitting each spatial field on
    semicolons produces multiple strings in any spatial field.
    """
    INPUT = [
        {
            "city": "La Jolla;Pasadena",
            "county": "San Diego;Los Angeles;Buncombe",
            "state": "California;North Carolina",
            "country": "United States",
            "iso3166-2": "US-CA;US-NC",
        }
    ]
    EXPECTED = [
        {
            "city": "La Jolla",
            "county": "San Diego",
            "state": "California",
            "country": "United States",
            "iso3166-2": "US-CA",
        },
        {"city": "Pasadena", "county": "Los Angeles", "state": "North Carolina", "iso3166-2": "US-NC"},
        {"county": "Buncombe"},
    ]

    OUTPUT = create_dictionaries(INPUT)
    assert OUTPUT == EXPECTED
def test_create_dictionaries_many2():
    """
    Should return array with dictionaries as elements if splitting each spatial field on
    semicolons produces multiple strings in any spatial field.
    """
    INPUT = [{
        "city": "La Jolla;Pasadena",
        "county": "San Diego;Los Angeles;Buncombe",
        "state": "California;North Carolina",
        "country": "United States",
        "iso3166-2": "US-CA;US-NC"
    }]
    EXPECTED = [
        {
            "city": "La Jolla",
            "county": "San Diego",
            "state": "California",
            "country": "United States",
            "iso3166-2": "US-CA"
        },
        {
            "city": "Pasadena",
            "county": "Los Angeles",
            "state": "North Carolina",
            "iso3166-2": "US-NC"
        },
        {
            "county": "Buncombe"
        }
    ]

    OUTPUT = create_dictionaries(INPUT)
    assert OUTPUT == EXPECTED
Пример #3
0
def test_create_dictionaries_one():
    """
    Should return array with one dictionary as the only element if splitting each spatial field on
    semicolons produces only one string for each spatial field.
    """
    INPUT = [
        {
            "city": "Asheville",
            "county": "Buncombe",
            "state": "North Carolina;",
            "country": "United States",
            "iso3166-2": "US-NC",
        }
    ]
    EXPECTED = [
        {
            "city": "Asheville",
            "county": "Buncombe",
            "state": "North Carolina",
            "country": "United States",
            "iso3166-2": "US-NC",
        }
    ]

    OUTPUT = create_dictionaries(INPUT)
    assert OUTPUT == EXPECTED
Пример #4
0
def test_create_dictionaries_one():
    """
    Should return array with one dictionary as the only element if splitting each spatial field on
    semicolons produces only one string for each spatial field.
    """
    INPUT = [{
        "city": "Asheville",
        "county": "Buncombe",
        "state": "North Carolina;",
        "country": "United States",
        "iso3166-2": "US-NC"
    }]
    EXPECTED = [{
        "city": "Asheville",
        "county": "Buncombe",
        "state": "North Carolina",
        "country": "United States",
        "iso3166-2": "US-NC"
    }]

    OUTPUT = create_dictionaries(INPUT)
    assert OUTPUT == EXPECTED