def test_comp(self): """StagingStatistic - Comparison""" self.statistic.alert_count = 200 second_stat = StagingStatistic(staged_at='fake_staged_at_time', staged_until='fake_staged_until_time', current_time='fake_current_time', rule='test_rule') second_stat.alert_count = 100 assert_equal(self.statistic > second_stat, True)
def _get_fake_stats(count=2): """Helper function to return fake StagingStatistics""" stage_time = datetime(year=2000, month=1, day=1, hour=1, minute=1, second=1) for i in range(count): stat = StagingStatistic( staged_at=stage_time, staged_until=stage_time + timedelta(days=2), current_time=stage_time + timedelta(days=1), rule='test_rule_{}'.format(i)) stat.alert_count = i + 1 yield stat
def test_comp_no_alert_count(self): """StagingStatistic - Comparison when alert_count is default value""" # self.statistic.alert_count = 200 second_stat = StagingStatistic(staged_at='fake_staged_at_time', staged_until='fake_staged_until_time', current_time='fake_current_time', rule='test_rule') second_stat.alert_count = 100 assert_equal(self.statistic > second_stat, False) self.statistic._current_time += timedelta(days=2, hours=10) expected_string = '''\u25E6 test_rule - Staged At: 2000-01-01 01:01:01 UTC - Staged Until: 2000-01-03 01:01:01 UTC - Time Past Staging: 1d 10h 0m - Alert Count: unknown - Alert Info: n/a''' assert_equal(str(self.statistic), expected_string)