Implement default precision=0 for upstream weatherapi endpoints
This commit is contained in:
@@ -43,7 +43,7 @@ config test suite.
|
||||
|
||||
- `base_url`: absolute base URL for the Weather API. Required for generation and collection workflows.
|
||||
- `timeout`: HTTP timeout duration. Default: `10s`.
|
||||
- `precision`: numeric precision query value. Default: `1`.
|
||||
- `precision`: numeric precision query value. Default: `0`, which requests integer values where supported.
|
||||
- `units`: Weather API units query value. Default: `us`.
|
||||
- `timezone`: report timezone and Weather API timezone query value where supported. Default: `America/Chicago`.
|
||||
- `format`: Weather API response format. Must be `json`. Default: `json`.
|
||||
|
||||
@@ -69,7 +69,8 @@ The adapter sends these query parameters:
|
||||
- `format`: from `weather_api.format`; configuration validation requires `json`
|
||||
- `units`: from `weather_api.units`
|
||||
- `precision`: from `weather_api.precision` on observations, current
|
||||
conditions, hourly forecast, and narrative forecast requests
|
||||
conditions, hourly forecast, and narrative forecast requests; the built-in
|
||||
default is `0`
|
||||
- `tz`: from `weather_api.timezone` on hourly forecast, narrative forecast,
|
||||
discussion, and SPC convective outlook requests
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
weather_api:
|
||||
base_url: https://weather.api.example.com/
|
||||
timeout: 15s
|
||||
precision: 1
|
||||
precision: 0
|
||||
units: us
|
||||
timezone: "America/Chicago"
|
||||
format: json
|
||||
|
||||
@@ -135,9 +135,15 @@ func TestFetchBundleBuildsExpectedQueries(t *testing.T) {
|
||||
t.Fatalf("request %q missing units=us", rawURL)
|
||||
}
|
||||
if strings.HasPrefix(rawURL, "/forecast/") {
|
||||
if !strings.Contains(rawURL, "precision=1") || !strings.Contains(rawURL, "tz=America%2FChicago") {
|
||||
if !strings.Contains(rawURL, "precision=0") || !strings.Contains(rawURL, "tz=America%2FChicago") {
|
||||
t.Fatalf("forecast request %q missing precision or tz", rawURL)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if rawURL == defaultWarmupEndpoint || strings.HasPrefix(rawURL, defaultWarmupEndpoint+"?") || strings.HasPrefix(rawURL, "/observations?") {
|
||||
if !strings.Contains(rawURL, "precision=0") {
|
||||
t.Fatalf("request %q missing precision=0", rawURL)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@ func TestDefaults(t *testing.T) {
|
||||
if cfg.WeatherAPI.Format != "json" {
|
||||
t.Fatalf("Format = %q, want json", cfg.WeatherAPI.Format)
|
||||
}
|
||||
if cfg.WeatherAPI.Precision != 0 {
|
||||
t.Fatalf("Precision = %d, want 0", cfg.WeatherAPI.Precision)
|
||||
}
|
||||
if cfg.Location.ID != "home" || cfg.Location.Name != "Brentwood" || cfg.Location.Region != "St. Louis Metro" {
|
||||
t.Fatalf("Location = %#v, want home/Brentwood/St. Louis Metro", cfg.Location)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ func Defaults() Config {
|
||||
return Config{
|
||||
WeatherAPI: WeatherAPIConfig{
|
||||
Timeout: 10 * time.Second,
|
||||
Precision: 1,
|
||||
Precision: 0,
|
||||
Units: "us",
|
||||
Timezone: "America/Chicago",
|
||||
Format: "json",
|
||||
|
||||
Reference in New Issue
Block a user