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

Proposed by Carla Sella on 2015-03-29
Status: Merged
Approved by: Alan Pope 🍺🐧🐱 πŸ¦„ on 2015-04-12
Approved revision: 628
Merged at revision: 627
Proposed branch: lp:~carla-sella/ubuntu-calendar-app/weekview-testing-stubs-completed
Merge into: lp:ubuntu-calendar-app
Prerequisite: lp:~carla-sella/ubuntu-calendar-app/dayview-test-default-view
Diff against target: 223 lines (+125/-26)
4 files modified
tests/autopilot/calendar_app/__init__.py (+23/-1)
tests/autopilot/calendar_app/tests/test_monthview.py (+9/-0)
tests/autopilot/calendar_app/tests/test_weekview.py (+83/-25)
tests/autopilot/calendar_app/tests/test_yearview.py (+10/-0)
To merge this branch: bzr merge lp:~carla-sella/ubuntu-calendar-app/weekview-testing-stubs-completed
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration 2015-03-29 Approve on 2015-04-12
Alan Pope 🍺🐧🐱 πŸ¦„ Approve on 2015-04-12
Nicholas Skaggs 2015-03-29 Needs Fixing on 2015-04-10
Mihir Soni Approve on 2015-04-09
Review via email: mp+254495@code.launchpad.net

This proposal supersedes a proposal from 2015-03-29.

Commit Message

Autopilot tests for Calendar App.

Description of the Change

Completing test_default_view in test_weekview.py.

To post a comment you must log in.
Carla Sella (carla-sella) wrote : Posted in a previous version of this proposal

This can be merged if ok as checking if current day is highlighted has been completed.

review: Needs Fixing (continuous-integration)

FAILED: Continuous integration, rev:618
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~carla-sella/ubuntu-calendar-app/weekview-testing-stubs-completed/+merge/254495/+edit-commit-message

http://91.189.93.70:8080/job/ubuntu-calendar-app-ci/1119/
Executed test runs:
    FAILURE: http://91.189.93.70:8080/job/generic-mediumtests-utopic/2448/console
    FAILURE: http://91.189.93.70:8080/job/ubuntu-calendar-app-utopic-amd64-ci/590/console
    FAILURE: http://91.189.93.70:8080/job/ubuntu-calendar-app-vivid-amd64-ci/116/console

Click here to trigger a rebuild:
http://91.189.93.70:8080/job/ubuntu-calendar-app-ci/1119/rebuild

review: Needs Fixing (continuous-integration)
review: Needs Fixing (continuous-integration)
review: Needs Fixing (continuous-integration)
Mihir Soni (mihirsoni) wrote :

looks good to me
Thanks :)

review: Approve
Nicholas Skaggs (nskaggs) wrote :

Text conflict in tests/autopilot/calendar_app/__init__.py
Text conflict in tests/autopilot/calendar_app/tests/test_dayview.py
2 conflicts encountered.
bzr: ERROR: Conflicts from merge

Should be a simple fix.

review: Needs Fixing
627. By Carla Sella on 2015-04-10

Fixed two text conflicts.

628. By Carla Sella on 2015-04-10

Fixed wrong function name.

Looks great, thanks Carla!

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/calendar_app/__init__.py'
2--- tests/autopilot/calendar_app/__init__.py 2015-04-04 15:59:15 +0000
3+++ tests/autopilot/calendar_app/__init__.py 2015-04-10 19:34:31 +0000
4@@ -219,7 +219,7 @@
5
6 def safe_swipe_view(self, direction, view, date):
7 """
8- direction: direction to swip
9+ direction: direction to swipe
10 view: the view you are swiping against
11 date: a function object of the view
12 """
13@@ -276,6 +276,11 @@
14 local = utc.astimezone(tz.tzlocal())
15 return local
16
17+ @autopilot.logging.log_action(logger.info)
18+ def get_header(self):
19+ return self.wait_select_single(
20+ "AppHeader", objectName="MainView_Header")
21+
22 def press_header_todaybutton(self):
23 header = self.get_header()
24 header.click_action_button('todaybutton')
25@@ -432,6 +437,17 @@
26 sorteddays.insert(0, day)
27 return sorteddays
28
29+ @autopilot.logging.log_action(logger.info)
30+ def get_current_headerdatecomponent(self, now):
31+ today = datetime.date(now.year, now.month, now.day)
32+ header_date_components = self.select_many('HeaderDateComponent')
33+ for header in header_date_components:
34+ header_date = datetime.date(header.date.datetime.year,
35+ header.date.datetime.month,
36+ header.date.datetime.day)
37+ if header_date == today:
38+ return header
39+
40
41 class MonthView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
42
43@@ -651,12 +667,18 @@
44 'TimeLineBaseComponent', objectName='DayComponent-0').scrollHour
45
46 @autopilot.logging.log_action(logger.info)
47+ def get_weeknumber(self):
48+ return self._get_timeline_base().weekNumber
49+
50 def check_loading_spinnger(self):
51 timelinebasecomponent = self.get_active_timelinebasecomponent()
52 loading_spinner = timelinebasecomponent.wait_select_single(
53 "ActivityIndicator")
54 loading_spinner.running.wait_for(False)
55
56+ def _get_timeline_base(self):
57+ return self.select_single("TimeLineBaseComponent", isActive=True)
58+
59 @autopilot.logging.log_action(logger.info)
60 def get_active_timelinebasecomponent(self):
61 timelinebase_components = self.select_many(("TimeLineBaseComponent"))
62
63=== modified file 'tests/autopilot/calendar_app/tests/test_monthview.py'
64--- tests/autopilot/calendar_app/tests/test_monthview.py 2015-03-06 21:33:24 +0000
65+++ tests/autopilot/calendar_app/tests/test_monthview.py 2015-04-10 19:34:31 +0000
66@@ -136,3 +136,12 @@
67 self.assertEquals(calendar.day_abbr[calendar.FRIDAY], day_4_label)
68 self.assertEquals(calendar.day_abbr[calendar.SATURDAY], day_5_label)
69 self.assertEquals(calendar.day_abbr[calendar.SUNDAY], day_6_label)
70+
71+ def test_today_button(self):
72+ """ Verify that today button takes to today in month view """
73+ self._go_to_today(1)
74+
75+ header = self.app.main_view.get_header()
76+ header.click_action_button('todaybutton')
77+
78+ self._assert_today()
79
80=== modified file 'tests/autopilot/calendar_app/tests/test_weekview.py'
81--- tests/autopilot/calendar_app/tests/test_weekview.py 2015-04-02 15:24:49 +0000
82+++ tests/autopilot/calendar_app/tests/test_weekview.py 2015-04-10 19:34:31 +0000
83@@ -25,8 +25,9 @@
84 range = xrange
85
86 import datetime
87+from datetime import timedelta
88 from autopilot.matchers import Eventually
89-from testtools.matchers import Equals
90+from testtools.matchers import Equals, NotEquals
91 from random import randint, randrange
92
93 from calendar_app.tests import CalendarAppTestCase
94@@ -61,30 +62,87 @@
95 self.assertThat(self.app.main_view.get_month_year(self.week_view),
96 Equals(expected_month_name_year))
97
98- # TODO: check current day is highlighted
99-
100- # These testing stubs need completed
101- # def test_scroll_week_must_scroll_within_week(self):
102- # """Scrolling inside the timeline should scroll the weekdays"""
103- # pass
104-
105- # def test_change_week_across_month(self):
106- # """Changing week across months should update the month"""
107- # pass
108-
109- # def test_change_week_across_year(self):
110- # """Changing week across years should update the year"""
111- # pass
112-
113- # def test_month_to_week(self):
114- # """Changing from a month to weekview should
115- # start weekview on the first week of the month"""
116- # pass
117-
118- # def test_day_to_week(self):
119- # """Changing from a day to weekview should
120- # start weekview on the same week as the day"""
121- # pass
122+ # check current day is highlighted
123+ header_date = self.week_view.get_current_headerdatecomponent(now)
124+ self.assertEquals(header_date.dayColor[0], 221)
125+ self.assertEquals(header_date.dayColor[1], 72)
126+ self.assertEquals(header_date.dayColor[2], 20)
127+ self.assertEquals(header_date.dayColor[3], 255)
128+
129+ def test_scroll_week_must_scroll_weekdays(self):
130+ """Scrolling inside the timeline should scroll the weekdays"""
131+ before_days = self.week_view.get_days_of_week()
132+
133+ direction = 1
134+ no_of_swipes = 3
135+ for x in range(no_of_swipes):
136+ self.app.main_view.swipe_view(direction, self.week_view)
137+
138+ after_days = self.week_view.get_days_of_week()
139+
140+ self.assertThat(before_days[0], NotEquals(after_days[0]))
141+ self.assertThat(before_days[1], NotEquals(after_days[1]))
142+ self.assertThat(before_days[2], NotEquals(after_days[2]))
143+ self.assertThat(before_days[3], NotEquals(after_days[3]))
144+ self.assertThat(before_days[4], NotEquals(after_days[4]))
145+ self.assertThat(before_days[5], NotEquals(after_days[5]))
146+ self.assertThat(before_days[6], NotEquals(after_days[6]))
147+
148+ def test_change_week_across_months(self):
149+ """Changing week across months should update the month"""
150+ header = self.app.main_view.get_header()
151+ before_month = self.app.main_view.get_month_year(header)
152+ self.week_view.change_week(4)
153+
154+ after_month = self.app.main_view.get_month_year(header)
155+
156+ self.assertThat(before_month, NotEquals(after_month))
157+
158+ def test_change_week_across_year(self):
159+ """Changing week across years should update the year"""
160+ header = self.app.main_view.get_header()
161+ month_year_label = self.app.main_view.get_month_year(header)
162+ before_year = month_year_label[-4:]
163+
164+ current_week = self.week_view.get_current_weeknumber()
165+ direction = 1
166+ no_of_swipes = ((55 - current_week) * 3) # 3 swipes to change week
167+ for x in range(1, no_of_swipes):
168+ self.app.main_view.swipe_view(direction, self.week_view)
169+
170+ month_year_label = self.app.main_view.get_month_year(header)
171+ after_year = month_year_label[-4:]
172+
173+ self.assertThat(before_year, NotEquals(after_year))
174+
175+ def test_month_to_week(self):
176+ """Changing from a month to weekview should
177+ start weekview on the first day of the week"""
178+ self.app.main_view.go_to_month_view()
179+ self.app.main_view.go_to_week_view()
180+
181+ cal_week_firstday_ts = self.app.main_view.get_week_view().firstDay
182+ cal_week_firstday = datetime.date(cal_week_firstday_ts.datetime.year,
183+ cal_week_firstday_ts.datetime.month,
184+ cal_week_firstday_ts.datetime.day)
185+
186+ now = datetime.datetime.now()
187+ delta = datetime.datetime.weekday(now)
188+ first_dow = now - timedelta(delta)
189+ expected_first_dow = datetime.date(first_dow.year, first_dow.month,
190+ first_dow.day)
191+
192+ self.assertEquals(cal_week_firstday, expected_first_dow)
193+
194+ def test_day_to_week(self):
195+ """Changing from a day to weekview should
196+ start weekview on the same week as the day"""
197+ day_view = self.app.main_view.go_to_day_view()
198+ day_week_no = day_view.get_weeknumber()
199+ week_view = self.app.main_view.go_to_week_view()
200+ week_week_no = week_view.get_current_weeknumber()
201+
202+ self.assertEquals(day_week_no, week_week_no)
203
204 def test_change_week(self):
205 """It must be possible to change weeks by swiping the timeline"""
206
207=== modified file 'tests/autopilot/calendar_app/tests/test_yearview.py'
208--- tests/autopilot/calendar_app/tests/test_yearview.py 2014-10-02 12:38:28 +0000
209+++ tests/autopilot/calendar_app/tests/test_yearview.py 2015-04-10 19:34:31 +0000
210@@ -94,3 +94,13 @@
211 def test_show_previous_years(self):
212 """It must be possible to show previous years by swiping the view."""
213 self._change_year(-1)
214+
215+ def test_today_button(self):
216+ """ Verify that today button takes to today in month view """
217+ date = datetime.datetime.now()
218+ self._change_year(1)
219+
220+ header = self.app.main_view.get_header()
221+ header.click_action_button('todaybutton')
222+
223+ self.assertEqual(self.year_view.get_selected_day().date, date.day)

Subscribers

People subscribed via source and target branches

to status/vote changes: