コード例 #1
0
    def test_postal_code_with_multiple_places(self):
        # GIVEN a known postal code with exactly two places
        CP = '01030'

        # WHEN using the places method
        places = postalcodes_mexico.places(CP)

        # THEN it returns a list of two places
        assert isinstance(places, list)
        assert len(places) == 2
コード例 #2
0
    def test_four_digit_postal_code(self):
        # GIVEN an existing, 4-digit postal code for San Ángel
        CP = '1000'

        # WHEN using the places method
        places = postalcodes_mexico.places(CP)

        # THEN it returns San Ángel
        place = places[0]
        assert place.place == 'San Ángel'
コード例 #3
0
    def test_postal_code_with_one_place(self):
        # GIVEN postal code for San Ángel in Mexico City
        CP = '01000'

        # WHEN using the places method on this postal code
        my_places = postalcodes_mexico.places(CP)

        # THEN it returns a list with exactly one place that is San Ángel
        assert len(my_places) == 1

        my_place = my_places[0]
        assert my_place.postal_code == CP
        assert my_place.place == 'San Ángel'
        assert my_place.place_type == 'Colonia'
        assert my_place.municipality == 'Álvaro Obregón'
        assert my_place.city == 'Ciudad de México'
        assert my_place.state == 'Ciudad de México'
コード例 #4
0
    def test_places_are_named_tuples(self):
        # GIVEN an existing postal code
        CP = '01000'

        # WHEN using the places method
        my_places = postalcodes_mexico.places(CP)
        my_place = my_places[0]

        # THEN it returns a list of named tuples
        assert isinstance(my_places, list)
        assert isinstance(my_place, tuple)

        # AND all attributes can be called
        assert my_place.postal_code == CP
        assert my_place.place == 'San Ángel'
        assert my_place.place_type == 'Colonia'
        assert my_place.municipality == 'Álvaro Obregón'
        assert my_place.city == 'Ciudad de México'
        assert my_place.state == 'Ciudad de México'
コード例 #5
0
def main(postalcode):
    """Console script for postalcodes_mexico."""
    places = postalcodes_mexico.places(postalcode)
    click.echo(places)
    return 0