def test_telemetry_predicates(self): temp1 = ChTemplate(1, "Test Channel 1", "Predicate_Tester", I32Type()) temp2 = ChTemplate(2, "Test Channel 2", "Predicate_Tester", StringType()) update1 = ChData(I32Type(20), TimeType(), temp1) update2 = ChData(StringType("apple"), TimeType(), temp2) pred = predicates.telemetry_predicate() assert pred( update1 ), "If no fields are specified a ChData object should return True" assert pred( update2 ), "If no fields are specified a ChData object should return True" assert not pred( "diff object" ), "Anything that's not a ChData object should be False" assert not pred( 5), "Anything that's not a ChData object should be False" self.check_str(pred) id_pred = predicates.equal_to(1) pred = predicates.telemetry_predicate(id_pred=id_pred) assert pred(update1), "This predicate on the ID 1 should return True" assert not pred( update2), "This predicate on the ID 2 should return False" self.check_str(pred) val_pred = predicates.equal_to("apple") pred = predicates.telemetry_predicate(value_pred=val_pred) assert not pred( update1), "This predicate on the value 20 should return False" assert pred( update2 ), "This predicate on the value \"apple\" should return True" self.check_str(pred) time_pred = predicates.equal_to(0) pred = predicates.telemetry_predicate(time_pred=time_pred) assert pred(update1), "This predicate on the time 0 should return True" assert pred(update2), "This predicate on the time 0 should return True" self.check_str(pred) val_pred = predicates.within_range(10, 30) pred = predicates.telemetry_predicate(id_pred, val_pred, time_pred) assert pred( update1), "Specifying all fields should return True for update 1" assert not pred( update2), "Specifying all fields should return False for update 2" self.check_str(pred)