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
=== added file '.lbox'
--- .lbox 1970-01-01 00:00:00 +0000
+++ .lbox 2013-10-15 20:34:17 +0000
@@ -0,0 +1,1 @@
1propose -cr -for lp:charmworld
02
=== modified file 'Makefile'
--- Makefile 2013-10-15 17:55:59 +0000
+++ Makefile 2013-10-15 20:34:17 +0000
@@ -122,7 +122,7 @@
122 bin/test -v -s -x --with-id $(ID) charmworld122 bin/test -v -s -x --with-id $(ID) charmworld
123123
124testdebug: bin/test124testdebug: bin/test
125 bin/test --pdb charmworld125 bin/test --pdb --pdb-failures charmworld
126126
127check: clear_ini clean sysdeps install lint testid127check: clear_ini clean sysdeps install lint testid
128128
129129
=== 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:34:17 +0000
@@ -48,7 +48,7 @@
48 self.assertEqual([], entries)48 self.assertEqual([], entries)
4949
50 def test_create_entries_from_questions(self):50 def test_create_entries_from_questions(self):
51 now = datetime.datetime.now()51 now = datetime.datetime.utcnow()
52 then = now - datetime.timedelta(1)52 then = now - datetime.timedelta(1)
53 questions = [{53 questions = [{
54 "question_id":345535,54 "question_id":345535,
@@ -67,7 +67,7 @@
67 "reputation":13,67 "reputation":13,
68 "user_type":"registered",68 "user_type":"registered",
69 "profile_image":"https://example.com/foo.jpg",69 "profile_image":"https://example.com/foo.jpg",
70 "link":"http://askubuntu.com/users/130026/jjmerelo"70 "link":"http://askubuntu.com/users/130026/jjmerelo",
71 },71 },
72 "link":"http://example.com/questions/1/",72 "link":"http://example.com/questions/1/",
73 "is_answered": False73 "is_answered": False
7474
=== modified file 'charmworld/jobs/tests/test_review.py'
--- charmworld/jobs/tests/test_review.py 2013-09-30 16:00:47 +0000
+++ charmworld/jobs/tests/test_review.py 2013-10-15 20:34:17 +0000
@@ -7,7 +7,7 @@
7from charmworld.testing import MongoTestBase7from charmworld.testing import MongoTestBase
88
99
10NOW = datetime.datetime.now()10NOW = datetime.datetime.utcnow()
11YESTERDAY = NOW - datetime.timedelta(1)11YESTERDAY = NOW - datetime.timedelta(1)
12TWO_DAYS = NOW - datetime.timedelta(2)12TWO_DAYS = NOW - datetime.timedelta(2)
1313
1414
=== 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:34:17 +0000
@@ -98,7 +98,7 @@
98 self.db.migration_version.save({98 self.db.migration_version.save({
99 '_id': 'version',99 '_id': 'version',
100 'version': version,100 'version': version,
101 'date': datetime.now(),101 'date': datetime.utcnow(),
102 })102 })
103103
104 def version_datastore(self):104 def version_datastore(self):
@@ -114,7 +114,7 @@
114 self.db.migration_version.insert({114 self.db.migration_version.insert({
115 '_id': 'version',115 '_id': 'version',
116 'version': 0,116 'version': 0,
117 'date': datetime.now(),117 'date': datetime.utcnow(),
118 })118 })
119119
120120
121121
=== modified file 'charmworld/reports.py'
--- charmworld/reports.py 2013-08-08 12:05:02 +0000
+++ charmworld/reports.py 2013-10-15 20:34:17 +0000
@@ -34,7 +34,7 @@
34 def __init__(self, start_date, step, end_date=None):34 def __init__(self, start_date, step, end_date=None):
35 self._start_date = start_date35 self._start_date = start_date
36 if end_date is None:36 if end_date is None:
37 end_date = datetime.datetime.now()37 end_date = datetime.datetime.utcnow()
38 self._end_date = end_date38 self._end_date = end_date
39 self._step = step39 self._step = step
40 self._series = {}40 self._series = {}
4141
=== modified file 'charmworld/tests/test_utils.py'
--- charmworld/tests/test_utils.py 2013-09-10 13:54:39 +0000
+++ charmworld/tests/test_utils.py 2013-10-15 20:34:17 +0000
@@ -53,7 +53,7 @@
5353
54 def test_days_apart(self):54 def test_days_apart(self):
55 """A single delta will get us the correct days apart."""55 """A single delta will get us the correct days apart."""
56 delta = datetime.now() - timedelta(10)56 delta = datetime.utcnow() - timedelta(10)
57 pretty = pretty_timedelta(delta)57 pretty = pretty_timedelta(delta)
58 self.assertEqual('10 days', pretty)58 self.assertEqual('10 days', pretty)
5959
6060
=== modified file 'charmworld/utils.py'
--- charmworld/utils.py 2013-09-10 13:54:39 +0000
+++ charmworld/utils.py 2013-10-15 20:34:17 +0000
@@ -50,7 +50,7 @@
50 if isinstance(time1, (str, unicode)):50 if isinstance(time1, (str, unicode)):
51 time1 = parse(time1)51 time1 = parse(time1)
52 if time2 is None:52 if time2 is None:
53 time2 = datetime.datetime.now()53 time2 = datetime.datetime.utcnow()
5454
55 if time1 > time2:55 if time1 > time2:
56 raise ValueError('The start date is before the end date.')56 raise ValueError('The start date is before the end date.')

Subscribers

People subscribed via source and target branches