Merge lp:~thomir-deactivatedaccount/autopilot/temp-dev-fix-timezones into lp:~autopilot/autopilot/temp-dev

Proposed by Thomi Richards
Status: Merged
Approved by: Christopher Lee
Approved revision: 514
Merged at revision: 512
Proposed branch: lp:~thomir-deactivatedaccount/autopilot/temp-dev-fix-timezones
Merge into: lp:~autopilot/autopilot/temp-dev
Diff against target: 193 lines (+68/-47)
4 files modified
autopilot/introspection/types.py (+1/-1)
autopilot/tests/functional/__init__.py (+33/-1)
autopilot/tests/functional/test_input_stack.py (+5/-45)
autopilot/tests/functional/test_types.py (+29/-0)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/autopilot/temp-dev-fix-timezones
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Christopher Lee (community) Approve
Review via email: mp+220570@code.launchpad.net

Commit message

Fix DateTime issue.

Description of the change

Fix issue where DateTime proxy attributes show the wrong time due to the assumption that the timestamp was in UTC time.

To post a comment you must log in.
Revision history for this message
Christopher Lee (veebers) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:514
http://jenkins.qa.ubuntu.com/job/autopilot-autopilot-temp-dev-ci/100/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-autopilot-temp-dev-utopic-amd64-ci/60
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-autopilot-temp-dev-utopic-amd64-ci/60/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-autopilot-temp-dev-utopic-armhf-ci/60
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-autopilot-temp-dev-utopic-armhf-ci/60/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-autopilot-temp-dev-utopic-i386-ci/60
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-autopilot-temp-dev-utopic-i386-ci/60/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic-autopilot/103
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic-touch/92
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic-autopilot/83
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/449
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/449/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/787
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/787/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/6624
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/7504

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/autopilot-autopilot-temp-dev-ci/100/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/introspection/types.py'
2--- autopilot/introspection/types.py 2014-05-04 20:51:21 +0000
3+++ autopilot/introspection/types.py 2014-05-22 06:46:15 +0000
4@@ -604,7 +604,7 @@
5 """
6 def __init__(self, *args, **kwargs):
7 super(DateTime, self).__init__(*args, **kwargs)
8- self._cached_dt = datetime.utcfromtimestamp(self[0])
9+ self._cached_dt = datetime.fromtimestamp(self[0])
10
11 @property
12 def year(self):
13
14=== modified file 'autopilot/tests/functional/__init__.py'
15--- autopilot/tests/functional/__init__.py 2014-04-29 22:58:35 +0000
16+++ autopilot/tests/functional/__init__.py 2014-05-22 06:46:15 +0000
17@@ -27,9 +27,12 @@
18 import logging
19 from shutil import rmtree
20 import subprocess
21-from tempfile import mkdtemp
22+from tempfile import mkdtemp, mktemp
23 from testtools.content import text_content
24
25+
26+from autopilot import platform
27+from autopilot.tests.functional.fixtures import TempDesktopFile
28 from autopilot.testcase import AutopilotTestCase
29
30
31@@ -181,3 +184,32 @@
32 load_entry_point('autopilot==1.5.0', 'console_scripts', 'autopilot3')()
33 )
34 """
35+
36+
37+class QmlScriptRunnerMixin(object):
38+
39+ """A Mixin class that knows how to get a proxy object for a qml script."""
40+
41+ def start_qml_script(self, script_contents):
42+ """Launch a qml script."""
43+ qml_path = mktemp(suffix='.qml')
44+ open(qml_path, 'w').write(script_contents)
45+ self.addCleanup(os.remove, qml_path)
46+
47+ extra_args = ''
48+ if platform.model() != "Desktop":
49+ # We need to add the desktop-file-hint
50+ desktop_file = self.useFixture(
51+ TempDesktopFile()
52+ ).get_desktop_file_path()
53+ extra_args = '--desktop_file_hint={hint_file}'.format(
54+ hint_file=desktop_file
55+ )
56+
57+ return self.launch_test_application(
58+ "qmlscene",
59+ "-qt=qt5",
60+ qml_path,
61+ extra_args,
62+ app_type='qt',
63+ )
64
65=== modified file 'autopilot/tests/functional/test_input_stack.py'
66--- autopilot/tests/functional/test_input_stack.py 2014-04-08 00:04:17 +0000
67+++ autopilot/tests/functional/test_input_stack.py 2014-05-22 06:46:15 +0000
68@@ -36,6 +36,7 @@
69 from autopilot.matchers import Eventually
70 from autopilot.testcase import AutopilotTestCase, multiply_scenarios
71 from autopilot.tests.functional.fixtures import TempDesktopFile
72+from autopilot.tests.functional import QmlScriptRunnerMixin
73 from autopilot.utilities import on_test_started
74
75
76@@ -225,7 +226,7 @@
77 return False
78
79
80-class OSKBackendTests(AutopilotTestCase):
81+class OSKBackendTests(AutopilotTestCase, QmlScriptRunnerMixin):
82 """Testing the Onscreen Keyboard (Ubuntu Keyboard) backend specifically.
83
84 There are limitations (i.e. on device only, window-mocker doesn't work on
85@@ -248,24 +249,6 @@
86
87 return text_area
88
89- def _start_qml_script(self, script_contents):
90- """Launch a qml script."""
91- qml_path = mktemp(suffix='.qml')
92- open(qml_path, 'w').write(script_contents)
93- self.addCleanup(os.remove, qml_path)
94-
95- desktop_file = self.useFixture(
96- TempDesktopFile()
97- ).get_desktop_file_path()
98-
99- return self.launch_test_application(
100- "qmlscene",
101- "-qt=qt5",
102- qml_path,
103- '--desktop_file_hint=%s' % desktop_file,
104- app_type='qt',
105- )
106-
107 def _launch_simple_input(self):
108 simple_script = dedent("""
109 import QtQuick 2.0
110@@ -302,7 +285,7 @@
111
112 """)
113
114- return self._start_qml_script(simple_script)
115+ return self.start_qml_script(simple_script)
116
117 @skipIf(platform.model() == 'Desktop', "Only suitable on a device")
118 @skipIf(not osk_backend_available(), "Test requires OSK Backend installed")
119@@ -416,30 +399,7 @@
120 self.button_status.text, Eventually(Equals("Touch Release")))
121
122
123-class TouchGesturesTests(AutopilotTestCase):
124- def _start_qml_script(self, script_contents):
125- """Launch a qml script."""
126- qml_path = mktemp(suffix='.qml')
127- open(qml_path, 'w').write(script_contents)
128- self.addCleanup(os.remove, qml_path)
129-
130- extra_args = ''
131- if platform.model() != "Desktop":
132- # We need to add the desktop-file-hint
133- desktop_file = self.useFixture(
134- TempDesktopFile()
135- ).get_desktop_file_path()
136- extra_args = '--desktop_file_hint={hint_file}'.format(
137- hint_file=desktop_file
138- )
139-
140- return self.launch_test_application(
141- "qmlscene",
142- "-qt=qt5",
143- qml_path,
144- extra_args,
145- app_type='qt',
146- )
147+class TouchGesturesTests(AutopilotTestCase, QmlScriptRunnerMixin):
148
149 def test_pinch_gesture(self):
150 """Ensure that the pinch gesture pinches as expected."""
151@@ -466,7 +426,7 @@
152 start_green_bg = [0, 255, 0, 255]
153 end_blue_bg = [0, 0, 255, 255]
154
155- app = self._start_qml_script(test_qml)
156+ app = self.start_qml_script(test_qml)
157 pinch_widget = app.select_single("QQuickRectangle")
158 widget_bg_colour = lambda: pinch_widget.color
159
160
161=== added file 'autopilot/tests/functional/test_types.py'
162--- autopilot/tests/functional/test_types.py 1970-01-01 00:00:00 +0000
163+++ autopilot/tests/functional/test_types.py 2014-05-22 06:46:15 +0000
164@@ -0,0 +1,29 @@
165+
166+from datetime import datetime
167+
168+from autopilot.testcase import AutopilotTestCase
169+from autopilot.tests.functional import QmlScriptRunnerMixin
170+
171+from textwrap import dedent
172+
173+
174+class TypeTests(AutopilotTestCase, QmlScriptRunnerMixin):
175+
176+ def test_date(self):
177+ proxy = self.start_qml_script(
178+ dedent(
179+ """\
180+ import QtQuick 2.0
181+
182+ Item {
183+ objectName: "TestMePlease"
184+ property date foo: "2014-01-01"
185+ }
186+ """
187+ )
188+ )
189+ item = proxy.select_single('*', objectName="TestMePlease")
190+ self.assertEqual(
191+ item.foo,
192+ datetime(2014, 1, 1, 0, 0, 0)
193+ )

Subscribers

People subscribed via source and target branches

to all changes: