Skip to content

Commit cf5d254

Browse files
committed
Allow adding bounds to MockComponent
Signed-off-by: Simon Völcker <simon.voelcker@frequenz.com>
1 parent f925ef7 commit cf5d254

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/client/test_utils.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ use crate::{
1212
proto::{
1313
common::{
1414
metrics::{
15-
Metric, MetricSample, MetricValueVariant, SimpleMetricValue, metric_value_variant,
15+
Bounds, Metric, MetricSample, MetricValueVariant, SimpleMetricValue, metric_value_variant,
1616
},
1717
microgrid::electrical_components::{
1818
ElectricalComponent, ElectricalComponentCategory,
1919
ElectricalComponentCategorySpecificInfo, ElectricalComponentConnection,
2020
ElectricalComponentStateCode, ElectricalComponentStateSnapshot,
2121
ElectricalComponentTelemetry, Inverter, InverterType,
2222
electrical_component_category_specific_info::Kind,
23+
MetricConfigBounds,
2324
},
2425
},
2526
google::protobuf,
@@ -33,7 +34,6 @@ use crate::{
3334
},
3435
quantity::{Current, Power, ReactivePower, Voltage},
3536
};
36-
3737
use super::MicrogridApiClient;
3838

3939
/// A mock implementation of the `MicrogridApiClient` trait for testing purposes.
@@ -162,6 +162,16 @@ impl MockComponent {
162162
self
163163
}
164164

165+
pub fn add_component_bounds(mut self, metric: i32, lower: Option<f32>, upper: Option<f32>) -> Self {
166+
self.component.metric_config_bounds.push(
167+
MetricConfigBounds {
168+
metric,
169+
config_bounds: Some(Bounds {lower, upper}),
170+
}
171+
);
172+
self
173+
}
174+
165175
pub fn with_power(mut self, power: Vec<f32>) -> Self {
166176
let mut metrics = self.metrics;
167177
for (i, p) in power.iter().enumerate() {

0 commit comments

Comments
 (0)