Ejemplo n.º 1
0
    def FromJson(data):
        eventScheduler = EventScheduler()
        eventDataArray = json.loads(data)
        for eventData in eventDataArray:
            eventScheduler.AddEvent(Event.FromDict(eventData))

        return eventScheduler
Ejemplo n.º 2
0
    def CreateTestEvent2(cls):
        from HorizonCore.Framework.Event import Event

        return Event(name='TestEvent2',
                     stateClassName='TimeForMorningGreeting',
                     startTime=datetime.time(8, 0),
                     endTime=datetime.time(9, 30))
Ejemplo n.º 3
0
    def CreateTestEvent1():
        from HorizonCore.Framework.Event import Event

        return Event(name='TestEvent1',
                     stateClassName='StateStartWakingUp',
                     startTime=datetime.time(7, 0),
                     endTime=datetime.time(8, 0))
Ejemplo n.º 4
0
    def test_SpecifyThatAnEventCanBeConstructedFromAJsonObject(self):
        event = Event.FromDict(eventAsJson)

        self.assertEqual(event.Name, 'TimeToStartWakingUp')
        self.assertEqual(event.StateClassName, 'StateStartWakingUp')
        self.assertEqual(event.StartTime, datetime.time(7, 0))
        self.assertEqual(event.EndTime, datetime.time(8, 0))
Ejemplo n.º 5
0
    def test_SpecifyThatAnEventCanBeSavedToJsonString(self):
        event = Event.FromDict(eventAsJson)

        eventSavedAsJsonString = event.ToJson()

        self.assertEqual(
            eventSavedAsJsonString,
            '{"Name": "TimeToStartWakingUp", "StateClassName": "StateStartWakingUp", "StartTime": "07:00", "EndTime": "08:00"}'
        )
Ejemplo n.º 6
0
    def test_SpecifyThatAnEventCanBeConstructed(self):
        event = Event(name='TimeToStartWakingUp',
                      stateClassName='StateStartWakingUp',
                      startTime=datetime.time(7, 0),
                      endTime=datetime.time(8, 0))

        self.assertEqual(event.Name, 'TimeToStartWakingUp')
        self.assertEqual(event.StateClassName, 'StateStartWakingUp')
        self.assertEqual(event.StartTime, datetime.time(7, 0))
        self.assertEqual(event.EndTime, datetime.time(8, 0))
Ejemplo n.º 7
0
 def PopulateFromJson(self, data):
     self.Clear()
     eventDataArray = json.loads(data)
     for eventData in eventDataArray:
         self.AddEvent(Event.FromDict(eventData))