Skip to content

Commit

Permalink
Merge branch 'wattime-v3-support' of https://github.com/Green-Softwar…
Browse files Browse the repository at this point in the history
…e-Foundation/carbon-aware-sdk into wattime-v3-support
  • Loading branch information
vaughanknight committed Jun 18, 2024
2 parents 0080ae8 + fbfcac1 commit f3fd570
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class TestDataConstants
public static DateTime Date = new DateTime(2099, 1, 1, 0, 0, 0);
public const float Value = 999.99f;
public const string Version = "1.0";
public const string SignalType = SignalTypes.co2_moer;
}

internal static string GetGridDataResponseJsonString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public async Task GetDataAsync_DeserializesExpectedResponse()
this.AddHandlers_Auth();
this.AddHandler_RequestResponse(r =>
{
return r.RequestUri!.ToString().Equals($"https://api.watttime.org/v3/data?region=region&starttime=2022-04-22T00%3a00%3a00.0000000%2b00%3a00&endtime=2022-04-22T00%3a00%3a00.0000000%2b00%3a00&signal_type={SignalTypes.co2_moer}") && r.Method == HttpMethod.Get;
return r.RequestUri!.ToString().Equals("https://api.watttime.org/v3/historical?region=region&start=2022-04-22T00%3a00%3a00.0000000%2b00%3a00&end=2022-04-22T00%3a00%3a00.0000000%2b00%3a00&signal_type=co2_moer") && r.Method == HttpMethod.Get;
}, System.Net.HttpStatusCode.OK, TestData.GetGridDataResponseJsonString());

var client = new WattTimeClient(this.HttpClientFactory, this.Options.Object, this.Log.Object, this.MemoryCache);
Expand All @@ -131,12 +131,12 @@ public async Task GetDataAsync_DeserializesExpectedResponse()

Assert.IsTrue(emissionsResponse.Data.Count() > 0);
var meta = emissionsResponse.Meta;
Assert.AreEqual("region", meta.Region);
Assert.AreEqual("signal_type", meta.SignalType);
Assert.AreEqual(TestData.TestDataConstants.Region, meta.Region);
Assert.AreEqual(TestData.TestDataConstants.SignalType, meta.SignalType);
var gridDataPoint = emissionsResponse.Data.ToList().First();
Assert.AreEqual(300, gridDataPoint.Frequency);
Assert.AreEqual("mkt", gridDataPoint.Market);
Assert.AreEqual(new DateTimeOffset(2099, 1, 1, 0, 0, 0, TimeSpan.Zero), gridDataPoint.PointTime);
Assert.AreEqual(TestData.TestDataConstants.Market, gridDataPoint.Market);
Assert.AreEqual(TestData.TestDataConstants.PointTime, gridDataPoint.PointTime);
Assert.AreEqual("999.99", gridDataPoint.Value.ToString("0.00", CultureInfo.InvariantCulture)); //Format float to avoid precision issues
Assert.AreEqual("1.0", gridDataPoint.Version);
}
Expand Down

0 comments on commit f3fd570

Please sign in to comment.