def test_greater_than(self):
     pred = predicates.greater_than(2)
     assert pred(3), "three is greater than two"
     assert pred(100), "one hundred is greater than two"
     assert not pred(2), "two is not greater than two"
     assert not pred(-1), "negative one is not greater than two"
     self.check_str(pred)
Exemple #2
0
    def test_active_logger_filter(self):
        self.set_default_filters()
        try:
            cmd_events = self.api.get_event_pred(
                severity=EventSeverity.COMMAND)
            actHI_events = self.api.get_event_pred(
                severity=EventSeverity.ACTIVITY_HI)
            pred = predicates.greater_than(0)
            zero = predicates.equal_to(0)
            # Drain time for dispatch events
            time.sleep(10)

            self.assert_command("cmdDisp.CMD_NO_OP")
            self.assert_command("cmdDisp.CMD_NO_OP")

            time.sleep(0.5)

            self.api.assert_event_count(pred, cmd_events)
            self.api.assert_event_count(pred, actHI_events)

            self.set_event_filter(self.FilterSeverity.COMMAND, False)
            # Drain time for dispatch events
            time.sleep(10)
            self.api.clear_histories()
            self.api.send_command("cmdDisp.CMD_NO_OP")
            self.api.send_command("cmdDisp.CMD_NO_OP")

            time.sleep(0.5)

            self.api.assert_event_count(zero, cmd_events)
            self.api.assert_event_count(pred, actHI_events)
        finally:
            self.set_default_filters()
Exemple #3
0
def test_time_greater_than_predicate():
    time1 = time_type.TimeType(seconds=1593610856, useconds=223451)
    time2 = time_type.TimeType(seconds=1593610856, useconds=223502)

    time_pred = predicates.greater_than(time1)
    assert not time_pred(time1)
    assert time_pred(time2)
Exemple #4
0
    def test_bd_cycles_ascending(self):
        length = 60
        count_pred = predicates.greater_than(length - 1)
        results = self.api.await_telemetry_count(count_pred, "BD_Cycles", timeout=length)
        last = None
        reordered = False
        ascending = True
        for result in results:
            if last is not None:
                last_time = last.get_time()
                result_time = result.get_time()
                if result_time - last_time > 1.5:
                    msg = "FSW didn't send an update between {} and {}".format(last_time.to_readable(), result_time.to_readable())
                    self.api.log(msg)
                elif result_time < last_time:
                    msg = "There is potential reorder error between {} and {}".format(last_time, result_time)
                    self.api.log(msg)
                    reordered = True
        
                if not result.get_val() > last.get_val(): 
                    msg = "Not all updates ascended: First ({}) Second ({})".format(last.get_val(), result.get_val())
                    self.api.log(msg)
                    ascending = False

            last = result

        case = True
        case &= self.api.test_assert(ascending, "Expected all updates to ascend.", True)
        case &= self.api.test_assert(not reordered, "Expected no updates to be dropped.", True)
        self.api.predicate_assert(count_pred, len(results) - 1, "Expected >= {} updates".format(length-1), True)
        self.api.assert_telemetry_count(0, "RgCycleSlips")
        assert case, "Expected all checks to pass (ascending, reordering). See log."
Exemple #5
0
def test_comparing_item_to_converted_time_succeeds(sample_event):
    time = time_type.TimeType(seconds=12345)
    sample_event.time = time_type.TimeType(seconds=9999999)

    time_pred = predicates.greater_than(time)
    converted_time_pred = filtering_utils.time_to_data_predicate(time_pred)
    # Now, this returns the correct value
    assert converted_time_pred(sample_event)
Exemple #6
0
 def print_upcoming_item(min_start_time="NOW"):
     item = cls._get_upcoming_item(api, search_filter,
                                   min_start_time)
     cls._log(cls._get_item_string(item, json))
     # Update time so we catch the next item since the last one
     if item:
         min_start_time = predicates.greater_than(item.get_time())
         min_start_time = filtering_utils.time_to_data_predicate(
             min_start_time)
     return (min_start_time, )
Exemple #7
0
def test_comparing_item_to_time_fails(sample_event):
    """
    Test that comparing a time to an event is problematic, since this assertion
    SHOULD always be true but is, in fact, false because we're comparing a data
    object to a time object
    """
    time = time_type.TimeType(seconds=12345)
    sample_event.time = time_type.TimeType(seconds=9999999)

    time_pred = predicates.greater_than(time)
    # This SHOULD return true, but it doesn't
    assert not time_pred(sample_event)