open-standards/eoc/eoc-rs/crates/eoc-carbon/tests/intensity_roundtrip.rs
Transaction Science 781c331288 ingest batch 5 (salvage): 2 crates from 9-agent dispatch (session-limit hit mid-batch)
OpenPay (1 crate)
  op-revrec      ASC 606 / IFRS 15 revenue recognition (5-step model,
                 multi-element allocation, deferred revenue ledger,
                 variable consideration with constraint, principal vs agent,
                 contract modifications, multi-currency translation)
                 27 tests across 6 FASB worked examples + SaaS lifecycle.

EOC (1 crate)
  eoc-carbon     Carbon intensity → joules → gCO2e accounting.
                 Electricity Maps, WattTime, CO2 Signal adapters; IEA
                 baseline fallback; PUE tables (AWS/GCP/Azure); region-aware
                 scheduling + demand shifting; SCI-for-AI bridge into eoc-eval.
                 21 tests passing.

Seven other crates (op-dispute-evidence, op-ewallets-asia, smart-byte-zk,
smart-byte-atproto, smart-byte-edv, eoc-agent, eoc-rag) were scoped in this
batch but the parallel agents hit session-limit before completing. They are
deferred to a follow-up batch.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
2026-05-24 09:28:38 -04:00

30 lines
1,012 B
Rust

//! Verifies that a real-shape Electricity Maps `/v3/carbon-intensity/latest`
//! body parses into a `CarbonIntensity` without any HTTP roundtrip.
use eoc_carbon::electricity_maps::MockElectricityMaps;
use eoc_carbon::intensity::{IntensityKind, ProviderKind};
#[test]
fn parse_em_latest_body() {
let body = r#"{
"zone": "FR",
"carbonIntensity": 58,
"datetime": "2026-05-24T12:00:00Z",
"updatedAt": "2026-05-24T12:01:00Z",
"emissionFactorType": "lifecycle",
"isEstimated": false,
"estimationMethod": null
}"#;
let ci = MockElectricityMaps::parse_latest(body).expect("parse ok");
assert_eq!(ci.zone.as_str(), "FR");
assert_eq!(ci.g_co2e_per_kwh, 58.0);
assert_eq!(ci.kind, IntensityKind::Average);
assert_eq!(ci.provider, ProviderKind::ElectricityMaps);
}
#[test]
fn missing_zone_decodes_to_error() {
let body = r#"{"carbonIntensity": 100}"#;
let r = MockElectricityMaps::parse_latest(body);
assert!(r.is_err());
}