예제 #1
0
 def given_event_with(self, start="4 Aug 2010", end="10 Aug 2010",
                      text="Text", description=None,
                      pos=(0, 0), size=(0, 0)):
     event = Event(self.db.get_time_type(), human_time_to_py(start), human_time_to_py(end), text)
     if description is not None:
         event.set_data("description", description)
     self.db.save_event(event)
     self.mock_drawer.events_and_rects.append((event, wx.Rect(pos[0], pos[1], size[0], size[1])))
     return event
예제 #2
0
 def given_event_at(self, start_time, end_time=None, visible=True):
     category = Category("category", (0, 0, 0), None, visible)
     if end_time is None:
         end_time = start_time
     event = Event(self.db.get_time_type(), human_time_to_py(start_time),
                   human_time_to_py(end_time), "event-text", category)
     self.db.save_category(category)
     self.db.save_event(event)
     self.view_properties.set_category_visible(category, visible)
예제 #3
0
 def given_event_with(self,
                      start="4 Aug 2010",
                      end="10 Aug 2010",
                      text="Text",
                      description=None,
                      pos=(0, 0),
                      size=(0, 0)):
     event = Event(self.db.get_time_type(), human_time_to_py(start),
                   human_time_to_py(end), text)
     if description is not None:
         event.set_data("description", description)
     self.db.save_event(event)
     self.mock_drawer.events_and_rects.append(
         (event, wx.Rect(pos[0], pos[1], size[0], size[1])))
     return event
예제 #4
0
 def when_moving(self, event, from_time, to_x):
     self.moved_event = event
     if event.is_period():
         self.period_events.append(event)
     handler = MoveByDragInputHandler(
         self.drawing_area, self.status_bar, event, human_time_to_py(from_time))
     handler.mouse_moved(to_x, 10)
예제 #5
0
 def when_moving(self, event, from_time, to_x):
     self.moved_event = event
     if event.is_period():
         self.period_events.append(event)
     handler = MoveByDragInputHandler(self.drawing_area, self.status_bar,
                                      event, human_time_to_py(from_time))
     handler.mouse_moved(to_x, 10)
예제 #6
0
 def test_changes_input_handler_to_move_when_pressing_move_handle(self):
     event = an_event()
     time = human_time_to_py("1 Jan 2011")
     self.given_time_at_x_is(10, time)
     self.given_event_with_rect_at(10, 10, event, wx.Rect(0, 0, 20, 20))
     self.given_event_selected(event)
     self.handler.left_mouse_down(10, 10, False, False)
     self.drawing_area.change_input_handler_to_move_by_drag.assert_called_once_with(event, time)
 def test_disables_mouse_cursor_when_event_ends_today(self):
     event = an_event_with(ends_today=True)
     time = human_time_to_py("1 Jan 2011")
     self.given_time_at_x_is(10, time)
     self.given_event_with_rect_at(10, 10, event, wx.Rect(0, 0, 20, 20))
     self.given_event_selected(event)
     self.handler.mouse_moved(10, 10)
     self.assertEquals(0, self.view.set_move_cursor.call_count)
예제 #8
0
 def test_disables_move_handler_when_event_ends_today(self):
     event = an_event_with(ends_today=True)
     time = human_time_to_py("1 Jan 2011")
     self.given_time_at_x_is(10, time)
     self.given_event_with_rect_at(10, 10, event, wx.Rect(0, 0, 20, 20))
     self.given_event_selected(event)
     self.handler.left_mouse_down(10, 10, False, False)
     self.assertEquals(0, self.drawing_area.change_input_handler_to_move_by_drag.call_count)
예제 #9
0
 def test_disables_mouse_cursor_when_event_ends_today(self):
     event = an_event_with(ends_today=True)
     time = human_time_to_py("1 Jan 2011")
     self.given_time_at_x_is(10, time)
     self.given_event_with_rect_at(10, 10, event, wx.Rect(0, 0, 20, 20))
     self.given_event_selected(event)
     self.handler.mouse_moved(10, 10)
     self.assertEquals(0, self.view.set_move_cursor.call_count)
 def test_changes_input_handler_to_move_when_pressing_move_handle(self):
     event = an_event()
     time = human_time_to_py("1 Jan 2011")
     self.given_time_at_x_is(10, time)
     self.given_event_with_rect_at(10, 10, event, wx.Rect(0, 0, 20, 20))
     self.given_event_selected(event)
     self.handler.left_mouse_down(10, 10, False, False)
     self.drawing_area.change_input_handler_to_move_by_drag.assert_called_once_with(
         event, time)
 def test_disables_move_handler_when_event_ends_today(self):
     event = an_event_with(ends_today=True)
     time = human_time_to_py("1 Jan 2011")
     self.given_time_at_x_is(10, time)
     self.given_event_with_rect_at(10, 10, event, wx.Rect(0, 0, 20, 20))
     self.given_event_selected(event)
     self.handler.left_mouse_down(10, 10, False, False)
     self.assertEquals(
         0,
         self.drawing_area.change_input_handler_to_move_by_drag.call_count)
예제 #12
0
 def setup_snap(self, time, snap_to):
     self.snaps.append((human_time_to_py(time), human_time_to_py(snap_to)))
예제 #13
0
 def get_time(self, x):
     any_time = human_time_to_py("19 Sep 1999")
     return self.get_time_calls.get(x, any_time)
예제 #14
0
 def assert_highlights_region(self, start_end):
     if start_end is not None:
         start_end = (human_time_to_py(start_end[0]), human_time_to_py(start_end[1]))
     view_properties = self.get_view_properties_used_when_drawing()
     self.assertEquals(start_end, view_properties.period_selection)
예제 #15
0
 def assert_created_event_with_period(self, start, end):
     self.view.open_create_event_editor.assert_called_with(
         human_time_to_py(start), human_time_to_py(end))
예제 #16
0
 def when_editor_opened_with_period(self, start, end):
     self.when_editor_opened_with(human_time_to_py(start),
                                  human_time_to_py(end), None)
예제 #17
0
 def given_time_at_x_is(self, x, time):
     self.mock_drawer.setup_get_time_call(x, human_time_to_py(time))
예제 #18
0
 def assert_end_time_set_to(self, time):
     self.view.set_end.assert_called_with(human_time_to_py(time))
예제 #19
0
 def given_time_at_x_is(self, x, time):
     self.controller.get_time.return_value = human_time_to_py(time)
     self.drawer.snap.return_value = human_time_to_py(time)
예제 #20
0
 def get_time(self, x):
     any_time = human_time_to_py("19 Sep 1999")
     return self.get_time_calls.get(x, any_time)
예제 #21
0
 def given_time_at_x_is(self, x, time):
     self.times_at[x] = human_time_to_py(time)
예제 #22
0
 def setup_snap(self, time, snap_to):
     self.snaps.append((human_time_to_py(time), human_time_to_py(snap_to)))
예제 #23
0
 def assert_created_event_with_period(self, start, end):
     self.view.open_create_event_editor.assert_called_with(
         human_time_to_py(start), human_time_to_py(end))
예제 #24
0
 def assert_highlights_region(self, start_end):
     if start_end is not None:
         start_end = (human_time_to_py(start_end[0]),
                      human_time_to_py(start_end[1]))
     view_properties = self.get_view_properties_used_when_drawing()
     self.assertEquals(start_end, view_properties.period_selection)
예제 #25
0
 def given_snaps(self, from_, to):
     self.snap_times[human_time_to_py(from_)] = human_time_to_py(to)
예제 #26
0
 def simulate_user_enters_end_time(self, time):
     self.view.get_end.return_value = human_time_to_py(time)
예제 #27
0
 def given_time_at_x_is(self, x, time):
     self.times_at[x] = human_time_to_py(time)
예제 #28
0
 def when_editor_opened_with_time(self, time):
     self.when_editor_opened_with(human_time_to_py(time),
                                  human_time_to_py(time), None)
예제 #29
0
 def given_time_at_x_is(self, x, time):
     self.controller.get_time.return_value = human_time_to_py(time)
     self.drawer.snap.return_value = human_time_to_py(time)
예제 #30
0
 def given_time_at_x_is(self, x, time):
     self.mock_drawer.setup_get_time_call(x, human_time_to_py(time))
예제 #31
0
 def test_event_starting_in_history(self):
     event = Mock()
     event.time_period.start_time = human_time_to_py("1 Jan 2010")
     self.when_editor_opened_with_event(event)
     self.assertTrue(self.editor.start_is_in_history())
예제 #32
0
 def test_saves_end_time(self):
     self.given_saving_valid_event()
     self.assertEquals(self.saved_event.time_period.end_time,
                       human_time_to_py("2 Jan 2010"))
예제 #33
0
 def given_snaps(self, from_, to):
     self.snap_times[human_time_to_py(from_)] = human_time_to_py(to)
예제 #34
0
 def test_saves_end_time_from_start_time(self):
     self.view.get_show_period.return_value = False
     self.given_saving_valid_event()
     self.assertEquals(self.saved_event.time_period.end_time,
                       human_time_to_py("1 Jan 2010"))