def testIntervalAlarm(self): self.topics = [Topic("onIntervalAlarm", "E1")] xsettings = [{"hours": 0, "minutes": 0, "seconds": 10, "key": "E1"}] settings = Settings() self.dispatcher = Dispatcher() self.subscriber = MockSubscriber() flexmock(settings, getEventsByType=xsettings) self.publisher = SchedulePublisher(self.dispatcher, settings) self.publisher.dailyAlarms = [] self.publisher.sleep = time.sleep self.publisher.sleepinterval = 1 self.subscriber.testq = Queue.Queue() self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=1, timeout=20) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics
def testDailyAlarm(self): from time import strftime self.topics = [Topic("onDailyAlarm", "E1")] hour, minute = strftime("%H:%M").split(":") xsettings = [{"hour": int(hour), "minute": int(minute) + 1, "key": "E1"}] settings = Settings() flexmock(settings, getEventsByType=xsettings) self.publisher = SchedulePublisher(self.dispatcher, settings) self.publisher.intervalAlarms = [] self.publisher.sleep = time.sleep self.publisher.sleepinterval = 1 self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=1, timeout=65) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] time.sleep(1) for topic in self.topics: assert topic in msgtopics
class TestSchedule(object): def __init__(self): self.publisher = None self.dispatcher = None self.subscriber = None self.topics = None def setup(self): flexmock(log.xbmc, log=printlog) flexmock(log.xbmc, sleep=sleep) self.dispatcher = Dispatcher() self.subscriber = MockSubscriber() def teardown(self): self.publisher.abort() self.dispatcher.abort() del self.publisher del self.dispatcher def testDailyAlarm(self): from time import strftime self.topics = [Topic("onDailyAlarm", "E1")] hour, minute = strftime("%H:%M").split(":") xsettings = [{"hour": int(hour), "minute": int(minute) + 1, "key": "E1"}] settings = Settings() flexmock(settings, getEventsByType=xsettings) self.publisher = SchedulePublisher(self.dispatcher, settings) self.publisher.intervalAlarms = [] self.publisher.sleep = time.sleep self.publisher.sleepinterval = 1 self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=1, timeout=65) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] time.sleep(1) for topic in self.topics: assert topic in msgtopics def testIntervalAlarm(self): self.topics = [Topic("onIntervalAlarm", "E1")] xsettings = [{"hours": 0, "minutes": 0, "seconds": 10, "key": "E1"}] settings = Settings() self.dispatcher = Dispatcher() self.subscriber = MockSubscriber() flexmock(settings, getEventsByType=xsettings) self.publisher = SchedulePublisher(self.dispatcher, settings) self.publisher.dailyAlarms = [] self.publisher.sleep = time.sleep self.publisher.sleepinterval = 1 self.subscriber.testq = Queue.Queue() self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=1, timeout=20) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics
class TestSchedule(object): def __init__(self): self.publisher = None self.dispatcher = None self.subscriber = None self.topics = None def setup(self): flexmock(log.xbmc, log=printlog) flexmock(log.xbmc, sleep=sleep) self.dispatcher = Dispatcher() self.subscriber = MockSubscriber() def teardown(self): self.publisher.abort() self.dispatcher.abort() del self.publisher del self.dispatcher def testDailyAlarm(self): from time import strftime self.topics = [Topic('onDailyAlarm', 'E1')] hour, minute = strftime('%H:%M').split(':') xsettings = [{ 'hour': int(hour), 'minute': int(minute) + 1, 'key': 'E1' }] settings = Settings() flexmock(settings, getEventsByType=xsettings) self.publisher = SchedulePublisher(self.dispatcher, settings) self.publisher.intervalAlarms = [] self.publisher.sleep = time.sleep self.publisher.sleepinterval = 1 self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=1, timeout=65) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] time.sleep(1) for topic in self.topics: assert topic in msgtopics def testIntervalAlarm(self): self.topics = [Topic('onIntervalAlarm', 'E1')] xsettings = [{'hours': 0, 'minutes': 0, 'seconds': 10, 'key': 'E1'}] settings = Settings() self.dispatcher = Dispatcher() self.subscriber = MockSubscriber() flexmock(settings, getEventsByType=xsettings) self.publisher = SchedulePublisher(self.dispatcher, settings) self.publisher.dailyAlarms = [] self.publisher.sleep = time.sleep self.publisher.sleepinterval = 1 self.subscriber.testq = Queue.Queue() self.subscriber.addTopic(self.topics[0]) self.dispatcher.addSubscriber(self.subscriber) self.dispatcher.start() self.publisher.start() self.subscriber.waitForMessage(count=1, timeout=20) self.publisher.abort() self.dispatcher.abort() messages = self.subscriber.retrieveMessages() msgtopics = [msg.topic for msg in messages] for topic in self.topics: assert topic in msgtopics