예제 #1
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))
예제 #2
0
    def test_011_setting_trigger(self):
        SettingsDao.update_setting(self.SETTING, self.BURNER_ID)
        new_settings = NewSettingsDao.get_all()
        self.assertEqual(1, len(new_settings))

        inserted = new_settings[0]

        real_setting = SettingsDao.get_setting_by_name(self.BURNER_ID, self.SETTING['setting_name'])
        self.assertEqual(real_setting['burner_sn'], inserted['burner_sn'])
        self.assertEqual(real_setting['setting_name'], inserted['setting_name'])
        self.assertEqual(real_setting['value'], inserted['value'])

        self.SETTING['value'] = 666
        SettingsDao.update_setting(self.SETTING, self.BURNER_ID)
        new_settings = NewSettingsDao.get_all()
        self.assertEqual(1, len(new_settings))

        inserted = new_settings[0]
        real_setting = SettingsDao.get_setting_by_name(self.BURNER_ID, self.SETTING['setting_name'])
        self.assertEqual(real_setting['burner_sn'], inserted['burner_sn'])
        self.assertEqual(real_setting['setting_name'], inserted['setting_name'])
        self.assertEqual(real_setting['value'], inserted['value'])
예제 #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