예제 #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_014_test_read_new(self):
        sync_entries = sync_queue_dao.get_all()
        self.assertEqual(1, len(sync_entries))

        new_alarms = NewAlarmsDao.get_all()
        self.assertEqual(1, len(new_alarms))

        new_settings = NewSettingsDao.get_all()
        self.assertEqual(1, len(new_settings))

        SyncManager.sendMessage = MagicMock(return_value="ok")
        SyncManager.run()

        new_alarms = NewAlarmsDao.get_all()
        self.assertEqual(0, len(new_alarms))

        new_settings = NewSettingsDao.get_all()
        self.assertEqual(0, len(new_settings))

        sync_entries = sync_queue_dao.get_all()
        self.assertEqual(3, len(sync_entries))
예제 #3
0
    def test_015_test_receive_message_not_adding_new_sync_entry(self):
        backend._exec("""DROP TRIGGER IF EXISTS alarm_after_insert;""");
        backend._exec("""DROP TRIGGER IF EXISTS settings_after_update;""");
        config.LOCAL = False
        sync_entries = sync_queue_dao.get_all()
        self.assertEqual(3, len(sync_entries))
        new_alarms = NewAlarmsDao.get_all()
        self.assertEqual(0, len(new_alarms))
        new_settings = NewSettingsDao.get_all()
        self.assertEqual(0, len(new_settings))

        sql = """DELETE FROM alarms"""
        backend._exec(sql)
        SyncManager.onMessage(testData.ALARM_CREATE)
        SyncManager.onMessage(testData.SETTING_UPDATE)

        new_alarms = NewAlarmsDao.get_all()
        self.assertEqual(0, len(new_alarms))
        new_settings = NewSettingsDao.get_all()
        self.assertEqual(0, len(new_settings))
        sync_entries = sync_queue_dao.get_all()
        self.assertEqual(3, len(sync_entries))

        pass