コード例 #1
0
def new_york_data_copy():
    lat = 40.7
    lon = -74.0
    alt = 10

    new_york = Place("New York", lat, lon, alt)

    new_york_forecast = Forecast(new_york, USER_AGENT, "compact",
                                 SAVE_LOCATION)
    new_york_forecast.load()

    return new_york_forecast.data
コード例 #2
0
        def test_place_parameter(self):
            place = "not a Place object"

            with pytest.raises(TypeError):
                Forecast(
                    place, "compact", USER_AGENT
                )  # type: ignore # We are testing what happens if wrong type is passed # noqa: E501
コード例 #3
0
    def london_forecast(self):
        lat = 51.5
        lon = -0.1
        alt = 25

        london = Place("London", lat, lon, alt)

        return Forecast(london, USER_AGENT, "complete", SAVE_LOCATION)
コード例 #4
0
    def new_york_forecast(self):
        lat = 40.7
        lon = -74.0
        alt = 10

        new_york = Place("New York", lat, lon, alt)

        return Forecast(new_york, USER_AGENT, "compact", SAVE_LOCATION)
コード例 #5
0
        def test_forecast_type_parameter(self):
            lat = 40.7
            lon = -74.0
            alt = 10
            new_york = Place("New York", lat, lon, alt)

            type = "unsupported type"

            with pytest.raises(ValueError):
                Forecast(new_york, type, USER_AGENT)
コード例 #6
0
    def beijing_forecast(self):
        lat = 39.9
        lon = 116.4

        beijing = Place("Beijing", lat, lon)

        base_url = "somewhere.com/met-api/"

        return Forecast(beijing, USER_AGENT, "compact", SAVE_LOCATION,
                        base_url)
コード例 #7
0
        def test_forecast_type_with_custom_url(self):
            lat = 40.7
            lon = -74.0
            alt = 10
            new_york = Place("New York", lat, lon, alt)

            type = ""
            base_url = "custom-domain.com/"

            forecast = Forecast(new_york, USER_AGENT, type, base_url=base_url)

            assert isinstance(forecast, Forecast)
            assert forecast.url == "custom-domain.com/"