← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~carla-sella/ubuntu-calendar-app/weekview-testing-stubs-completed into lp:ubuntu-calendar-app

 

Carla Sella has proposed merging lp:~carla-sella/ubuntu-calendar-app/weekview-testing-stubs-completed into lp:ubuntu-calendar-app with lp:~carla-sella/ubuntu-calendar-app/dayview-test-default-view as a prerequisite.

Requested reviews:
  Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot): continuous-integration
  Nicholas Skaggs (nskaggs)

For more details, see:
https://code.launchpad.net/~carla-sella/ubuntu-calendar-app/weekview-testing-stubs-completed/+merge/254495

Completing test_default_view in test_weekview.py.
-- 
Your team Ubuntu Calendar Developers is subscribed to branch lp:ubuntu-calendar-app.
=== modified file 'tests/autopilot/calendar_app/__init__.py'
--- tests/autopilot/calendar_app/__init__.py	2015-03-31 20:40:24 +0000
+++ tests/autopilot/calendar_app/__init__.py	2015-03-31 20:40:24 +0000
@@ -428,6 +428,17 @@
                 sorteddays.insert(0, day)
         return sorteddays
 
+    @autopilot.logging.log_action(logger.info)
+    def get_current_headerdatecomponent(self, now):
+        today = datetime.date(now.year, now.month, now.day)
+        header_date_components = self.select_many('HeaderDateComponent')
+        for header in header_date_components:
+            header_date = datetime.date(header.date.datetime.year,
+                                        header.date.datetime.month,
+                                        header.date.datetime.day)
+            if header_date == today:
+                return header
+
 
 class MonthView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
@@ -636,7 +647,7 @@
             'Label', objectName='dateLabel')
 
     @autopilot.logging.log_action(logger.info)
-    def get_weeknumer(self, today):
+    def get_weeknumer_label(self, today):
         current_day_header = self.get_timeline_header(today)
         return current_day_header.wait_select_single(
             'Label', objectName='weeknumber')
@@ -646,6 +657,13 @@
         return self.wait_select_single(
             'TimeLineBaseComponent', objectName='DayComponent-0').scrollHour
 
+    @autopilot.logging.log_action(logger.info)
+    def get_weeknumber(self):
+        return self._get_timeline_base().weekNumber
+
+    def _get_timeline_base(self):
+        return self.select_single("TimeLineBaseComponent", isActive=True)
+
 
 class AgendaView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 

=== modified file 'tests/autopilot/calendar_app/tests/test_dayview.py'
--- tests/autopilot/calendar_app/tests/test_dayview.py	2015-03-31 20:40:24 +0000
+++ tests/autopilot/calendar_app/tests/test_dayview.py	2015-03-31 20:40:24 +0000
@@ -74,7 +74,8 @@
 
         # Checking week number is  correct
         self.assertEquals(
-            self.day_view.get_weeknumer(today).text, 'W' + now.strftime("%U"))
+            self.day_view.get_weeknumer_label(today).text,
+            'W' + now.strftime("%U"))
 
         # 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_weekview.py'
--- tests/autopilot/calendar_app/tests/test_weekview.py	2015-02-26 16:29:18 +0000
+++ tests/autopilot/calendar_app/tests/test_weekview.py	2015-03-31 20:40:24 +0000
@@ -25,6 +25,7 @@
     range = xrange
 
 import datetime
+from datetime import timedelta
 from autopilot.matchers import Eventually
 from testtools.matchers import Equals
 from random import randint, randrange
@@ -61,7 +62,12 @@
         self.assertThat(self.app.main_view.get_month_year(self.week_view),
                         Equals(expected_month_name_year))
 
-        # TODO: check current day is highlighted
+        # check current day is highlighted
+        header_date = self.week_view.get_current_headerdatecomponent(now)
+        self.assertEquals(header_date.dayColor[0], 221)
+        self.assertEquals(header_date.dayColor[1], 72)
+        self.assertEquals(header_date.dayColor[2], 20)
+        self.assertEquals(header_date.dayColor[3], 255)
 
     # These testing stubs need completed
     # def test_scroll_week_must_scroll_within_week(self):
@@ -76,15 +82,34 @@
         # """Changing week across years should update the year"""
         # pass
 
-    # def test_month_to_week(self):
-        # """Changing from a month to weekview should
-        # start weekview on the first week of the month"""
-        # pass
-
-    # def test_day_to_week(self):
-        # """Changing from a day to weekview should
-        # start weekview on the same week as the day"""
-        # pass
+    def test_month_to_week(self):
+        """Changing from a month to weekview should
+         start weekview on the first day of the week"""
+        self.app.main_view.go_to_month_view()
+        self.app.main_view.go_to_week_view()
+
+        cal_week_firstday_ts = self.app.main_view.get_week_view().firstDay
+        cal_week_firstday = datetime.date(cal_week_firstday_ts.datetime.year,
+                                          cal_week_firstday_ts.datetime.month,
+                                          cal_week_firstday_ts.datetime.day)
+
+        now = datetime.datetime.now()
+        delta = datetime.datetime.weekday(now)
+        first_dow = now - timedelta(delta)
+        expected_first_dow = datetime.date(first_dow.year, first_dow.month,
+                                           first_dow.day)
+
+        self.assertEquals(cal_week_firstday, expected_first_dow)
+
+    def test_day_to_week(self):
+        """Changing from a day to weekview should
+           start weekview on the same week as the day"""
+        day_view = self.app.main_view.go_to_day_view()
+        day_week_no = day_view.get_weeknumber()
+        week_view = self.app.main_view.go_to_week_view()
+        week_week_no = week_view.get_current_weeknumber()
+
+        self.assertEquals(day_week_no, week_week_no)
 
     def test_change_week(self):
         """It must be possible to change weeks by swiping the timeline"""


Follow ups