Merge lp:~nskaggs/autopilot/fix-1328600 into lp:autopilot

Proposed by Nicholas Skaggs
Status: Superseded
Proposed branch: lp:~nskaggs/autopilot/fix-1328600
Merge into: lp:autopilot
Diff against target: 507 lines (+183/-87)
8 files modified
autopilot/introspection/types.py (+14/-3)
autopilot/tests/functional/test_types.py (+8/-2)
autopilot/tests/unit/test_types.py (+122/-47)
debian/control (+35/-30)
debian/copyright (+0/-1)
debian/python3-autopilot-tests.install (+2/-2)
debian/python3-autopilot-vis.install (+1/-1)
debian/python3-autopilot.install (+1/-1)
To merge this branch: bzr merge lp:~nskaggs/autopilot/fix-1328600
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Robert Bruce Park (community) Approve
Christopher Lee (community) Needs Fixing
Thomi Richards (community) Approve
Barry Warsaw Pending
Review via email: mp+227399@code.launchpad.net

This proposal has been superseded by a proposal from 2014-10-02.

Commit message

Workaround around 32-bit platform limitations with regards to timestamps. Bug 1328600

Also also changed the static values to be defined variables. This is different than the other tests, so feel free to nitpick at it and I'll revert back to the static values.

Note in this case, I'm not sure a scenario for the large value would work well, thus it's left as a single testcase.

Description of the change

Fixes bug 1328600. Includes a test for "large" timestamps as well

This works around 32-bit platform limitations.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:506
http://jenkins.qa.ubuntu.com/job/autopilot-ci/804/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-amd64-ci/79
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-amd64-ci/79/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-armhf-ci/78
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-armhf-ci/78/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-i386-ci/78
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-i386-ci/78/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/2206
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic-autopilot/219
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/2415
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3380
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3380/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/10094
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic-autopilot/283
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2059
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2059/artifact/work/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

This doesn't actually fix the problem, it just creates new problems. Please see my comment on the bug report:

https://bugs.launchpad.net/ubuntu-calendar-app/+bug/1328600/comments/9

Thanks for the patch though, but it looks like this is going to be a bit more of an involved fix.

Cheers,

review: Disapprove
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

So the idea of using tzlocal seems to suffer from daylight savings problem, unless I'm missing something.

>>> from datetime import datetime, time, timedelta
>>> from dateutil.tz import tzlocal, tzutc
>>> print(datetime.fromtimestamp(1377209927))
2013-08-22 18:18:47
>>> print(datetime.fromtimestamp(1377209927,tzutc()))
2013-08-22 22:18:47+00:00
>>> naive = datetime.fromtimestamp(0) + timedelta(seconds=1377209927)
>>> print(naive)
2013-08-22 17:18:47
>>> aware = naive.replace(tzinfo=tzlocal())
>>> print(aware)
2013-08-22 17:18:47-04:00
>>> print(aware.astimezone(tzutc()))
2013-08-22 21:18:47+00:00
>>> aware2 = datetime.fromtimestamp(0, tzlocal())
>>> print(aware2)
1969-12-31 19:00:00-05:00
>>> print(aware2.astimezone(tzutc()))
1970-01-01 00:00:00+00:00
>>> try2 = aware2 + timedelta(seconds=1377209927)
>>> print(try2)
2013-08-22 17:18:47-04:00
>>> print(try2.astimezone(tzutc()))
2013-08-22 21:18:47+00:00

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Going to grab the local offset at the time of the timestamp and apply it against the fromtimestamp date.

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 :
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
Thomi Richards (thomir-deactivatedaccount) wrote :

I have a couple of comments in the diff.

Overall, this looks excellent - thank you for taking this on.

There's one change I'd like you to make in the tests, and I'd really like Barry Warsaw to review the implementation.

I'm setting this to approve, so you don't need a re-review once those two things have happeend (I trust ya :D )

review: Approve
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Oh, also, CI has to pass (obviously)

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 :
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
Nicholas Skaggs (nskaggs) wrote :

Tests don't want to run now?

/var/local/autopilot/setup.log: I: Running autopilot
/var/local/autopilot/setup.log: I: Using python2
tail: '/var/lib/lxc//utopic-amd64-20140619-0752/run/delta//var/local/autopilot/autopilot.log' has become accessible
/var/local/autopilot/autopilot.log: Loading tests from: /usr/lib/python2.7/dist-packages
/var/local/autopilot/autopilot.log:
/var/local/autopilot/autopilot.log: Did not find any tests
/var/local/autopilot/autopilot.log:
/var/local/autopilot/autopilot.log: ----------------------------------------------------------------------
/var/local/autopilot/autopilot.log: Ran 0 tests in 0.126s
/var/local/autopilot/autopilot.log:
/var/local/autopilot/autopilot.log: OK
/var/local/autopilot/setup.log: I: Using python3
tail: /var/lib/lxc//utopic-amd64-20140619-0752/run/delta//var/local/autopilot/autopilot.log: file truncated
/var/local/autopilot/autopilot.log:
/var/local/autopilot/autopilot.log: ----------------------------------------------------------------------
/var/local/autopilot/autopilot.log: Ran 0 tests in 0.110s
/var/local/autopilot/autopilot.log:
/var/local/autopilot/autopilot.log: OK
/var/local/autopilot/setup.log: I: No test left to run

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 :
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 :
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 :
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 :
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 :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~nskaggs/autopilot/fix-1328600 updated
530. By Nicholas Skaggs

merge trunk

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

Why is this running 0 tests?

lp:~nskaggs/autopilot/fix-1328600 updated
531. By Nicholas Skaggs

swap TestWithScenarios around

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~nskaggs/autopilot/fix-1328600 updated
532. By Nicholas Skaggs

undo swap

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

I see a crash:

PythonArgs: ['/usr/sbin/aa-status']
Traceback:
 Traceback (most recent call last):
   File "/usr/sbin/aa-status", line 194, in <module>
     commands[cmd]()
   File "/usr/sbin/aa-status", line 17, in cmd_enabled
     if get_profiles() == {}:
   File "/usr/sbin/aa-status", line 92, in get_profiles
     for p in open(apparmor_profiles).readlines():
 PermissionError: [Errno 13] Permission denied: '/sys/kernel/security/apparmor/profiles'

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)
lp:~nskaggs/autopilot/fix-1328600 updated
533. By Nicholas Skaggs

add depends to tests as well

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
Nicholas Skaggs (nskaggs) wrote :

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/autopilot/tests/functional/test_types.py", line 28, in test_date
    datetime(2014, 1, 1, 0, 0, 0)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 338, in assertEqual
    self.assertThat(observed, matcher, message)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 423, in assertThat
    raise mismatch_error
testtools.matchers._impl.MismatchError: DateTime(2014-01-01 00:00:00) != datetime.datetime(2014, 1, 1, 0, 0)

lp:~nskaggs/autopilot/fix-1328600 updated
534. By Nicholas Skaggs

tweak functional test

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~nskaggs/autopilot/fix-1328600 updated
535. By Nicholas Skaggs

add tzlocal to datetime functional test

536. By Nicholas Skaggs

wrap and sort packaging tweaks

Revision history for this message
Christopher Lee (veebers) wrote :

A couple of minor indent issues. Deeper review to come.

review: Needs Fixing
Revision history for this message
Robert Bruce Park (robru) wrote :

Packaging looks good, thanks for the wrap-and-sort, makes for a noisy diff now but easier to read later.

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

PASSED: Continuous integration, rev:535
http://jenkins.qa.ubuntu.com/job/autopilot-ci/865/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-amd64-ci/140
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-amd64-ci/140/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-armhf-ci/139
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-armhf-ci/139/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-i386-ci/139
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-i386-ci/139/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/4627
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic-autopilot/303
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/4409
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/5879
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/5879/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/12911
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic-autopilot/342
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3727
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3727/artifact/work/output/*zip*/output.zip

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

review: Approve (continuous-integration)
lp:~nskaggs/autopilot/fix-1328600 updated
537. By Nicholas Skaggs

fix layout, properly construct object for functional test

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:536
http://jenkins.qa.ubuntu.com/job/autopilot-ci/866/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-amd64-ci/141
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-amd64-ci/141/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-armhf-ci/140
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-armhf-ci/140/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-i386-ci/140
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-i386-ci/140/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/4631
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic-autopilot/304
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/4413
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/5883
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/5883/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/12920
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic-autopilot/343
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3732
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3732/artifact/work/output/*zip*/output.zip

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

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

PASSED: Continuous integration, rev:537
http://jenkins.qa.ubuntu.com/job/autopilot-ci/867/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-amd64-ci/142
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-amd64-ci/142/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-armhf-ci/141
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-armhf-ci/141/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-i386-ci/141
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-i386-ci/141/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/4633
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic-autopilot/305
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/4415
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/5885
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/5885/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/12923
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic-autopilot/344
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3733
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3733/artifact/work/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Can you provide an update on what you'd like to see with mp?

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'autopilot/introspection/types.py'
--- autopilot/introspection/types.py 2014-05-29 19:44:44 +0000
+++ autopilot/introspection/types.py 2014-09-08 23:54:02 +0000
@@ -37,7 +37,8 @@
3737
38"""38"""
3939
40from datetime import datetime, time40from datetime import datetime, time, timedelta
41from dateutil.tz import tzlocal
41import dbus42import dbus
42import logging43import logging
43from testtools.matchers import Equals44from testtools.matchers import Equals
@@ -547,6 +548,8 @@
547 """The DateTime class represents a date and time in the UTC timezone.548 """The DateTime class represents a date and time in the UTC timezone.
548549
549 DateTime is constructed by passing a unix timestamp in to the constructor.550 DateTime is constructed by passing a unix timestamp in to the constructor.
551 The incoming timestamp is assumed to be in localtime.
552 For date support for 32-bit platforms beyond 2038, we use a timedelta.
550 Timestamps are expressed as the number of seconds since 1970-01-01T00:00:00553 Timestamps are expressed as the number of seconds since 1970-01-01T00:00:00
551 in the UTC timezone::554 in the UTC timezone::
552555
@@ -573,6 +576,9 @@
573 18576 18
574 >>> my_dt.second577 >>> my_dt.second
575 47578 47
579 >>> my_dt.tzinfo
580 UTC
581
576582
577 Two DateTime objects can be compared for equality::583 Two DateTime objects can be compared for equality::
578584
@@ -599,7 +605,8 @@
599 """605 """
600 def __init__(self, *args, **kwargs):606 def __init__(self, *args, **kwargs):
601 super(DateTime, self).__init__(*args, **kwargs)607 super(DateTime, self).__init__(*args, **kwargs)
602 self._cached_dt = datetime.fromtimestamp(self[0])608 self._cached_dt = datetime.fromtimestamp(
609 0, tz=tzlocal()) + timedelta(seconds=self[0])
603610
604 @property611 @property
605 def year(self):612 def year(self):
@@ -627,7 +634,11 @@
627634
628 @property635 @property
629 def timestamp(self):636 def timestamp(self):
630 return self[0]637 return self._cached_dt.timestamp
638
639 @property
640 def tzinfo(self):
641 return self._cached_dt.tzinfo
631642
632 @property643 @property
633 def datetime(self):644 def datetime(self):
634645
=== modified file 'autopilot/tests/functional/test_types.py'
--- autopilot/tests/functional/test_types.py 2014-05-22 06:41:16 +0000
+++ autopilot/tests/functional/test_types.py 2014-09-08 23:54:02 +0000
@@ -1,8 +1,10 @@
11
2from datetime import datetime2from datetime import datetime, timedelta
3import time
34
4from autopilot.testcase import AutopilotTestCase5from autopilot.testcase import AutopilotTestCase
5from autopilot.tests.functional import QmlScriptRunnerMixin6from autopilot.tests.functional import QmlScriptRunnerMixin
7from dateutil.tz import tzlocal
68
7from textwrap import dedent9from textwrap import dedent
810
@@ -23,7 +25,11 @@
23 )25 )
24 )26 )
25 item = proxy.select_single('*', objectName="TestMePlease")27 item = proxy.select_single('*', objectName="TestMePlease")
28 dt = datetime(2014, 1, 1, 0, 0, 0, tzinfo=tzlocal())
29 timestamp = time.mktime(dt.timetuple())
30 dt = datetime.fromtimestamp(
31 0, tz=tzlocal()) + timedelta(seconds=timestamp)
26 self.assertEqual(32 self.assertEqual(
27 item.foo,33 item.foo,
28 datetime(2014, 1, 1, 0, 0, 0)34 dt
29 )35 )
3036
=== modified file 'autopilot/tests/unit/test_types.py'
--- autopilot/tests/unit/test_types.py 2014-07-22 02:39:26 +0000
+++ autopilot/tests/unit/test_types.py 2014-09-08 23:54:02 +0000
@@ -17,8 +17,9 @@
17# along with this program. If not, see <http://www.gnu.org/licenses/>.17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#18#
1919
20from datetime import datetime, time20from datetime import datetime, time, timedelta
21from testscenarios import TestWithScenarios21import pytz
22from testscenarios import TestWithScenarios, multiply_scenarios
22from testtools import TestCase23from testtools import TestCase
23from testtools.matchers import Equals, IsInstance, NotEquals, raises24from testtools.matchers import Equals, IsInstance, NotEquals, raises
2425
@@ -281,79 +282,153 @@
281 self.assertEqual(repr(c), str(c))282 self.assertEqual(repr(c), str(c))
282283
283284
284class DateTimeTests(TestCase):285class DateTimeTests(TestWithScenarios, TestCase):
286
287 timestamps = [
288 ('32bitlimit',
289 {'timestamp': 2983579200
290 }),
291
292 ('winter',
293 {'timestamp': 1389744000
294 }),
295
296 ('summer',
297 {'timestamp': 1405382400
298 })
299 ]
300
301 timezones = [
302 ('UTC',
303 {'timezone': 'UTC'
304 }),
305
306 ('NewZealand',
307 {'timezone': 'NZ',
308 }),
309
310 ('Pacific',
311 {'timezone': 'US/Pacific'
312 }),
313
314 ('Hongkong',
315 {'timezone': 'Hongkong'
316 }),
317
318 ('MSK',
319 {'timezone': 'Europe/Moscow'
320 })
321 ]
322
323 scenarios = multiply_scenarios(timestamps, timezones)
324
325 def local_timezone(self):
326 tz = pytz.timezone(self.timezone)
327 return tz
328
329 def local_from_timestamp(self, timestamp):
330 # fromtimestamp is naive
331 # thus we need create a "local" timestamp for test comparision
332 # and support 32-bit limit via timedelta
333 return datetime.fromtimestamp(
334 0, tz=self.local_timezone()) + timedelta(seconds=timestamp)
285335
286 def test_can_construct_datetime(self):336 def test_can_construct_datetime(self):
287 dt = DateTime(1377209927)337 with patch('autopilot.introspection.types.tzlocal',
288 self.assertThat(dt, IsInstance(dbus.Array))338 new=self.local_timezone):
339 dt = DateTime(self.timestamp)
340 self.assertThat(dt, IsInstance(dbus.Array))
289341
290 def test_datetime_has_slice_access(self):342 def test_datetime_has_slice_access(self):
291 dt = DateTime(1377209927)343 with patch('autopilot.introspection.types.tzlocal',
344 new=self.local_timezone):
345 dt = DateTime(self.timestamp)
292346
293 self.assertThat(dt[0], Equals(1377209927))347 self.assertThat(dt[0], Equals(self.timestamp))
294348
295 def test_datetime_has_properties(self):349 def test_datetime_has_properties(self):
296 dt = DateTime(1377209927)350 with patch('autopilot.introspection.types.tzlocal',
351 new=self.local_timezone):
352 dt = DateTime(self.timestamp)
297353
298 self.assertTrue(hasattr(dt, 'timestamp'))354 self.assertTrue(hasattr(dt, 'timestamp'))
299 self.assertTrue(hasattr(dt, 'year'))355 self.assertTrue(hasattr(dt, 'year'))
300 self.assertTrue(hasattr(dt, 'month'))356 self.assertTrue(hasattr(dt, 'month'))
301 self.assertTrue(hasattr(dt, 'day'))357 self.assertTrue(hasattr(dt, 'day'))
302 self.assertTrue(hasattr(dt, 'hour'))358 self.assertTrue(hasattr(dt, 'hour'))
303 self.assertTrue(hasattr(dt, 'minute'))359 self.assertTrue(hasattr(dt, 'minute'))
304 self.assertTrue(hasattr(dt, 'second'))360 self.assertTrue(hasattr(dt, 'second'))
361 self.assertTrue(hasattr(dt, 'tzinfo'))
305362
306 def test_datetime_properties_have_correct_values(self):363 def test_datetime_properties_have_correct_values(self):
307 dt = DateTime(1377209927)364 with patch('autopilot.introspection.types.tzlocal',
308 dt_with_tz = datetime.fromtimestamp(1377209927)365 new=self.local_timezone):
366 dt1 = DateTime(self.timestamp)
367 dt2 = self.local_from_timestamp(self.timestamp)
309368
310 self.assertThat(dt.timestamp, Equals(dt_with_tz.timestamp()))369 self.assertThat(dt1.year, Equals(dt2.year))
311 self.assertThat(dt.year, Equals(dt_with_tz.year))370 self.assertThat(dt1.month, Equals(dt2.month))
312 self.assertThat(dt.month, Equals(dt_with_tz.month))371 self.assertThat(dt1.day, Equals(dt2.day))
313 self.assertThat(dt.day, Equals(dt_with_tz.day))372 self.assertThat(dt1.hour, Equals(dt2.hour))
314 self.assertThat(dt.hour, Equals(dt_with_tz.hour))373 self.assertThat(dt1.minute, Equals(dt2.minute))
315 self.assertThat(dt.minute, Equals(dt_with_tz.minute))374 self.assertThat(dt1.second, Equals(dt2.second))
316 self.assertThat(dt.second, Equals(dt_with_tz.second))375 self.assertThat(dt1.tzinfo, Equals(dt2.tzinfo))
376 self.assertThat(dt1.timestamp(), Equals(dt2.timestamp()))
377 self.assertThat(dt1.timestamp(), Equals(self.timestamp))
317378
318 def test_equality_with_datetime(self):379 def test_equality_with_datetime(self):
319 dt1 = DateTime(1377209927)380 with patch('autopilot.introspection.types.tzlocal',
320 dt2 = DateTime(1377209927)381 new=self.local_timezone):
382 dt1 = DateTime(self.timestamp)
383 dt2 = datetime(dt1.year, dt1.month, dt1.day,
384 dt1.hour, dt1.minute, dt1.second,
385 tzinfo=dt1.tzinfo)
321386
322 self.assertThat(dt1, Equals(dt2))387 self.assertThat(dt1, Equals(dt2))
323388
324 def test_equality_with_list(self):389 def test_equality_with_list(self):
325 dt1 = DateTime(1377209927)390 with patch('autopilot.introspection.types.tzlocal',
326 dt2 = [1377209927]391 new=self.local_timezone):
392 dt1 = DateTime(self.timestamp)
393 dt2 = [self.timestamp]
327394
328 self.assertThat(dt1, Equals(dt2))395 self.assertThat(dt1, Equals(dt2))
329396
330 def test_equality_with_datetime_timestamp(self):397 def test_equality_with_datetime_timestamp(self):
331 # DateTime no longer assumes UTC and uses local TZ.398 with patch('autopilot.introspection.types.tzlocal',
332 dt1 = DateTime(1377209927)399 new=self.local_timezone):
333 dt2 = datetime.fromtimestamp(1377209927)400 dt1 = DateTime(self.timestamp)
334 dt3 = datetime.fromtimestamp(1377209928)401 dt2 = self.local_from_timestamp(self.timestamp)
402 dt3 = self.local_from_timestamp(self.timestamp + 1)
335403
336 self.assertThat(dt1, Equals(dt2))404 self.assertThat(dt1, Equals(dt2))
337 self.assertThat(dt1, NotEquals(dt3))405 self.assertThat(dt1, NotEquals(dt3))
338406
339 def test_can_convert_to_datetime(self):407 def test_can_convert_to_datetime(self):
340 dt1 = DateTime(1377209927)408 with patch('autopilot.introspection.types.tzlocal',
409 new=self.local_timezone):
410 dt1 = DateTime(self.timestamp)
341411
342 self.assertThat(dt1.datetime, IsInstance(datetime))412 self.assertThat(dt1.datetime, IsInstance(datetime))
343413
344 def test_repr(self):414 def test_repr(self):
345 expected = repr_type(415 with patch('autopilot.introspection.types.tzlocal',
346 u"DateTime({:%Y-%m-%d %H:%M:%S})".format(416 new=self.local_timezone):
347 datetime.fromtimestamp(1377209927)417 dt = DateTime(self.timestamp)
418 observed = repr(dt)
419 expected = repr_type(
420 u"DateTime({:%Y-%m-%d %H:%M:%S})".format(
421 self.local_from_timestamp(
422 self.timestamp).replace(tzinfo=self.local_timezone())
423 )
348 )424 )
349 )425 self.assertEqual(expected, observed)
350 dt = DateTime(1377209927)
351 observed = repr(dt)
352 self.assertEqual(expected, observed)
353426
354 def test_repr_equals_str(self):427 def test_repr_equals_str(self):
355 dt = DateTime(1377209927)428 with patch('autopilot.introspection.types.tzlocal',
356 self.assertEqual(repr(dt), str(dt))429 new=self.local_timezone):
430 dt = DateTime(self.timestamp)
431 self.assertEqual(repr(dt), str(dt))
357432
358433
359class TimeTests(TestCase):434class TimeTests(TestCase):
360435
=== modified file 'debian/control'
--- debian/control 2014-08-05 21:58:41 +0000
+++ debian/control 2014-09-08 23:54:02 +0000
@@ -15,6 +15,7 @@
15 libjs-underscore,15 libjs-underscore,
16 liblttng-ust-dev,16 liblttng-ust-dev,
17 python3-all-dev (>= 3.4),17 python3-all-dev (>= 3.4),
18 python3-dateutil,
18 python3-dbus,19 python3-dbus,
19 python3-decorator,20 python3-decorator,
20 python3-evdev,21 python3-evdev,
@@ -22,13 +23,14 @@
22 python3-flake8,23 python3-flake8,
23 python3-gi,24 python3-gi,
24 python3-junitxml,25 python3-junitxml,
26 python3-pil,
25 python3-psutil,27 python3-psutil,
26 python3-pil,
27 python3-setuptools,28 python3-setuptools,
28 python3-sphinx,29 python3-sphinx,
29 python3-subunit,30 python3-subunit,
30 python3-testscenarios,31 python3-testscenarios,
31 python3-testtools,32 python3-testtools,
33 python3-tz,
32 python3-xlib,34 python3-xlib,
33 sphinx-common,35 sphinx-common,
34 texlive-latex-extra,36 texlive-latex-extra,
@@ -40,33 +42,34 @@
4042
41Package: python3-autopilot43Package: python3-autopilot
42Architecture: all44Architecture: all
43Depends: ${misc:Depends},45Depends: gir1.2-ubuntu-app-launch-2 | gir1.2-upstart-app-launch-2,
44 ${python3:Depends},46 libjs-jquery,
45 gir1.2-ubuntu-app-launch-2 | gir1.2-upstart-app-launch-2,47 libjs-underscore,
46 libjs-underscore, libjs-jquery,
47 python3-dbus,48 python3-dbus,
48 python3-decorator,49 python3-decorator,
49 python3-fixtures,50 python3-fixtures,
50 python3-gi,51 python3-gi,
51 python3-junitxml,52 python3-junitxml,
53 python3-pil,
52 python3-psutil,54 python3-psutil,
53 python3-pil,
54 python3-subunit,55 python3-subunit,
55 python3-testscenarios,56 python3-testscenarios,
56 python3-testtools,57 python3-testtools,
57 udev,58 udev,
58Recommends: python3-xlib,59 ${misc:Depends},
59 python3-evdev,60 ${python3:Depends},
60 gir1.2-gconf-2.0,61Recommends: gir1.2-gconf-2.0,
61 gir1.2-glib-2.0,62 gir1.2-glib-2.0,
62 gir1.2-gtk-3.0,63 gir1.2-gtk-3.0,
63 gir1.2-ibus-1.0,64 gir1.2-ibus-1.0,
64 libautopilot-gtk (>= 1.4),65 libautopilot-gtk (>= 1.4),
65 libautopilot-qt (>= 1.4),66 libautopilot-qt (>= 1.4),
66 python3-autopilot-trace,67 python3-autopilot-trace,
68 python3-evdev,
69 python3-xlib,
67 recordmydesktop,70 recordmydesktop,
68Breaks: libautopilot-gtk (<< 1.4),71Breaks: libautopilot-gtk (<< 1.4),
69 libautopilot-qt (<< 1.4),72 libautopilot-qt (<< 1.4),
70Description: Utility to write and run integration tests easily (Python 3)73Description: Utility to write and run integration tests easily (Python 3)
71 The autopilot engine enables to ease the writing of python tests74 The autopilot engine enables to ease the writing of python tests
72 for your application manipulating your inputs like the mouse and75 for your application manipulating your inputs like the mouse and
@@ -75,9 +78,9 @@
7578
76Package: python3-autopilot-trace79Package: python3-autopilot-trace
77Architecture: any80Architecture: any
78Depends: ${misc:Depends},81Depends: python3-autopilot,
82 ${misc:Depends},
79 ${shlibs:Depends},83 ${shlibs:Depends},
80 python3-autopilot,
81Description: Support for tracing in autopilot (Python 3)84Description: Support for tracing in autopilot (Python 3)
82 This package contains the binary lttng trace point for tracing85 This package contains the binary lttng trace point for tracing
83 autopilot tests. This is useful when using autopilot to exercise86 autopilot tests. This is useful when using autopilot to exercise
@@ -86,12 +89,12 @@
86Package: autopilot-touch89Package: autopilot-touch
87Architecture: all90Architecture: all
88Section: metapackages91Section: metapackages
89Depends: ${misc:Depends},92Depends: autopilot-qt5,
90 autopilot-qt5,93 fbset,
94 python3-autopilot,
95 python3-evdev,
91 qttestability-autopilot,96 qttestability-autopilot,
92 python3-autopilot,97 ${misc:Depends},
93 python3-evdev,
94 fbset,
95Description: Autopilot support for the ubuntu Touch platform98Description: Autopilot support for the ubuntu Touch platform
96 This metapackage exists to depend on the packages needed to install and use99 This metapackage exists to depend on the packages needed to install and use
97 autopilot on the Ubuntu Touch platform.100 autopilot on the Ubuntu Touch platform.
@@ -99,14 +102,14 @@
99Package: autopilot-desktop102Package: autopilot-desktop
100Architecture: all103Architecture: all
101Section: metapackages104Section: metapackages
102Depends: ${misc:Depends},105Depends: at-spi2-core,
103 at-spi2-core,106 bamfdaemon,
104 gir1.2-gconf-2.0,107 gir1.2-gconf-2.0,
105 gir1.2-glib-2.0,108 gir1.2-glib-2.0,
106 gir1.2-gtk-3.0,109 gir1.2-gtk-3.0,
107 python3-autopilot,110 python3-autopilot,
108 python3-xlib,111 python3-xlib,
109 bamfdaemon,112 ${misc:Depends},
110Recommends: python3-autopilot-vis,113Recommends: python3-autopilot-vis,
111 python3-evdev,114 python3-evdev,
112Description: Autopilot support for the ubuntu Desktop platform115Description: Autopilot support for the ubuntu Desktop platform
@@ -115,13 +118,13 @@
115118
116Package: python3-autopilot-vis119Package: python3-autopilot-vis
117Architecture: all120Architecture: all
118Depends: ${misc:Depends},121Depends: gnome-icon-theme,
119 ${python3:Depends},
120 gnome-icon-theme,
121 python3-autopilot,122 python3-autopilot,
122 python3-dbus,123 python3-dbus,
123 python3-dbus.mainloop.qt,124 python3-dbus.mainloop.qt,
124 python3-pyqt4,125 python3-pyqt4,
126 ${misc:Depends},
127 ${python3:Depends},
125Recommends: python3-lxml,128Recommends: python3-lxml,
126Description: visualisation application for Autopilot (Python 3)129Description: visualisation application for Autopilot (Python 3)
127 The Autopilot vis tool allows you to inspect an application introspection130 The Autopilot vis tool allows you to inspect an application introspection
@@ -130,17 +133,19 @@
130133
131Package: python3-autopilot-tests134Package: python3-autopilot-tests
132Architecture: all135Architecture: all
133Depends: ${misc:Depends},136Depends: libautopilot-gtk (>= 1.4),
134 ${python3:Depends},
135 libautopilot-gtk (>= 1.4),
136 libautopilot-qt (>= 1.4),137 libautopilot-qt (>= 1.4),
137 python3-autopilot,
138 python3-dbus.mainloop.qt,
139 python3-evdev,
140 python3-pyqt4,
141 python-windowmocker,138 python-windowmocker,
139 python3-autopilot,
140 python3-dateutil,
141 python3-dbus.mainloop.qt,
142 python3-evdev,
143 python3-pyqt4,
144 python3-tz,
142 qmlscene,145 qmlscene,
143 recordmydesktop,146 recordmydesktop,
147 ${misc:Depends},
148 ${python3:Depends},
144Description: Tests for the autopilot functional test tool. (Python 3)149Description: Tests for the autopilot functional test tool. (Python 3)
145 This package contains tests for the python3-autopilot package.150 This package contains tests for the python3-autopilot package.
146 You can use this package to verify that autopilot is functioning151 You can use this package to verify that autopilot is functioning
147152
=== modified file 'debian/copyright'
--- debian/copyright 2013-08-28 07:24:58 +0000
+++ debian/copyright 2014-09-08 23:54:02 +0000
@@ -21,4 +21,3 @@
21 .21 .
22 On Debian systems, the complete text of the GNU General22 On Debian systems, the complete text of the GNU General
23 Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".23 Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
24
2524
=== modified file 'debian/python3-autopilot-tests.install'
--- debian/python3-autopilot-tests.install 2014-04-02 01:30:40 +0000
+++ debian/python3-autopilot-tests.install 2014-09-08 23:54:02 +0000
@@ -1,4 +1,4 @@
1usr/lib/python3*/*/autopilot/tests/*.py1usr/lib/python3*/*/autopilot/tests/*.py
2usr/lib/python3*/*/autopilot/tests/acceptance/*.py
3usr/lib/python3*/*/autopilot/tests/functional/*.py
2usr/lib/python3*/*/autopilot/tests/unit/*.py4usr/lib/python3*/*/autopilot/tests/unit/*.py
3usr/lib/python3*/*/autopilot/tests/functional/*.py
4usr/lib/python3*/*/autopilot/tests/acceptance/*.py
55
=== modified file 'debian/python3-autopilot-vis.install'
--- debian/python3-autopilot-vis.install 2014-05-05 20:37:46 +0000
+++ debian/python3-autopilot-vis.install 2014-09-08 23:54:02 +0000
@@ -1,4 +1,4 @@
1usr/lib/python3*/*/autopilot/vis/*.py
2debian/autopilot3-vis.desktop /usr/share/applications1debian/autopilot3-vis.desktop /usr/share/applications
3icons/autopilot-toggle-overlay.svg /usr/share/icons/hicolor/scalable/actions/2icons/autopilot-toggle-overlay.svg /usr/share/icons/hicolor/scalable/actions/
4icons/autopilot.svg /usr/share/icons/hicolor/scalable/apps/3icons/autopilot.svg /usr/share/icons/hicolor/scalable/apps/
4usr/lib/python3*/*/autopilot/vis/*.py
55
=== modified file 'debian/python3-autopilot.install'
--- debian/python3-autopilot.install 2014-05-15 05:59:44 +0000
+++ debian/python3-autopilot.install 2014-09-08 23:54:02 +0000
@@ -1,3 +1,4 @@
1
1debian/61-autopilot3-uinput.rules /lib/udev/rules.d2debian/61-autopilot3-uinput.rules /lib/udev/rules.d
2usr/bin/autopilot3 /usr/bin/3usr/bin/autopilot3 /usr/bin/
3usr/bin/autopilot3-sandbox-run /usr/bin/4usr/bin/autopilot3-sandbox-run /usr/bin/
@@ -9,4 +10,3 @@
9usr/lib/python3*/*/autopilot/introspection/*.py10usr/lib/python3*/*/autopilot/introspection/*.py
10usr/lib/python3*/*/autopilot/matchers/*.py11usr/lib/python3*/*/autopilot/matchers/*.py
11usr/lib/python3*/*/autopilot/process/*.py12usr/lib/python3*/*/autopilot/process/*.py
12

Subscribers

People subscribed via source and target branches