예제 #1
0
    def test_010_alarm_trigger(self):
        AlarmDao.create_alarm(self.BURNER_ID, self.TYPE, "error")
        new_alarms = NewAlarmsDao.get_all()
        self.assertEqual(1, len(new_alarms))
        inserted = new_alarms[0]

        real_alarm = AlarmDao.get_alarm(inserted['alarm_id'], self.BURNER_ID)
        self.assertEqual(real_alarm['type_key'], self.TYPE)
예제 #2
0
    def test_002_onMessage_update_alarm_ok(self):
        alarm_update = testData.ALARM_UPDATE

        alarm_before = AlarmDao.get_alarm(json.loads(alarm_update['data'])['id'], testData.burner)
        self.assertEquals(alarm_before['acknowledged'], 0)

        SyncManager.onMessage(alarm_update)

        alarm_after = AlarmDao.get_alarm(json.loads(alarm_update['data'])['id'], testData.burner)
        self.assertEquals(alarm_after['acknowledged'], 1)
예제 #3
0
    def test_003_onMessage_delete_alarm_ok(self):
        alarm_delete = testData.ALARM_DELETE
        data = json.loads(alarm_delete['data'])

        alarm_before = AlarmDao.get_alarm(data['id'], testData.burner)
        self.assertIsNotNone(alarm_before)

        print(alarm_delete, (type(alarm_delete)))
        SyncManager.onMessage(alarm_delete)

        alarm_after = AlarmDao.get_alarm(data['id'], testData.burner)
        self.assertIsNone(alarm_after)
예제 #4
0
    def test_001_onMessage_insert_alarm_ok(self):
        num_alarms_before = len(AlarmDao._get_all())
        alarm_msg = testData.ALARM_CREATE
        date, burner = testData.date, testData.burner

        SyncManager.onMessage(alarm_msg)
        alarms_after = AlarmDao._get_all()
        newest = len(alarms_after) -1

        self.assertEquals(len(alarms_after), num_alarms_before + 1)
        self.assertEquals(timeUtil.to_current_timestmap(alarms_after[newest]['date']), date)
        self.assertEquals(alarms_after[newest]['burner_sn'], burner)
        self.assertEquals(alarms_after[newest]['acknowledged'], 0)