示例#1
0
    def test_property_last_time(self):
        metric = MetricFactory.create()
        RecordFactory.create(value=3, metric=metric)
        record = RecordFactory.create(value=5, metric=metric)
        obj = WatchdogFactory.create(metric=metric)

        assert obj.last_timestamp == record.timestamp
示例#2
0
    def test_property_last_time(self):
        metric = MetricFactory.create()
        RecordFactory.create(value=3, metric=metric)
        record = RecordFactory.create(value=5, metric=metric)
        obj = WatchdogFactory.create(metric=metric)

        assert obj.last_timestamp == record.timestamp
示例#3
0
    def test_property_last_value(self):
        metric = MetricFactory.create()
        RecordFactory.create(value=3, metric=metric)
        RecordFactory.create(value=5, metric=metric)
        obj = WatchdogFactory.create(metric=metric)

        assert obj.last_value == 5
示例#4
0
    def test_property_last_value(self):
        metric = MetricFactory.create()
        RecordFactory.create(value=3, metric=metric)
        RecordFactory.create(value=5, metric=metric)
        obj = WatchdogFactory.create(metric=metric)

        assert obj.last_value == 5
示例#5
0
    def test_send_clear(self, pushover_mock, settings):
        pushover_mock.return_value = None
        title = 'OK: {0}'.format(self.observer.name)

        assert self.watchdog.observer.compare(self.watchdog.last_value) is False
        Alert.objects.all().count() == 1
        RecordFactory.create(value=4, metric=self.metric)
        assert self.watchdog.observer.compare(self.watchdog.last_value) is True
        assert pushover_mock.call_args[0] == (settings.PUSHOVER_RECIPIENT, title, 'ok')
        assert Alert.objects.all().count() == 0
示例#6
0
    def test_property_last_time_delta(self):
        metric = MetricFactory.create()

        with freeze_time('2016-01-14 12:00:00'):
            RecordFactory.create(metric=metric)

        obj = WatchdogFactory.create(metric=metric)

        with freeze_time('2016-01-14 12:00:50'):
            assert obj.last_timestamp_delta == 50
    def test_handle(self, request_mock, settings):
        request_mock.return_value = requests.Response()
        request_mock.return_value.status_code = 200

        settings.DEBUG = True
        metric = MetricFactory.create()
        RecordFactory.create(value=3, metric=metric)
        WatchdogFactory.create(metric=metric)

        assert Command().execute(stdout=self.stdout) is None
示例#8
0
    def test_get_last_value(self, rf):
        metric = MetricFactory.create()
        RecordFactory.create(value=5, metric=metric)
        obj = WatchdogFactory.create(metric=metric)

        user = UserFactory.create()
        request = rf.get('/')
        request.user = user

        assert self.modeladmin.get_last_value(obj=obj) == 5
示例#9
0
    def test_property_last_time_delta(self):
        metric = MetricFactory.create()

        with freeze_time('2016-01-14 12:00:00'):
            RecordFactory.create(metric=metric)

        obj = WatchdogFactory.create(metric=metric)

        with freeze_time('2016-01-14 12:00:50'):
            assert obj.last_timestamp_delta == 50
示例#10
0
    def test_get_last_value(self, rf):
        metric = MetricFactory.create()
        RecordFactory.create(value=5, metric=metric)
        obj = WatchdogFactory.create(metric=metric)

        user = UserFactory.create()
        request = rf.get('/')
        request.user = user

        assert self.modeladmin.get_last_value(obj=obj) == 5
示例#11
0
    def test_handle(self, request_mock, settings):
        request_mock.return_value = requests.Response()
        request_mock.return_value.status_code = 200

        settings.DEBUG = True
        metric = MetricFactory.create()
        RecordFactory.create(value=3, metric=metric)
        WatchdogFactory.create(metric=metric)

        assert Command().execute(stdout=self.stdout) is None
    def test_handle(self, request_mock, settings):
        request_mock.return_value = requests.Response()
        request_mock.return_value.status_code = 200

        settings.DEBUG = True
        metric = MetricFactory.create()
        RecordFactory.create(value=3, metric=metric)
        WatchdogFactory.create(metric=metric)

        args = []
        opts = {}
        assert call_command('check_watchdogs', *args, **opts) is None
示例#13
0
    def test_send_clear(self, pushover_mock, settings):
        pushover_mock.return_value = None
        title = 'OK: {0}'.format(self.observer.name)

        assert self.watchdog.observer.compare(
            self.watchdog.last_value) is False
        Alert.objects.all().count() == 1
        RecordFactory.create(value=4, metric=self.metric)
        assert self.watchdog.observer.compare(self.watchdog.last_value) is True
        assert pushover_mock.call_args[0] == (settings.PUSHOVER_RECIPIENT,
                                              title, 'ok')
        assert Alert.objects.all().count() == 0
示例#14
0
 def setup(self):
     self.metric = MetricFactory.create()
     self.observer = ObserverFactory.create(value=4)
     self.record = RecordFactory.create(value=5, metric=self.metric)
     self.watchdog = WatchdogFactory.create(observer=self.observer,
                                            metric=self.metric)
示例#15
0
 def setup(self):
     self.metric = MetricFactory.create()
     self.observer = ObserverFactory.create(value=4)
     self.record = RecordFactory.create(value=5, metric=self.metric)
     self.watchdog = WatchdogFactory.create(observer=self.observer, metric=self.metric)