def test_end_date_should_be_immutable(self): date_range = DateRange(datetime.date(2011, 9, 28), datetime.date(2011, 9, 29)) try: date_range.end_date = datetime.date(2011, 9, 30) except(AttributeError): pass else: self.fail()
def test_end_date_should_be_immutable(self): date_range = DateRange(datetime.date(2011, 9, 28), datetime.date(2011, 9, 29)) try: date_range.end_date = datetime.date(2011, 9, 30) except(AttributeError): pass else: self.fail()
def refreshGraphView(self, view, sport=None): logging.debug('>>') if self.windowmain is None: logging.debug("First call to refreshGraphView") logging.debug('<<') return date_selected = self.date.getDate() if view == "record": logging.debug('record view') if self.windowmain.recordview.get_current_page() == 0: self.refreshRecordGraphView("info") elif self.windowmain.recordview.get_current_page() == 1: self.refreshRecordGraphView("graphs") elif self.windowmain.recordview.get_current_page() == 2: self.refreshRecordGraphView("map") elif self.windowmain.recordview.get_current_page() == 3: self.refreshRecordGraphView("heartrate") elif self.windowmain.recordview.get_current_page() == 4: self.refreshRecordGraphView("analytics") elif view == "day": logging.debug('day view') self.windowmain.actualize_dayview(date_selected) elif view == "week": logging.debug('week view') date_range = DateRange.for_week_containing(date_selected) self.windowmain.actualize_weekview(date_range) elif view == "month": logging.debug('month view') date_range = DateRange.for_month_containing(date_selected) nameMonth, daysInMonth = getNameMonth(date_selected) self.windowmain.actualize_monthview(date_range, nameMonth, daysInMonth) elif view == "year": logging.debug('year view') date_range = DateRange.for_year_containing(date_selected) self.windowmain.actualize_yearview(date_range, date_selected.year) elif view == "listview": logging.debug('list view') self.refreshListView() elif view == "athlete": logging.debug('athlete view') self.windowmain.on_athleteview_activate() elif view == "stats": logging.debug('stats view') self.windowmain.on_statsview_activate() else: logging.error("Unknown view %s", view) logging.debug('<<')
def getRecordDayList(self, date, sport=None): logging.debug('>>') logging.debug('Retrieving data for %s', date) date_range = DateRange.for_month_containing(date) for activity in self.pytrainer_main.activitypool.get_activities_period( date_range, sport=sport): yield activity.date.day
def test_constructor_should_reject_none_end_date(self): try: DateRange(datetime.date(2011, 9, 28), None) except (TypeError): pass else: self.fail()
def refreshGraphView(self, view, sport=None): logging.debug('>>') if self.windowmain is None: logging.debug("First call to refreshGraphView") logging.debug('<<') return date_selected = self.date.getDate() if view=="record": logging.debug('record view') if self.windowmain.recordview.get_current_page()==0: self.refreshRecordGraphView("info") elif self.windowmain.recordview.get_current_page()==1: self.refreshRecordGraphView("graphs") elif self.windowmain.recordview.get_current_page()==2: self.refreshRecordGraphView("map") elif self.windowmain.recordview.get_current_page()==3: self.refreshRecordGraphView("heartrate") elif self.windowmain.recordview.get_current_page()==4: self.refreshRecordGraphView("analytics") elif view=="day": logging.debug('day view') self.windowmain.actualize_dayview(date_selected) elif view=="week": logging.debug('week view') date_range = DateRange.for_week_containing(date_selected) self.windowmain.actualize_weekview(date_range) elif view=="month": logging.debug('month view') date_range = DateRange.for_month_containing(date_selected) nameMonth, daysInMonth = getNameMonth(date_selected) self.windowmain.actualize_monthview(date_range, nameMonth, daysInMonth) elif view=="year": logging.debug('year view') date_range = DateRange.for_year_containing(date_selected) self.windowmain.actualize_yearview(date_range, date_selected.year) elif view=="listview": logging.debug('list view') self.refreshListView() elif view=="athlete": logging.debug('athlete view') self.windowmain.on_athleteview_activate() elif view=="stats": logging.debug('stats view') self.windowmain.on_statsview_activate() else: logging.error("Unknown view %s", view) logging.debug('<<')
def test_constructor_should_reject_date_rime_start_date(self): try: DateRange(datetime(2011, 9, 28), datetime.date(2011, 9, 29)) except (TypeError): pass else: self.fail() pass
def test_constructor_should_reject_end_date_before_start_date(self): date_before = datetime.date(2011, 8, 31) date_after = datetime.date(2011, 9, 28) try: DateRange(date_after, date_before) except (ValueError): pass else: self.fail()
def test_end_date_should_return_constructed_Value(self): date_range = DateRange(datetime.date(2011, 9, 28), datetime.date(2011, 9, 29)) self.assertEquals(datetime.date(2011, 9, 29), date_range.end_date)
def test_constructor_should_accept_end_date_same_as_start_date(self): DateRange(datetime.date(2011, 9, 28), datetime.date(2011, 9, 28))
def test_date_range_for_week_should_end_saturday(self): date_range = DateRange.for_week_containing(datetime.date(2011, 12, 7)) self.assertEquals(datetime.date(2011, 12, 10), date_range.end_date)
def test_date_range_for_week_should_start_sunday(self): date_range = DateRange.for_week_containing(datetime.date(2011, 12, 7)) self.assertEquals(datetime.date(2011, 12, 4), date_range.start_date)
def test_date_range_for_month_feb_should_end_feb_28(self): date_range = DateRange.for_month_containing(datetime.date(2011, 2, 11)) self.assertEquals(datetime.date(2011, 2, 28), date_range.end_date)
def test_date_range_for_month_dec_should_end_dec_31(self): date_range = DateRange.for_month_containing(datetime.date( 2011, 12, 11)) self.assertEquals(datetime.date(2011, 12, 31), date_range.end_date)
def test_date_range_for_month_should_start_first_day_of_month(self): date_range = DateRange.for_month_containing(datetime.date( 2011, 12, 11)) self.assertEquals(datetime.date(2011, 12, 1), date_range.start_date)
def test_date_range_for_month_should_start_first_day_of_month(self): date_range = DateRange.for_month_containing(datetime.date(2011, 12, 11)) self.assertEqual(datetime.date(2011, 12, 1), date_range.start_date)
def test_date_range_for_month_dec_should_end_dec_31(self): date_range = DateRange.for_month_containing(datetime.date(2011, 12, 11)) self.assertEqual(datetime.date(2011, 12, 31), date_range.end_date)
def test_activities_period(self): activity = list(self.service.get_activities_period(DateRange.for_week_containing(datetime.date(2016, 7, 24))))[0] self.assertEqual(self.activity, activity)
def test_date_range_for_month_feb_should_end_feb_28(self): date_range = DateRange.for_month_containing(datetime.date(2011, 2, 11)) self.assertEqual(datetime.date(2011, 2, 28), date_range.end_date)
def test_date_range_for_week_should_end_saturday(self): date_range = DateRange.for_week_containing(datetime.date(2011, 12, 7)) self.assertEqual(datetime.date(2011, 12, 10), date_range.end_date)
def test_date_range_for_week_should_start_sunday(self): date_range = DateRange.for_week_containing(datetime.date(2011, 12, 7)) self.assertEqual(datetime.date(2011, 12, 4), date_range.start_date)
def test_date_range_for_year_should_start_jan_1(self): date_range = DateRange.for_year_containing(datetime.date(2011, 12, 11)) self.assertEquals(datetime.date(2011, 1, 1), date_range.start_date)
def test_date_range_for_year_should_start_jan_1(self): date_range = DateRange.for_year_containing(datetime.date(2011, 12, 11)) self.assertEqual(datetime.date(2011, 1, 1), date_range.start_date)