Esempio n. 1
0
 def get_events_by_task(task_id):
     data_source = DataSource.get_instance()
     return data_source.query_for_list(Event, Event.__EVENTS_BY_TASK,
                                       task_id)
Esempio n. 2
0
import unittest
from batch.domain import Pin, Event, Task
from batch.dateutils import cast_time_to_datetime, get_difference_in_seconds
from datetime import datetime
from batch.workers import TaskManager
from batch.dao import DataSource

DataSource.set_sql_type("sqLite")


class PinTest(unittest.TestCase):
    def get_pin_test(self):
        pin = Pin.get_pin(1)
        self.assertIsNotNone(pin)
        self.assertEqual(1, pin.id)

    def turn_off_pin_test(self):
        pin = Pin.get_pin(1)
        pin.turn_off()
        pin1 = Pin.get_pin(1)
        self.assertFalse(pin1.output)

    def turn_on_pin_test(self):
        pin = Pin.get_pin(1)
        pin.turn_on()
        pin1 = Pin.get_pin(1)
        self.assertTrue(pin1.output)

    def load_pins_test(self):
        pins = Pin.load()
        self.assertTrue(len(pins) > 0)
Esempio n. 3
0
 def load():
     data_source = DataSource.get_instance()
     return data_source.query_for_list(Event, Event.__ALL)
Esempio n. 4
0
 def get_event(event_id):
     data_source = DataSource.get_instance()
     return data_source.query_for_object(Event, Event.__DETAIL, event_id)
Esempio n. 5
0
 def get_pin(pin_id):
     data_source = DataSource.get_instance()
     pin = data_source.query_for_object(Pin, Pin.__DETAIL, pin_id)
     return pin
Esempio n. 6
0
 def load():
     data_source = DataSource.get_instance()
     return data_source.query_for_list(domain_type=Pin, query=Pin.__ALL)
Esempio n. 7
0
 def __update(self):
     data_source = DataSource.get_instance()
     data_source.execute(Pin.__UPDATE, [1 if self.output else 0, self.id])
Esempio n. 8
0
 def get_task(task_id):
     data_source = DataSource.get_instance()
     task = data_source.query_for_object(Task, Task.__DETAIL, task_id)
     return task
Esempio n. 9
0
 def load():
     data_source = DataSource.get_instance()
     return data_source.query_for_list(Task, Task.__ALL)