Merge lp:~bac/charmworld/utc-smackdown into lp:~juju-jitsu/charmworld/trunk

Proposed by Brad Crittenden
Status: Merged
Approved by: Brad Crittenden
Approved revision: 421
Merged at revision: 420
Proposed branch: lp:~bac/charmworld/utc-smackdown
Merge into: lp:~juju-jitsu/charmworld/trunk
Diff against target: 114 lines (+10/-9)
8 files modified
.lbox (+1/-0)
Makefile (+1/-1)
charmworld/jobs/tests/test_askubuntu.py (+2/-2)
charmworld/jobs/tests/test_review.py (+1/-1)
charmworld/migrations/migrate.py (+2/-2)
charmworld/reports.py (+1/-1)
charmworld/tests/test_utils.py (+1/-1)
charmworld/utils.py (+1/-1)
To merge this branch: bzr merge lp:~bac/charmworld/utc-smackdown
Reviewer Review Type Date Requested Status
Juju Gui Bot continuous-integration Approve
Juju-Jitsu Hackers Pending
Review via email: mp+191291@code.launchpad.net

Commit message

Make cw code tests tz agnostic.

In the past there have been some incredibly hard to debug test failures
caused by using .now() vs .utcnow(). During a routine inspection I saw
various instances of .now() being used and have replaced them.

Added a .lbox to use -cr on propose by default and set the project
to lp:charmworld.

Fixed the testdebug target to stop on failures in addition to errors.

https://codereview.appspot.com/14486046/

R=rharding

Description of the change

Make cw code tests tz agnostic.

In the past there have been some incredibly hard to debug test failures
caused by using .now() vs .utcnow(). During a routine inspection I saw
various instances of .now() being used and have replaced them.

Added a .lbox to use -cr on propose by default and set the project
to lp:charmworld.

Fixed the testdebug target to stop on failures in addition to errors.

https://codereview.appspot.com/14486046/

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :
Download full text (5.2 KiB)

Reviewers: mp+191291_code.launchpad.net,

Message:
Please take a look.

Description:
Make cw code tests tz agnostic.

In the past there have been some incredibly hard to debug test failures
caused by using .now() vs .utcnow(). During a routine inspection I saw
various instances of .now() being used and have replaced them.

Added a .lbox to use -cr on propose by default and set the project
to lp:charmworld.

Fixed the testdebug target to stop on failures in addition to errors.

https://code.launchpad.net/~bac/charmworld/utc-smackdown/+merge/191291

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/14486046/

Affected files (+12, -9 lines):
   .lbox
   Makefile
   [revision details]
   charmworld/jobs/tests/test_askubuntu.py
   charmworld/jobs/tests/test_review.py
   charmworld/migrations/migrate.py
   charmworld/reports.py
   charmworld/tests/test_utils.py
   charmworld/utils.py

Index: .lbox
=== added file '.lbox'
--- .lbox 1970-01-01 00:00:00 +0000
+++ .lbox 2013-10-15 20:26:51 +0000
@@ -0,0 +1,1 @@
+propose -cr -for lp:charmworld

Index: Makefile
=== modified file 'Makefile'
--- Makefile 2013-10-15 17:55:59 +0000
+++ Makefile 2013-10-15 20:04:46 +0000
@@ -122,7 +122,7 @@
   bin/test -v -s -x --with-id $(ID) charmworld

  testdebug: bin/test
- bin/test --pdb charmworld
+ bin/test --pdb --pdb-failures charmworld

  check: clear_ini clean sysdeps install lint testid

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-20131015180445-lmxsdrtp2xjl0ec3
+New revision: <email address hidden>

Index: charmworld/reports.py
=== modified file 'charmworld/reports.py'
--- charmworld/reports.py 2013-08-08 12:05:02 +0000
+++ charmworld/reports.py 2013-10-15 20:04:46 +0000
@@ -34,7 +34,7 @@
      def __init__(self, start_date, step, end_date=None):
          self._start_date = start_date
          if end_date is None:
- end_date = datetime.datetime.now()
+ end_date = datetime.datetime.utcnow()
          self._end_date = end_date
          self._step = step
          self._series = {}

Index: charmworld/migrations/migrate.py
=== modified file 'charmworld/migrations/migrate.py'
--- charmworld/migrations/migrate.py 2013-08-28 20:19:02 +0000
+++ charmworld/migrations/migrate.py 2013-10-15 20:04:46 +0000
@@ -98,7 +98,7 @@
          self.db.migration_version.save({
              '_id': 'version',
              'version': version,
- 'date': datetime.now(),
+ 'date': datetime.utcnow(),
          })

      def version_datastore(self):
@@ -114,7 +114,7 @@
          self.db.migration_version.insert({
              '_id': 'version',
              'version': 0,
- 'date': datetime.now(),
+ 'date': datetime.utcnow(),
          })

Index: charmworld/jobs/tests/test_askubuntu.py
=== modified file 'charmworld/jobs/tests/test_askubuntu.py'
--- charmworld/jobs/tests/test_askubuntu.py 2013-09-27 16:13:21 +0000
+++ charmworld/jobs/tests/test_askubuntu.py 2013-10-15 20:04:46 +0000
@@ ...

Read more...

Revision history for this message
Brad Crittenden (bac) wrote :
Revision history for this message
Richard Harding (rharding) wrote :

LGTM reviewed on LP due to the chunk mismatch.

https://codereview.appspot.com/14486046/

Revision history for this message
Juju Gui Bot (juju-gui-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.lbox'
2--- .lbox 1970-01-01 00:00:00 +0000
3+++ .lbox 2013-10-15 20:34:17 +0000
4@@ -0,0 +1,1 @@
5+propose -cr -for lp:charmworld
6
7=== modified file 'Makefile'
8--- Makefile 2013-10-15 17:55:59 +0000
9+++ Makefile 2013-10-15 20:34:17 +0000
10@@ -122,7 +122,7 @@
11 bin/test -v -s -x --with-id $(ID) charmworld
12
13 testdebug: bin/test
14- bin/test --pdb charmworld
15+ bin/test --pdb --pdb-failures charmworld
16
17 check: clear_ini clean sysdeps install lint testid
18
19
20=== modified file 'charmworld/jobs/tests/test_askubuntu.py'
21--- charmworld/jobs/tests/test_askubuntu.py 2013-09-27 16:13:21 +0000
22+++ charmworld/jobs/tests/test_askubuntu.py 2013-10-15 20:34:17 +0000
23@@ -48,7 +48,7 @@
24 self.assertEqual([], entries)
25
26 def test_create_entries_from_questions(self):
27- now = datetime.datetime.now()
28+ now = datetime.datetime.utcnow()
29 then = now - datetime.timedelta(1)
30 questions = [{
31 "question_id":345535,
32@@ -67,7 +67,7 @@
33 "reputation":13,
34 "user_type":"registered",
35 "profile_image":"https://example.com/foo.jpg",
36- "link":"http://askubuntu.com/users/130026/jjmerelo"
37+ "link":"http://askubuntu.com/users/130026/jjmerelo",
38 },
39 "link":"http://example.com/questions/1/",
40 "is_answered": False
41
42=== modified file 'charmworld/jobs/tests/test_review.py'
43--- charmworld/jobs/tests/test_review.py 2013-09-30 16:00:47 +0000
44+++ charmworld/jobs/tests/test_review.py 2013-10-15 20:34:17 +0000
45@@ -7,7 +7,7 @@
46 from charmworld.testing import MongoTestBase
47
48
49-NOW = datetime.datetime.now()
50+NOW = datetime.datetime.utcnow()
51 YESTERDAY = NOW - datetime.timedelta(1)
52 TWO_DAYS = NOW - datetime.timedelta(2)
53
54
55=== modified file 'charmworld/migrations/migrate.py'
56--- charmworld/migrations/migrate.py 2013-08-28 20:19:02 +0000
57+++ charmworld/migrations/migrate.py 2013-10-15 20:34:17 +0000
58@@ -98,7 +98,7 @@
59 self.db.migration_version.save({
60 '_id': 'version',
61 'version': version,
62- 'date': datetime.now(),
63+ 'date': datetime.utcnow(),
64 })
65
66 def version_datastore(self):
67@@ -114,7 +114,7 @@
68 self.db.migration_version.insert({
69 '_id': 'version',
70 'version': 0,
71- 'date': datetime.now(),
72+ 'date': datetime.utcnow(),
73 })
74
75
76
77=== modified file 'charmworld/reports.py'
78--- charmworld/reports.py 2013-08-08 12:05:02 +0000
79+++ charmworld/reports.py 2013-10-15 20:34:17 +0000
80@@ -34,7 +34,7 @@
81 def __init__(self, start_date, step, end_date=None):
82 self._start_date = start_date
83 if end_date is None:
84- end_date = datetime.datetime.now()
85+ end_date = datetime.datetime.utcnow()
86 self._end_date = end_date
87 self._step = step
88 self._series = {}
89
90=== modified file 'charmworld/tests/test_utils.py'
91--- charmworld/tests/test_utils.py 2013-09-10 13:54:39 +0000
92+++ charmworld/tests/test_utils.py 2013-10-15 20:34:17 +0000
93@@ -53,7 +53,7 @@
94
95 def test_days_apart(self):
96 """A single delta will get us the correct days apart."""
97- delta = datetime.now() - timedelta(10)
98+ delta = datetime.utcnow() - timedelta(10)
99 pretty = pretty_timedelta(delta)
100 self.assertEqual('10 days', pretty)
101
102
103=== modified file 'charmworld/utils.py'
104--- charmworld/utils.py 2013-09-10 13:54:39 +0000
105+++ charmworld/utils.py 2013-10-15 20:34:17 +0000
106@@ -50,7 +50,7 @@
107 if isinstance(time1, (str, unicode)):
108 time1 = parse(time1)
109 if time2 is None:
110- time2 = datetime.datetime.now()
111+ time2 = datetime.datetime.utcnow()
112
113 if time1 > time2:
114 raise ValueError('The start date is before the end date.')

Subscribers

People subscribed via source and target branches