Vendor Pegasus report-skill templates for weather and reports

This commit is contained in:
Jacob Dubin
2026-05-17 00:30:00 -05:00
parent a47c90c9c3
commit a8a153e910
177 changed files with 21614 additions and 70 deletions

View File

@@ -195,6 +195,28 @@ public sealed class LegacyMimCatalogImporterTests
reply.Contains("I was powered on for the first time today", StringComparison.OrdinalIgnoreCase));
}
[Fact]
public void ImportCatalog_ImportsReportSkillTemplatesWithPlaceholdersPreserved()
{
var rootDirectory = Path.Combine(
AppContext.BaseDirectory,
"Content",
"LegacyMims",
"ReportSkill");
var catalog = LegacyMimCatalogImporter.ImportCatalog(rootDirectory);
Assert.Contains("First let's check in with the meteorology department.", catalog.WeatherIntroReplies);
Assert.Contains("First, the weather tomorrow.", catalog.WeatherTomorrowIntroReplies);
Assert.Contains("Today's high is ${skill.weather.today.highTemp}, and the low is ${skill.weather.today.lowTemp}.", catalog.WeatherTodayHighLowReplies);
Assert.Contains("Tomorrow's high will be ${skill.weather.tomorrow.highTemp} and the low will be ${skill.weather.tomorrow.lowTemp}.", catalog.WeatherTomorrowHighLowReplies);
Assert.Contains("Looks like our weather service is offline. Sorry.", catalog.WeatherServiceDownReplies);
Assert.Contains("Sure ${speaker}. Here it is.", catalog.PersonalReportKickOffReplies);
Assert.Contains("And that's your report for the day. I hope you had as much fun as I did.", catalog.PersonalReportOutroReplies);
Assert.Contains(catalog.ReportSkillTemplates, reply =>
reply.Contains("Checking your calendar, I see ${skill.calendar.numEventsToday} items today.", StringComparison.OrdinalIgnoreCase));
}
[Fact]
public void MergeInto_PreservesExistingCatalogAndAddsImportedContent()
{
@@ -236,6 +258,8 @@ public sealed class LegacyMimCatalogImporterTests
Assert.Contains(catalog.EmotionReplies, reply =>
reply.Condition.Contains("NEUTRAL", StringComparison.OrdinalIgnoreCase));
Assert.Contains("Something's off with the connection to my sources. Maybe ask me again in a little while.", catalog.GenericFallbackReplies);
Assert.Contains("For your weather.", catalog.WeatherIntroReplies);
Assert.Contains("Today's high is {high}, and the low is {low}.", catalog.WeatherTodayHighLowReplies);
}
private static string CreateSeedDirectory()

View File

@@ -20,8 +20,18 @@ public sealed class ProviderCachingTests
{
"/geo/1.0/direct" => JsonResponse(
"""[{"name":"Boston","state":"Massachusetts","country":"US","lat":42.3601,"lon":-71.0589}]"""),
"/data/2.5/weather" => JsonResponse(
"""{"name":"Boston","weather":[{"main":"Clouds","description":"overcast clouds"}],"main":{"temp":70.2,"temp_max":72.9,"temp_min":66.1}}"""),
"/data/3.0/onecall" => JsonResponse(
"""
{
"lat":42.3601,
"lon":-71.0589,
"timezone":"America/New_York",
"current":{"dt":1710000000,"temp":70.2,"weather":[{"main":"Clouds","description":"overcast clouds"}]},
"daily":[
{"dt":1710000000,"temp":{"day":70.2,"min":66.1,"max":72.9},"weather":[{"main":"Clouds","description":"overcast clouds"}]}
]
}
"""),
_ => new HttpResponseMessage(HttpStatusCode.NotFound)
};
});
@@ -43,8 +53,7 @@ public sealed class ProviderCachingTests
Assert.NotNull(first);
Assert.NotNull(second);
Assert.Equal(1, handler.GetCallCount("/geo/1.0/direct"));
Assert.Equal(1, handler.GetCallCount("/data/2.5/weather"));
Assert.Equal(0, handler.GetCallCount("/data/2.5/forecast"));
Assert.Equal(1, handler.GetCallCount("/data/3.0/onecall"));
}
[Fact]
@@ -57,8 +66,18 @@ public sealed class ProviderCachingTests
{
"/geo/1.0/direct" => JsonResponse(
"""[{"name":"Lone Jack","country":"US","lat":38.8708,"lon":-94.1733}]"""),
"/data/2.5/weather" => JsonResponse(
"""{"name":"Lone Jack","weather":[{"main":"Clouds","description":"overcast clouds"}],"main":{"temp":76.0,"temp_max":82.0,"temp_min":78.0}}"""),
"/data/3.0/onecall" => JsonResponse(
"""
{
"lat":38.8708,
"lon":-94.1733,
"timezone":"America/Chicago",
"current":{"dt":1710000000,"temp":76.0,"weather":[{"main":"Clouds","description":"overcast clouds"}]},
"daily":[
{"dt":1710000000,"temp":{"day":76.0,"min":78.0,"max":82.0},"weather":[{"main":"Clouds","description":"overcast clouds"}]}
]
}
"""),
_ => new HttpResponseMessage(HttpStatusCode.NotFound)
};
});
@@ -80,8 +99,99 @@ public sealed class ProviderCachingTests
Assert.Equal(76, report!.Temperature);
Assert.Equal(82, report.HighTemperature);
Assert.Equal(76, report.LowTemperature);
Assert.Equal(1, handler.GetCallCount("/data/3.0/onecall"));
}
[Fact]
public async Task OpenWeatherReportProvider_UsesOneCallDailyForecastForTomorrow()
{
var handler = new CountingHttpMessageHandler(message =>
{
var path = message.RequestUri?.AbsolutePath ?? string.Empty;
return path switch
{
"/geo/1.0/direct" => JsonResponse(
"""[{"name":"Chicago","country":"US","lat":41.8781,"lon":-87.6298}]"""),
"/data/3.0/onecall" => JsonResponse(
"""
{
"lat":41.8781,
"lon":-87.6298,
"timezone":"America/Chicago",
"current":{"dt":1710000000,"temp":61.0,"weather":[{"main":"Clouds","description":"scattered clouds"}]},
"daily":[
{"dt":1710000000,"temp":{"day":61.0,"min":55.0,"max":66.0},"weather":[{"main":"Clouds","description":"scattered clouds"}]},
{"dt":1710086400,"temp":{"day":74.0,"min":60.0,"max":76.0},"summary":"A warmer day ahead","weather":[{"main":"Rain","description":"light rain"}]}
]
}
"""),
_ => new HttpResponseMessage(HttpStatusCode.NotFound)
};
});
var provider = new OpenWeatherReportProvider(
new HttpClient(handler),
new OpenWeatherOptions
{
ApiKey = "test-key",
CurrentCacheTtlSeconds = 300,
ForecastCacheTtlSeconds = 300,
GeocodeCacheTtlSeconds = 300,
FailureCacheTtlSeconds = 30
},
NullLogger<OpenWeatherReportProvider>.Instance);
var report = await provider.GetReportAsync(new WeatherReportRequest("Chicago,US", null, null, true, false, 1));
Assert.NotNull(report);
Assert.Equal(74, report!.Temperature);
Assert.Equal(76, report.HighTemperature);
Assert.Equal(60, report.LowTemperature);
Assert.Equal(1, handler.GetCallCount("/geo/1.0/direct"));
Assert.Equal(1, handler.GetCallCount("/data/3.0/onecall"));
}
[Fact]
public async Task OpenWeatherReportProvider_FallsBackToLegacyWeatherWhenOneCallIsUnauthorized()
{
var handler = new CountingHttpMessageHandler(message =>
{
var path = message.RequestUri?.AbsolutePath ?? string.Empty;
return path switch
{
"/geo/1.0/direct" => JsonResponse(
"""[{"name":"Boston","state":"Massachusetts","country":"US","lat":42.3601,"lon":-71.0589}]"""),
"/data/3.0/onecall" => new HttpResponseMessage(HttpStatusCode.Unauthorized)
{
Content = new StringContent(
"""{"cod":401,"message":"One Call 3.0 requires a subscription"}""",
Encoding.UTF8,
"application/json")
},
"/data/2.5/weather" => JsonResponse(
"""{"name":"Boston","weather":[{"main":"Clouds","description":"overcast clouds"}],"main":{"temp":70.0,"temp_max":72.0,"temp_min":66.0}}"""),
_ => new HttpResponseMessage(HttpStatusCode.NotFound)
};
});
var provider = new OpenWeatherReportProvider(
new HttpClient(handler),
new OpenWeatherOptions
{
ApiKey = "test-key",
CurrentCacheTtlSeconds = 300,
ForecastCacheTtlSeconds = 300,
GeocodeCacheTtlSeconds = 300,
FailureCacheTtlSeconds = 30
},
NullLogger<OpenWeatherReportProvider>.Instance);
var report = await provider.GetReportAsync(new WeatherReportRequest("Boston,US", null, null, false, false, 0));
Assert.NotNull(report);
Assert.Equal(70, report!.Temperature);
Assert.Equal(72, report.HighTemperature);
Assert.Equal(66, report.LowTemperature);
Assert.Equal(1, handler.GetCallCount("/data/3.0/onecall"));
Assert.Equal(1, handler.GetCallCount("/data/2.5/weather"));
Assert.Equal(0, handler.GetCallCount("/data/2.5/forecast"));
}
[Fact]

View File

@@ -1724,9 +1724,10 @@ public sealed class JiboInteractionServiceTests
});
Assert.Equal("personal_report_delivered", decision.IntentName);
Assert.Contains("Great, alex. Here is your personal report.", decision.ReplyText, StringComparison.OrdinalIgnoreCase);
Assert.Contains("Right now in Boston, U.S., it's light rain, around 61 degrees Fahrenheit.", decision.ReplyText, StringComparison.OrdinalIgnoreCase);
Assert.Contains("That is your personal report.", decision.ReplyText, StringComparison.OrdinalIgnoreCase);
Assert.Contains("Sure alex. Here it is.", decision.ReplyText, StringComparison.OrdinalIgnoreCase);
Assert.Contains("First, your weather.", decision.ReplyText, StringComparison.OrdinalIgnoreCase);
Assert.Contains("For your weather. In Boston, U.S., it's light rain and 61 degrees Fahrenheit. Today's high is 65, and the low is 54.", decision.ReplyText, StringComparison.OrdinalIgnoreCase);
Assert.Contains("alex that wraps up your report for the day. Hope you have a good one.", decision.ReplyText, StringComparison.OrdinalIgnoreCase);
Assert.NotNull(decision.ContextUpdates);
Assert.Equal("idle", decision.ContextUpdates![PersonalReportStateKey]);
Assert.Equal(true, decision.ContextUpdates[PersonalReportUserVerifiedKey]);
@@ -1952,7 +1953,7 @@ public sealed class JiboInteractionServiceTests
Assert.Equal("weather", decision.IntentName);
Assert.Null(decision.SkillName);
Assert.Null(decision.SkillPayload);
Assert.Equal("I can check weather once my weather service is connected.", decision.ReplyText);
Assert.Equal("Looks like our weather service is offline. Sorry.", decision.ReplyText);
}
[Fact]
@@ -1967,7 +1968,7 @@ public sealed class JiboInteractionServiceTests
});
Assert.Equal("weather", decision.IntentName);
Assert.Equal("I can check weather once my weather service is connected.", decision.ReplyText);
Assert.Equal("Looks like our weather service is offline. Sorry.", decision.ReplyText);
}
[Fact]
@@ -1982,7 +1983,7 @@ public sealed class JiboInteractionServiceTests
});
Assert.Equal("weather", decision.IntentName);
Assert.Equal("I can check weather once my weather service is connected.", decision.ReplyText);
Assert.Equal("Looks like our weather service is offline. Sorry.", decision.ReplyText);
}
[Fact]
@@ -1997,7 +1998,7 @@ public sealed class JiboInteractionServiceTests
});
Assert.Equal("weather", decision.IntentName);
Assert.Equal("I can check weather once my weather service is connected.", decision.ReplyText);
Assert.Equal("Looks like our weather service is offline. Sorry.", decision.ReplyText);
}
[Fact]
@@ -2012,7 +2013,7 @@ public sealed class JiboInteractionServiceTests
});
Assert.Equal("weather", decision.IntentName);
Assert.Equal("I can check weather once my weather service is connected.", decision.ReplyText);
Assert.Equal("Looks like our weather service is offline. Sorry.", decision.ReplyText);
}
[Fact]
@@ -2031,7 +2032,7 @@ public sealed class JiboInteractionServiceTests
});
Assert.Equal("weather", decision.IntentName);
Assert.Equal("I can check weather once my weather service is connected.", decision.ReplyText);
Assert.Equal("Looks like our weather service is offline. Sorry.", decision.ReplyText);
}
[Fact]
@@ -2063,7 +2064,7 @@ public sealed class JiboInteractionServiceTests
Assert.Equal(54, decision.SkillPayload["weather_low"]);
Assert.Equal("F", decision.SkillPayload["weather_unit"]);
Assert.Equal("Normal", decision.SkillPayload["weather_theme"]);
Assert.Equal("Right now in Boston, U.S., it's light rain, around 61 degrees Fahrenheit.", decision.ReplyText);
Assert.Equal("For your weather. In Boston, U.S., it's light rain and 61 degrees Fahrenheit. Today's high is 65, and the low is 54.", decision.ReplyText);
Assert.NotNull(provider.LastRequest);
Assert.False(provider.LastRequest!.IsTomorrow);
Assert.Equal(0, provider.LastRequest.ForecastDayOffset);
@@ -2088,7 +2089,7 @@ public sealed class JiboInteractionServiceTests
Assert.Equal("Chicago", provider.LastRequest?.LocationQuery);
Assert.True(provider.LastRequest?.IsTomorrow);
Assert.Equal(1, provider.LastRequest?.ForecastDayOffset);
Assert.Equal("Tomorrow in Chicago, U.S., it looks mostly cloudy with a high near 74 degrees Fahrenheit and a low around 60 degrees Fahrenheit.", decision.ReplyText);
Assert.Equal("First, the weather tomorrow. Tomorrow in Chicago, U.S., it looks mostly cloudy. Tomorrow's high will be 74 and the low will be 60.", decision.ReplyText);
}
[Fact]
@@ -2110,7 +2111,7 @@ public sealed class JiboInteractionServiceTests
Assert.Equal("Seattle", provider.LastRequest?.LocationQuery);
Assert.False(provider.LastRequest?.IsTomorrow);
Assert.Equal(0, provider.LastRequest?.ForecastDayOffset);
Assert.Equal("Right now in Seattle, U.S., it's light rain, around 58 degrees Fahrenheit.", decision.ReplyText);
Assert.Equal("For your weather. In Seattle, U.S., it's light rain and 58 degrees Fahrenheit. Today's high is 61, and the low is 52.", decision.ReplyText);
}
[Fact]
@@ -2132,7 +2133,7 @@ public sealed class JiboInteractionServiceTests
Assert.Equal("Paris", provider.LastRequest?.LocationQuery);
Assert.False(provider.LastRequest?.IsTomorrow);
Assert.Equal(0, provider.LastRequest?.ForecastDayOffset);
Assert.Equal("Right now in Paris, FR, it's overcast clouds, around 66 degrees Fahrenheit.", decision.ReplyText);
Assert.Equal("For your weather. In Paris, FR, it's overcast clouds and 66 degrees Fahrenheit. Today's high is 70, and the low is 60.", decision.ReplyText);
}
[Fact]
@@ -2154,7 +2155,7 @@ public sealed class JiboInteractionServiceTests
Assert.Equal("Redmond Oregon", provider.LastRequest?.LocationQuery);
Assert.False(provider.LastRequest?.IsTomorrow);
Assert.Equal(0, provider.LastRequest?.ForecastDayOffset);
Assert.Equal("Right now in Redmond, U.S., it's clear sky, around 63 degrees Fahrenheit.", decision.ReplyText);
Assert.Equal("For your weather. In Redmond, U.S., it's clear sky and 63 degrees Fahrenheit. Today's high is 66, and the low is 52.", decision.ReplyText);
}
[Fact]
@@ -2176,7 +2177,7 @@ public sealed class JiboInteractionServiceTests
Assert.Equal("New York City", provider.LastRequest?.LocationQuery);
Assert.True(provider.LastRequest?.IsTomorrow);
Assert.Equal(1, provider.LastRequest?.ForecastDayOffset);
Assert.Equal("Tomorrow in New York, U.S., it looks partly cloudy with a high near 76 degrees Fahrenheit and a low around 61 degrees Fahrenheit.", decision.ReplyText);
Assert.Equal("First, the weather tomorrow. Tomorrow in New York, U.S., it looks partly cloudy. Tomorrow's high will be 76 and the low will be 61.", decision.ReplyText);
}
[Fact]
@@ -2231,7 +2232,7 @@ public sealed class JiboInteractionServiceTests
Assert.Equal("Chicago", provider.LastRequest?.LocationQuery);
Assert.Null(provider.LastRequest?.Latitude);
Assert.Null(provider.LastRequest?.Longitude);
Assert.Equal("Right now in Chicago, U.S., it's mostly cloudy, around 70 degrees Fahrenheit.", decision.ReplyText);
Assert.Equal("For your weather. In Chicago, U.S., it's mostly cloudy and 70 degrees Fahrenheit. Today's high is 75, and the low is 62.", decision.ReplyText);
}
[Fact]
@@ -2261,7 +2262,7 @@ public sealed class JiboInteractionServiceTests
Assert.Equal("Chicago", provider.LastRequest?.LocationQuery);
Assert.Equal(0, provider.LastRequest?.ForecastDayOffset);
Assert.False(provider.LastRequest?.IsTomorrow);
Assert.Equal("Right now in Chicago, U.S., it's mostly cloudy, around 70 degrees Fahrenheit.", decision.ReplyText);
Assert.Equal("For your weather. In Chicago, U.S., it's mostly cloudy and 70 degrees Fahrenheit. Today's high is 75, and the low is 62.", decision.ReplyText);
}
[Fact]
@@ -2291,7 +2292,7 @@ public sealed class JiboInteractionServiceTests
Assert.Equal("Chicago", provider.LastRequest?.LocationQuery);
Assert.Equal(1, provider.LastRequest?.ForecastDayOffset);
Assert.True(provider.LastRequest?.IsTomorrow);
Assert.Equal("Tomorrow in Chicago, U.S., it looks mostly cloudy with a high near 75 degrees Fahrenheit and a low around 62 degrees Fahrenheit.", decision.ReplyText);
Assert.Equal("First, the weather tomorrow. Tomorrow in Chicago, U.S., it looks mostly cloudy. Tomorrow's high will be 75 and the low will be 62.", decision.ReplyText);
}
[Theory]
@@ -2361,7 +2362,7 @@ public sealed class JiboInteractionServiceTests
Assert.Equal("weather", decision.IntentName);
Assert.Equal(2, provider.LastRequest?.ForecastDayOffset);
Assert.False(provider.LastRequest?.IsTomorrow);
Assert.Equal("On Monday in Portland, U.S., it looks scattered clouds with a high near 68 degrees Fahrenheit and a low around 53 degrees Fahrenheit.", decision.ReplyText);
Assert.Equal("Let's look at the weather. On Monday in Portland, U.S., it looks scattered clouds with a high near 68 degrees Fahrenheit and a low around 53 degrees Fahrenheit.", decision.ReplyText);
}
[Fact]
@@ -2386,7 +2387,7 @@ public sealed class JiboInteractionServiceTests
Assert.Equal("weather", decision.IntentName);
Assert.Equal("Chicago", provider.LastRequest?.LocationQuery);
Assert.Equal(1, provider.LastRequest?.ForecastDayOffset);
Assert.Equal("On Tuesday in Chicago, U.S., it looks light rain with a high near 63 degrees Fahrenheit and a low around 51 degrees Fahrenheit.", decision.ReplyText);
Assert.Equal("First, the weather tomorrow. On Tuesday in Chicago, U.S., it looks light rain. Tomorrow's high will be 63 and the low will be 51.", decision.ReplyText);
}
[Fact]
@@ -2435,7 +2436,7 @@ public sealed class JiboInteractionServiceTests
Assert.Equal("weather", decision.IntentName);
Assert.Equal("Paris", provider.LastRequest?.LocationQuery);
Assert.Equal(5, provider.LastRequest?.ForecastDayOffset);
Assert.Equal("This weekend in Paris, FR, it looks overcast clouds with a high near 70 degrees Fahrenheit and a low around 60 degrees Fahrenheit.", decision.ReplyText);
Assert.Equal("Let's look at the weather. This weekend in Paris, FR, it looks overcast clouds with a high near 70 degrees Fahrenheit and a low around 60 degrees Fahrenheit.", decision.ReplyText);
}
[Fact]
@@ -2557,7 +2558,7 @@ public sealed class JiboInteractionServiceTests
Assert.Equal("weather", decision.IntentName);
Assert.Equal("Chicago", provider.LastRequest?.LocationQuery);
Assert.Equal(2, provider.LastRequest?.ForecastDayOffset);
Assert.Equal("The day after tomorrow in Chicago, U.S., it looks mostly cloudy with a high near 74 degrees Fahrenheit and a low around 60 degrees Fahrenheit.", decision.ReplyText);
Assert.Equal("Let's look at the weather. The day after tomorrow in Chicago, U.S., it looks mostly cloudy with a high near 74 degrees Fahrenheit and a low around 60 degrees Fahrenheit.", decision.ReplyText);
}
[Fact]

View File

@@ -2162,7 +2162,7 @@ public sealed class JiboWebSocketServiceTests
.GetProperty("play")
.GetProperty("esml")
.GetString();
Assert.Contains("weather service is connected", esml, StringComparison.OrdinalIgnoreCase);
Assert.Contains("weather service is offline", esml, StringComparison.OrdinalIgnoreCase);
}
[Fact]
@@ -2204,7 +2204,7 @@ public sealed class JiboWebSocketServiceTests
.GetProperty("play")
.GetProperty("esml")
.GetString();
Assert.Contains("weather service is connected", esml, StringComparison.OrdinalIgnoreCase);
Assert.Contains("weather service is offline", esml, StringComparison.OrdinalIgnoreCase);
}
[Fact]