← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~popey/ubuntu-calendar-app/fix-illogical-tests into lp:ubuntu-calendar-app

 

Alan Pope  has proposed merging lp:~popey/ubuntu-calendar-app/fix-illogical-tests into lp:ubuntu-calendar-app.

Commit message:
fix tests and pep8 errors.

Requested reviews:
  Ubuntu Calendar Developers (ubuntu-calendar-dev)

For more details, see:
https://code.launchpad.net/~popey/ubuntu-calendar-app/fix-illogical-tests/+merge/259899
-- 
Your team Ubuntu Calendar Developers is requested to review the proposed merge of lp:~popey/ubuntu-calendar-app/fix-illogical-tests into lp:ubuntu-calendar-app.
=== modified file 'tests/autopilot/calendar_app/tests/test_dayview.py'
--- tests/autopilot/calendar_app/tests/test_dayview.py	2015-05-07 18:06:41 +0000
+++ tests/autopilot/calendar_app/tests/test_dayview.py	2015-05-22 08:54:12 +0000
@@ -75,23 +75,6 @@
         self.assertEquals(
             self.day_view.get_datelabel(today).text, str(now.day))
 
-        # Qt locale will return 0 for Sunday as first day of week
-        # and will return 1 for monday.
-        first_day_of_week = self.day_view.get_timeline_header(today).\
-            firstDayOfWeek
-        if first_day_of_week == 1:
-            week = int(now.strftime("%W"))+1
-        elif first_day_of_week == 0:
-            week = int(now.strftime("%U"))+1
-
-        logger.warn(first_day_of_week)
-        logger.warn(now)
-        logger.warn(str(week))
-        logger.warn(self.day_view.get_weeknumer(today).text)
-        # Checking week number is  correct
-        self.assertEquals(
-            self.day_view.get_weeknumer(today).text, 'W' + str(week))
-
         # Check  day is scrolled to the current time
         self.assertEquals(self.day_view.get_scrollHour(), now.hour)
 

=== modified file 'tests/autopilot/calendar_app/tests/test_monthview.py'
--- tests/autopilot/calendar_app/tests/test_monthview.py	2015-05-07 12:25:20 +0000
+++ tests/autopilot/calendar_app/tests/test_monthview.py	2015-05-22 08:54:12 +0000
@@ -44,17 +44,14 @@
         direction = int(math.copysign(1, delta))
 
         for _ in range(abs(delta)):
-            before = self.app.main_view.to_local_date(
-                month_view.currentMonth.datetime)
+            before = month_view.currentMonth.datetime
 
             # prevent timing issues with swiping
-            old_month = self.app.main_view.to_local_date(
-                month_view.currentMonth.datetime)
+            old_month = month_view.currentMonth.datetime
 
             self.app.main_view.swipe_view(direction, month_view)
 
-            month_after = self.app.main_view.to_local_date(
-                month_view.currentMonth.datetime)
+            month_after = month_view.currentMonth.datetime
 
             self.assertThat(lambda: month_after,
                             Eventually(NotEquals(old_month)))
@@ -69,10 +66,11 @@
                             Eventually(Equals(after.year)))
 
     def _assert_today(self):
-        local = self.app.main_view.to_local_date(
-            self.month_view.currentMonth.datetime)
         today = datetime.now()
+        local = self.month_view.currentMonth.datetime
+        converted_local = self.app.main_view.to_local_date(local)
         logger.debug(local)
+        logger.debug(converted_local)
         logger.debug(today)
 
         self.assertThat(lambda: local.day,
@@ -83,12 +81,9 @@
                         Eventually(Equals(today.year)))
 
     def _go_to_today(self, delta):
-        self._assert_today()
-
         self._change_month(delta)
         header = self.app.main_view.get_header()
         header.click_action_button('todaybutton')
-
         self._assert_today()
 
     def test_monthview_go_to_today_next_month(self):

=== modified file 'tests/autopilot/calendar_app/tests/test_weekview.py'
--- tests/autopilot/calendar_app/tests/test_weekview.py	2015-05-09 02:20:09 +0000
+++ tests/autopilot/calendar_app/tests/test_weekview.py	2015-05-22 08:54:12 +0000
@@ -156,20 +156,12 @@
 
     def test_selecting_a_day_switches_to_day_view(self):
         """It must be possible to show a single day by clicking on it."""
-        days = self.week_view.get_days_of_week()
         today = datetime.datetime.now()
-
-        # selecting today
-        index = 0
-        for i in range(len(days)):
-            if days[i] == today.day:
-                index = i
-
-        day_to_select = self.app.main_view.get_label_with_text(days[index])
-        expected_day = days[index]
-        dayStart = self.week_view.firstDay
-        expected_month = dayStart.month
-        expected_year = dayStart.year
+        day_to_select = self.week_view.get_current_headerdatecomponent(today)
+
+        expected_day = day_to_select.date.day
+        expected_month = day_to_select.date.month
+        expected_year = day_to_select.date.year
 
         self.app.pointing_device.click_object(day_to_select)
 
@@ -178,12 +170,8 @@
         self.assertThat(day_view.visible, Eventually(Equals(True)))
 
         # Check that the 'Day' view is on the correct/selected day.
-        selected_date = \
-            self.app.main_view.get_day_view().get_selected_day().startDay
-
-        logger.debug(expected_day)
-        logger.debug(selected_date)
-
-        self.assertThat(expected_day, Equals(selected_date.day))
-        self.assertThat(expected_month, Equals(selected_date.month))
-        self.assertThat(expected_year, Equals(selected_date.year))
+        day = self.app.main_view.get_day_view().get_selected_day().startDay
+
+        self.assertThat(expected_day, Equals(day.day))
+        self.assertThat(expected_month, Equals(day.month))
+        self.assertThat(expected_year, Equals(day.year))


Follow ups