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
1=== modified file 'juju/providers/ec2/tests/test_utils.py'
2--- juju/providers/ec2/tests/test_utils.py 2012-04-11 00:09:41 +0000
3+++ juju/providers/ec2/tests/test_utils.py 2012-04-11 13:16:25 +0000
4@@ -116,9 +116,11 @@
5 """
6
7 def match_context(value):
8- if isinstance(value, VerifyingContextFactory):
9- return True
10- return False
11+ if VerifyingContextFactory is None:
12+ # We're running against an older twisted version without
13+ # certificate verification.
14+ return value is None
15+ return isinstance(value, VerifyingContextFactory)
16
17 page = self.mocker.replace("twisted.web.client.getPage")
18 page(IMAGE_URI_TEMPLATE % "lucid",
19
20=== modified file 'juju/providers/ec2/utils.py'
21--- juju/providers/ec2/utils.py 2012-04-11 00:09:41 +0000
22+++ juju/providers/ec2/utils.py 2012-04-11 13:16:25 +0000
23@@ -97,11 +97,12 @@
24 return tokens[7]
25 raise LookupError((series, arch, region))
26
27+ uri = _CURRENT_IMAGE_URI_TEMPLATE % (_CURRENT_IMAGE_HOST, series)
28 if ssl and ssl_verify:
29 contextFactory=VerifyingContextFactory(_CURRENT_IMAGE_HOST)
30 else:
31 contextFactory=None
32- d = getPage(_CURRENT_IMAGE_URI_TEMPLATE % (_CURRENT_IMAGE_HOST, series), contextFactory=contextFactory)
33+ d = getPage(uri, contextFactory=contextFactory)
34 d.addErrback(handle_404)
35 d.addCallback(extract_ami)
36 return d

Subscribers

People subscribed via source and target branches

to status/vote changes: