Merge lp:~fwereade/pyjuju/old-twisted-test-fix into lp:pyjuju

Proposed by William Reade
Status: Merged
Approved by: William Reade
Approved revision: 522
Merged at revision: 522
Proposed branch: lp:~fwereade/pyjuju/old-twisted-test-fix
Merge into: lp:pyjuju
Diff against target: 36 lines (+7/-4)
2 files modified
juju/providers/ec2/tests/test_utils.py (+5/-3)
juju/providers/ec2/utils.py (+2/-1)
To merge this branch: bzr merge lp:~fwereade/pyjuju/old-twisted-test-fix
Reviewer Review Type Date Requested Status
Kapil Thangavelu (community) Approve
Review via email: mp+101508@code.launchpad.net

Description of the change

Tests were not expecting to run against pre-VerifyingContextFactory twisted

https://codereview.appspot.com/5970089/

To post a comment you must log in.
Revision history for this message
William Reade (fwereade) wrote :

Reviewers: mp+101508_code.launchpad.net,

Message:
Please take a look.

Description:
Tests were not expecting to run against pre-VerifyingContextFactory
twisted

https://code.launchpad.net/~fwereade/juju/old-twisted-test-fix/+merge/101508

(do not edit description out of merge proposal)

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

Affected files:
   A [revision details]
   M juju/providers/ec2/tests/test_utils.py
   M juju/providers/ec2/utils.py

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: <email address hidden>
+New revision: <email address hidden>

Index: juju/providers/ec2/utils.py
=== modified file 'juju/providers/ec2/utils.py'
--- juju/providers/ec2/utils.py 2012-04-11 00:09:41 +0000
+++ juju/providers/ec2/utils.py 2012-04-11 08:36:43 +0000
@@ -97,11 +97,12 @@
                  return tokens[7]
          raise LookupError((series, arch, region))

+ uri = _CURRENT_IMAGE_URI_TEMPLATE % (_CURRENT_IMAGE_HOST, series)
      if ssl and ssl_verify:
          contextFactory=VerifyingContextFactory(_CURRENT_IMAGE_HOST)
      else:
          contextFactory=None
- d = getPage(_CURRENT_IMAGE_URI_TEMPLATE % (_CURRENT_IMAGE_HOST,
series), contextFactory=contextFactory)
+ d = getPage(uri, contextFactory=contextFactory)
      d.addErrback(handle_404)
      d.addCallback(extract_ami)
      return d

Index: juju/providers/ec2/tests/test_utils.py
=== modified file 'juju/providers/ec2/tests/test_utils.py'
--- juju/providers/ec2/tests/test_utils.py 2012-04-11 00:09:41 +0000
+++ juju/providers/ec2/tests/test_utils.py 2012-04-11 08:19:44 +0000
@@ -116,9 +116,11 @@
          """

          def match_context(value):
- if isinstance(value, VerifyingContextFactory):
- return True
- return False
+ if VerifyingContextFactory is None:
+ # We're running against an older twisted version without
+ # certificate verification.
+ return value is None
+ return isinstance(value, VerifyingContextFactory)

          page = self.mocker.replace("twisted.web.client.getPage")
          page(IMAGE_URI_TEMPLATE % "lucid",

Revision history for this message
Kapil Thangavelu (hazmat) wrote :

trivial, lgtm

review: Approve
523. By William Reade

merge parent

Revision history for this message
William Reade (fwereade) wrote :

*** Submitted:

Tests were not expecting to run against pre-VerifyingContextFactory
twisted

R=
CC=
https://codereview.appspot.com/5970089

https://codereview.appspot.com/5970089/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'juju/providers/ec2/tests/test_utils.py'
--- juju/providers/ec2/tests/test_utils.py 2012-04-11 00:09:41 +0000
+++ juju/providers/ec2/tests/test_utils.py 2012-04-11 13:16:25 +0000
@@ -116,9 +116,11 @@
116 """116 """
117117
118 def match_context(value):118 def match_context(value):
119 if isinstance(value, VerifyingContextFactory):119 if VerifyingContextFactory is None:
120 return True120 # We're running against an older twisted version without
121 return False121 # certificate verification.
122 return value is None
123 return isinstance(value, VerifyingContextFactory)
122124
123 page = self.mocker.replace("twisted.web.client.getPage")125 page = self.mocker.replace("twisted.web.client.getPage")
124 page(IMAGE_URI_TEMPLATE % "lucid",126 page(IMAGE_URI_TEMPLATE % "lucid",
125127
=== modified file 'juju/providers/ec2/utils.py'
--- juju/providers/ec2/utils.py 2012-04-11 00:09:41 +0000
+++ juju/providers/ec2/utils.py 2012-04-11 13:16:25 +0000
@@ -97,11 +97,12 @@
97 return tokens[7]97 return tokens[7]
98 raise LookupError((series, arch, region))98 raise LookupError((series, arch, region))
9999
100 uri = _CURRENT_IMAGE_URI_TEMPLATE % (_CURRENT_IMAGE_HOST, series)
100 if ssl and ssl_verify:101 if ssl and ssl_verify:
101 contextFactory=VerifyingContextFactory(_CURRENT_IMAGE_HOST)102 contextFactory=VerifyingContextFactory(_CURRENT_IMAGE_HOST)
102 else:103 else:
103 contextFactory=None104 contextFactory=None
104 d = getPage(_CURRENT_IMAGE_URI_TEMPLATE % (_CURRENT_IMAGE_HOST, series), contextFactory=contextFactory)105 d = getPage(uri, contextFactory=contextFactory)
105 d.addErrback(handle_404)106 d.addErrback(handle_404)
106 d.addCallback(extract_ami)107 d.addCallback(extract_ami)
107 return d108 return d

Subscribers

People subscribed via source and target branches

to status/vote changes: