ocpi-tariffs 0.45.0

OCPI tariff calculations
Documentation
use assert_matches::assert_matches;

use crate::{
    generate::{self},
    tariff,
    warning::test::VerdictTestExt,
};

use super::test;

const DATE: &str = "2025-11-10";

#[test]
fn should_warn_no_elements() {
    const TARIFF_JSON: &str = r#"{
    "country_code": "DE",
    "party_id": "ALL",
    "id": "1",
    "currency": "EUR",
    "type": "REGULAR",
    "elements": [],
    "last_updated": "2018-12-05T12:01:09Z"
}
"#;

    let tariff = tariff::parse(TARIFF_JSON).unwrap().unwrap_certain();
    let config = generate::Config {
        timezone: chrono_tz::Europe::Amsterdam,
        start_date_time: test::datetime_utc(DATE, "15:02:12"),
        end_date_time: test::datetime_utc(DATE, "15:12:12"),
        max_power_supply_kw: 12.into(),
        requested_kwh: 80.into(),
        max_current_supply_amp: 2.into(),
    };
    let failure = generate::cdr_from_tariff(&tariff, &config).unwrap_only_error();
    let warning = assert_matches!(failure.into_warning(), generate::Warning::Tariff(w) => w);
    assert_matches!(warning, tariff::Warning::NoElements);
}