Merge lp:~pkunal-parmar/ubuntu-calendar-app/Autopilot_Fix_TIMEZONE into lp:ubuntu-calendar-app

Proposed by Kunal Parmar
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 280
Merged at revision: 278
Proposed branch: lp:~pkunal-parmar/ubuntu-calendar-app/Autopilot_Fix_TIMEZONE
Merge into: lp:ubuntu-calendar-app
Diff against target: 182 lines (+43/-21)
5 files modified
tests/autopilot/calendar_app/emulators.py (+6/-0)
tests/autopilot/calendar_app/tests/test_dayview.py (+4/-4)
tests/autopilot/calendar_app/tests/test_monthview.py (+19/-9)
tests/autopilot/calendar_app/tests/test_weekview.py (+13/-7)
tests/autopilot/calendar_app/tests/test_yearview.py (+1/-1)
To merge this branch: bzr merge lp:~pkunal-parmar/ubuntu-calendar-app/Autopilot_Fix_TIMEZONE
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Nicholas Skaggs (community) Approve
Review via email: mp+220443@code.launchpad.net

Commit message

Bug #1291225

Converting time coming from QML to local time zone

Description of the change

Bug #1291225

Converting time coming from QML to local time zone

To post a comment you must log in.
279. By Kunal Parmar

log statement removed

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
280. By Kunal Parmar

pep8 error resolved

Revision history for this message
Nicholas Skaggs (nskaggs) :
review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
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/emulators.py'
2--- tests/autopilot/calendar_app/emulators.py 2014-04-29 17:34:35 +0000
3+++ tests/autopilot/calendar_app/emulators.py 2014-05-21 13:11:37 +0000
4@@ -9,6 +9,7 @@
5
6 from autopilot.introspection import dbus
7 from ubuntuuitoolkit import emulators as toolkit_emulators
8+from dateutil import tz
9
10
11 class MainView(toolkit_emulators.MainView):
12@@ -116,3 +117,8 @@
13 new_event = self.get_new_event()
14 return new_event.wait_select_single("Button",
15 objectName="cancel")
16+
17+ def to_local_date(self, date):
18+ utc = date.replace(tzinfo=tz.tzutc())
19+ local = utc.astimezone(tz.tzlocal())
20+ return local
21
22=== modified file 'tests/autopilot/calendar_app/tests/test_dayview.py'
23--- tests/autopilot/calendar_app/tests/test_dayview.py 2014-05-21 08:18:49 +0000
24+++ tests/autopilot/calendar_app/tests/test_dayview.py 2014-05-21 13:11:37 +0000
25@@ -38,7 +38,7 @@
26 def test_current_month_and_year_is_selected(self):
27 """By default, the day view shows the current month and year."""
28
29- now = datetime.datetime.utcnow()
30+ now = datetime.datetime.now()
31
32 expected_year = now.year
33 expected_month_name = now.strftime("%B")
34@@ -59,7 +59,7 @@
35 days = self.day_view.select_many(objectName="dateLabel")
36 days = [int(day.text) for day in days]
37
38- now = datetime.datetime.utcnow()
39+ now = datetime.datetime.now()
40
41 today = now.day
42 tomorrow = (now + datetime.timedelta(days=1)).day
43@@ -78,7 +78,7 @@
44 self.change_days(-1)
45
46 def change_days(self, direction):
47- now = datetime.datetime.utcnow()
48+ firstday = self.day_view.currentDay.datetime
49
50 for i in range(1, 5):
51 #prevent timing issues with swiping
52@@ -89,7 +89,7 @@
53
54 current_day = self.day_view.currentDay.datetime
55
56- expected_day = (now + datetime.timedelta(
57+ expected_day = (firstday + datetime.timedelta(
58 days=(i * direction)))
59
60 self.assertThat(self.strip(current_day),
61
62=== modified file 'tests/autopilot/calendar_app/tests/test_monthview.py'
63--- tests/autopilot/calendar_app/tests/test_monthview.py 2014-05-21 07:05:56 +0000
64+++ tests/autopilot/calendar_app/tests/test_monthview.py 2014-05-21 13:11:37 +0000
65@@ -37,30 +37,40 @@
66 sign = int(math.copysign(1, delta))
67
68 for _ in range(abs(delta)):
69- before = month_view.currentMonth.datetime
70+ before = self.main_view.to_local_date(
71+ month_view.currentMonth.datetime)
72
73 #prevent timing issues with swiping
74- old_month = month_view.currentMonth.datetime
75+ old_month = self.main_view.to_local_date(
76+ month_view.currentMonth.datetime)
77+
78 self.main_view.swipe_view(sign, month_view)
79- self.assertThat(lambda: month_view.currentMonth.datetime,
80+
81+ month_after = self.main_view.to_local_date(
82+ month_view.currentMonth.datetime)
83+
84+ self.assertThat(lambda: month_after,
85 Eventually(NotEquals(old_month)))
86
87 after = before + relativedelta(months=sign)
88
89 self.assertThat(lambda:
90- self.month_view.currentMonth.datetime.month,
91+ month_after.month,
92 Eventually(Equals(after.month)))
93 self.assertThat(lambda:
94- self.month_view.currentMonth.datetime.year,
95+ month_after.year,
96 Eventually(Equals(after.year)))
97
98 def _assert_today(self):
99- today = datetime.utcnow()
100- self.assertThat(lambda: self.month_view.currentMonth.datetime.day,
101+ local = self.main_view.to_local_date(
102+ self.month_view.currentMonth.datetime)
103+ today = datetime.now()
104+
105+ self.assertThat(lambda: local.day,
106 Eventually(Equals(today.day)))
107- self.assertThat(lambda: self.month_view.currentMonth.datetime.month,
108+ self.assertThat(lambda: local.month,
109 Eventually(Equals(today.month)))
110- self.assertThat(lambda: self.month_view.currentMonth.datetime.year,
111+ self.assertThat(lambda: local.year,
112 Eventually(Equals(today.year)))
113
114 def _test_go_to_today(self, delta):
115
116=== modified file 'tests/autopilot/calendar_app/tests/test_weekview.py'
117--- tests/autopilot/calendar_app/tests/test_weekview.py 2014-05-21 08:18:49 +0000
118+++ tests/autopilot/calendar_app/tests/test_weekview.py 2014-05-21 13:11:37 +0000
119@@ -41,12 +41,16 @@
120 first_dow = self._get_first_day_of_week()
121
122 #prevent timing issues with swiping
123- old_day = self.week_view.dayStart.datetime
124+ old_day = self.main_view.to_local_date(
125+ self.week_view.dayStart.datetime)
126 self.main_view.swipe_view(direction, self.week_view)
127- self.assertThat(lambda: self.week_view.dayStart.datetime,
128+ self.assertThat(lambda:
129+ self.main_view.to_local_date(
130+ self.week_view.dayStart.datetime),
131 Eventually(NotEquals(old_day)))
132
133- new_day_start = self.week_view.dayStart.datetime
134+ new_day_start = self.main_view.to_local_date(
135+ self.week_view.dayStart.datetime)
136
137 expected_day_start = first_dow + datetime.timedelta(
138 days=(7 * direction))
139@@ -81,8 +85,10 @@
140 return dateLabels
141
142 def _get_first_day_of_week(self):
143- date = self.week_view.dayStart.datetime
144- firstDay = self.week_view.firstDay.datetime
145+ date = self.main_view.to_local_date(self.week_view.dayStart.datetime)
146+ firstDay = self.main_view.to_local_date(
147+ self.week_view.firstDay.datetime)
148+
149 #sunday
150 if firstDay.weekday() == 6:
151 logger.debug("Locale has Sunday as first day of week")
152@@ -111,7 +117,7 @@
153 def test_current_month_and_year_is_selected(self):
154 """By default, the week view shows the current month and year."""
155
156- now = datetime.datetime.utcnow()
157+ now = datetime.datetime.now()
158
159 expected_year = now.year
160 expected_month_name = now.strftime("%B")
161@@ -125,7 +131,7 @@
162 def test_current_week_is_selected(self):
163 """By default, the week view shows the current week."""
164
165- now = datetime.datetime.utcnow()
166+ now = datetime.datetime.now()
167 days = self._get_days_of_week()
168 day_headers = self._get_date_label_headers()
169
170
171=== modified file 'tests/autopilot/calendar_app/tests/test_yearview.py'
172--- tests/autopilot/calendar_app/tests/test_yearview.py 2014-05-21 07:05:56 +0000
173+++ tests/autopilot/calendar_app/tests/test_yearview.py 2014-05-21 13:11:37 +0000
174@@ -115,7 +115,7 @@
175 Equals(datetime.now().year))
176
177 def current_month(self):
178- now = datetime.utcnow()
179+ now = datetime.now()
180 current_month_name = now.strftime("%B")
181
182 # for months after June, we must scroll down the page to have

Subscribers

People subscribed via source and target branches

to status/vote changes: