def test_range(self): """Test if range filter works.""" lower = 10 upper = 20 filt = RangeFilter(entity=None, lower_bound=lower, upper_bound=upper) for unf_state in self.values: unf = float(unf_state.state) filtered = filt.filter_state(unf_state) if unf < lower: assert lower == filtered.state elif unf > upper: assert upper == filtered.state else: assert unf == filtered.state
def test_range_zero(values): """Test if range filter works with zeroes as bounds.""" lower = 0 upper = 0 filt = RangeFilter(entity=None, precision=2, lower_bound=lower, upper_bound=upper) for unf_state in values: unf = float(unf_state.state) filtered = filt.filter_state(unf_state) if unf < lower: assert lower == filtered.state elif unf > upper: assert upper == filtered.state else: assert unf == filtered.state
def test_range_zero(self): """Test if range filter works with zeroes as bounds.""" lower = 0 upper = 0 filt = RangeFilter(entity=None, lower_bound=lower, upper_bound=upper) for unf_state in self.values: unf = float(unf_state.state) filtered = filt.filter_state(unf_state) if unf < lower: assert lower == filtered.state elif unf > upper: assert upper == filtered.state else: assert unf == filtered.state