Merge lp:~jkakar/txaws/discover-shows-url into lp:txaws

Proposed by Jamu Kakar
Status: Merged
Merged at revision: 68
Proposed branch: lp:~jkakar/txaws/discover-shows-url
Merge into: lp:txaws
Diff against target: 144 lines (+46/-30)
2 files modified
txaws/client/discover/command.py (+9/-0)
txaws/client/discover/tests/test_command.py (+37/-30)
To merge this branch: bzr merge lp:~jkakar/txaws/discover-shows-url
Reviewer Review Type Date Requested Status
Thomas Herve Needs Fixing
Review via email: mp+34528@code.launchpad.net

Description of the change

This branch introduces the following changes:

- txaws-discover now outputs the URL used to make the request, in
  addition to the HTTP status code and the response body.

To post a comment you must log in.
Revision history for this message
Thomas Herve (therve) wrote :

Please use query.client.url instead of duplicating the logic.

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'txaws/client/discover/command.py'
2--- txaws/client/discover/command.py 2010-06-21 15:59:10 +0000
3+++ txaws/client/discover/command.py 2010-09-03 12:20:56 +0000
4@@ -55,6 +55,10 @@
5 other_params=self.parameters)
6
7 def write_response(response):
8+ url = "%s?%s" % (region.ec2_endpoint.get_uri(),
9+ query.get_canonical_query_params())
10+ print >>self.output, "URL: %s" % url
11+ print >>self.output
12 print >>self.output, "HTTP status code: %s" % query.client.status
13 print >>self.output
14 print >>self.output, response
15@@ -66,6 +70,11 @@
16 message = failure.getErrorMessage()
17 if message.startswith("Error Message: "):
18 message = message[len("Error Message: "):]
19+
20+ url = "%s?%s" % (region.ec2_endpoint.get_uri(),
21+ query.get_canonical_query_params())
22+ print >>self.output, "URL: %s" % url
23+ print >>self.output
24 print >>self.output, "HTTP status code: %s" % query.client.status
25 print >>self.output
26 print >>self.output, message
27
28=== modified file 'txaws/client/discover/tests/test_command.py'
29--- txaws/client/discover/tests/test_command.py 2010-06-04 22:38:29 +0000
30+++ txaws/client/discover/tests/test_command.py 2010-09-03 12:20:56 +0000
31@@ -68,17 +68,19 @@
32 self.prepare_command("The response", 200, "DescribeRegions")
33
34 def check(result):
35- self.assertEqual("GET", self.method)
36- self.assertEqual(
37+ url = (
38 "http://endpoint?AWSAccessKeyId=key&"
39 "Action=DescribeRegions&"
40 "Signature=uAlV2ALkp7qTxZrTNNuJhHl0i9xiTK5faZOhJTgGS1E%3D&"
41 "SignatureMethod=HmacSHA256&SignatureVersion=2&"
42- "Timestamp=2010-06-04T23%3A40%3A00Z&Version=2008-12-01",
43- self.url)
44- self.assertEqual("HTTP status code: 200\n"
45- "\n"
46- "The response\n",
47+ "Timestamp=2010-06-04T23%3A40%3A00Z&Version=2008-12-01")
48+ self.assertEqual("GET", self.method)
49+ self.assertEqual(url, self.url)
50+ self.assertEqual("URL: %s\n"
51+ "\n"
52+ "HTTP status code: 200\n"
53+ "\n"
54+ "The response\n" % url,
55 self.output.getvalue())
56
57 deferred = self.command.run()
58@@ -91,17 +93,19 @@
59 {"RegionName.0": "us-west-1"})
60
61 def check(result):
62- self.assertEqual("GET", self.method)
63- self.assertEqual(
64+ url = (
65 "http://endpoint?AWSAccessKeyId=key&"
66 "Action=DescribeRegions&RegionName.0=us-west-1&"
67 "Signature=P6C7cQJ7j93uIJyv2dTbpQG3EI7ArGBJT%2FzVH%2BDFhyY%3D&"
68 "SignatureMethod=HmacSHA256&SignatureVersion=2&"
69- "Timestamp=2010-06-04T23%3A40%3A00Z&Version=2008-12-01",
70- self.url)
71- self.assertEqual("HTTP status code: 200\n"
72- "\n"
73- "The response\n",
74+ "Timestamp=2010-06-04T23%3A40%3A00Z&Version=2008-12-01")
75+ self.assertEqual("GET", self.method)
76+ self.assertEqual(url, self.url)
77+ self.assertEqual("URL: %s\n"
78+ "\n"
79+ "HTTP status code: 200\n"
80+ "\n"
81+ "The response\n" % url,
82 self.output.getvalue())
83
84 deferred = self.command.run()
85@@ -118,22 +122,23 @@
86 self.get_error_page)
87
88 def check(result):
89- self.assertEqual("GET", self.method)
90- self.assertEqual(
91+ url = (
92 "http://endpoint?AWSAccessKeyId=key&"
93 "Action=DescribeRegions&RegionName.0=us-west-1&"
94 "Signature=P6C7cQJ7j93uIJyv2dTbpQG3EI7ArGBJT%2FzVH%2BDFhyY%3D&"
95 "SignatureMethod=HmacSHA256&SignatureVersion=2&"
96- "Timestamp=2010-06-04T23%3A40%3A00Z&Version=2008-12-01",
97- self.url)
98- self.assertEqual("HTTP status code: 400\n"
99- "\n"
100- "The error response\n",
101+ "Timestamp=2010-06-04T23%3A40%3A00Z&Version=2008-12-01")
102+ self.assertEqual("GET", self.method)
103+ self.assertEqual(url, self.url)
104+ self.assertEqual("URL: %s\n"
105+ "\n"
106+ "HTTP status code: 400\n"
107+ "\n"
108+ "The error response\n" % url,
109 self.output.getvalue())
110
111 deferred = self.command.run()
112- deferred.addErrback(check)
113- return deferred
114+ return self.assertFailure(deferred, Exception).addErrback(check)
115
116 def test_run_with_error_strips_non_response_text(self):
117 """
118@@ -146,17 +151,19 @@
119 self.get_error_page)
120
121 def check(result):
122- self.assertEqual("GET", self.method)
123- self.assertEqual(
124+ url = (
125 "http://endpoint?AWSAccessKeyId=key&"
126 "Action=DescribeRegions&RegionName.0=us-west-1&"
127 "Signature=P6C7cQJ7j93uIJyv2dTbpQG3EI7ArGBJT%2FzVH%2BDFhyY%3D&"
128 "SignatureMethod=HmacSHA256&SignatureVersion=2&"
129- "Timestamp=2010-06-04T23%3A40%3A00Z&Version=2008-12-01",
130- self.url)
131- self.assertEqual("HTTP status code: 400\n"
132- "\n"
133- "The error response\n",
134+ "Timestamp=2010-06-04T23%3A40%3A00Z&Version=2008-12-01")
135+ self.assertEqual("GET", self.method)
136+ self.assertEqual(url, self.url)
137+ self.assertEqual("URL: %s\n"
138+ "\n"
139+ "HTTP status code: 400\n"
140+ "\n"
141+ "The error response\n" % url,
142 self.output.getvalue())
143
144 deferred = self.command.run()

Subscribers

People subscribed via source and target branches

to all changes: