Merge lp:~dreamhosters/txaws/920302-python2.5-compat into lp:txaws

Proposed by Duncan McGreggor
Status: Merged
Approved by: Duncan McGreggor
Approved revision: 118
Merged at revision: 127
Proposed branch: lp:~dreamhosters/txaws/920302-python2.5-compat
Merge into: lp:txaws
Diff against target: 522 lines (+172/-33)
17 files modified
Makefile (+7/-1)
txaws/client/discover/tests/test_command.py (+1/-1)
txaws/client/discover/tests/test_entry_point.py (+3/-3)
txaws/client/gui/tests/test_gtk.py (+1/-1)
txaws/s3/client.py (+42/-0)
txaws/s3/model.py (+18/-0)
txaws/s3/tests/test_acls.py (+1/-1)
txaws/s3/tests/test_client.py (+74/-1)
txaws/server/tests/test_call.py (+1/-1)
txaws/server/tests/test_exception.py (+1/-1)
txaws/server/tests/test_method.py (+2/-2)
txaws/server/tests/test_registry.py (+2/-2)
txaws/server/tests/test_resource.py (+2/-2)
txaws/server/tests/test_schema.py (+9/-9)
txaws/tests/test_credentials.py (+1/-1)
txaws/tests/test_util.py (+1/-1)
txaws/tests/test_wsdl.py (+6/-6)
To merge this branch: bzr merge lp:~dreamhosters/txaws/920302-python2.5-compat
Reviewer Review Type Date Requested Status
txAWS Technical List Pending
Review via email: mp+90360@code.launchpad.net

Description of the change

This branch takes care of the Python2.5 errors that were preventing the test suite from completing (some of the fixes involved test skips).

To post a comment you must log in.
Revision history for this message
Arsene Rei (arsene-rei) wrote :

Just looking at the diff, it would seem the recent code for get bucket website is removed. Other than that it looks good.

Revision history for this message
Duncan McGreggor (oubiwann) wrote :

Yeah, craziness. Thanks for catching that. Not sure what happened... I feel safe in blaming git-bzr though ;-) Weird, too... 'cause it was a *partial* deletion.

Anyway, I've just pushed it back in.

119. By Duncan McGreggor

Reverted a mysterious partial deletion of a new feature that landed today.

120. By Duncan McGreggor

Revision 115 reverted this change; putting it back.

Revision history for this message
Duncan McGreggor (oubiwann) wrote :

So... the diff that I'm looking at on my filesystem from version 112 to 120 does not look at all like what Launchpad is showing here.

Ah, looks like rev 124 on trunk got committed accidentally at some point. That should *not* happened (obviously). I guess it's really time to stop using git-bzr. A good chunk of what fixed the Python 2.5 errors was in that revision; the rest was clean-up. Ah, well.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2012-01-27 00:10:28 +0000
3+++ Makefile 2012-01-27 06:51:24 +0000
4@@ -23,6 +23,11 @@
5 @python setup.py sdist
6
7
8+check-testcase-names:
9+ @echo "Checking for (possibly) badly named test cases..."
10+ @find ./txaws|xargs grep Test|grep class|grep -v 'TestCase('
11+
12+
13 virtual-dir-setup: VERSION ?= 2.7
14 virtual-dir-setup:
15 -@test -d .venv-$(VERSION) || virtualenv -p $(PYBIN)$(VERSION) .venv-$(VERSION)
16@@ -50,7 +55,7 @@
17
18 virtual-pep8: VERSION ?= 2.7
19 virtual-pep8:
20- -. .venv-$(VERSION)/bin/activate && pep8 ./txaws
21+ -. .venv-$(VERSION)/bin/activate && pep8 --repeat ./txaws
22
23
24 virtual-pyflakes: VERSION ?= 2.7
25@@ -82,6 +87,7 @@
26 -@test -e "`which python2.5`" && VERSION=2.5 make virtual-check
27 -@test -e "`which python2.6`" && VERSION=2.6 make virtual-check
28 -@test -e "`which python2.7`" && VERSION=2.7 make virtual-check
29+ make check-testcase-names
30
31
32 virtual-uninstall: VERSION ?= 2.7
33
34=== modified file 'txaws/client/discover/tests/test_command.py'
35--- txaws/client/discover/tests/test_command.py 2012-01-12 14:41:59 +0000
36+++ txaws/client/discover/tests/test_command.py 2012-01-27 06:51:24 +0000
37@@ -20,7 +20,7 @@
38 self.url = url
39
40
41-class CommandTest(TXAWSTestCase):
42+class CommandTestCase(TXAWSTestCase):
43
44 def prepare_command(self, response, status, action, parameters={},
45 get_page=None, error=None):
46
47=== modified file 'txaws/client/discover/tests/test_entry_point.py'
48--- txaws/client/discover/tests/test_entry_point.py 2010-06-04 22:35:23 +0000
49+++ txaws/client/discover/tests/test_entry_point.py 2012-01-27 06:51:24 +0000
50@@ -12,7 +12,7 @@
51 from txaws.testing.base import TXAWSTestCase
52
53
54-class ParseOptionsTest(TXAWSTestCase):
55+class ParseOptionsTestCase(TXAWSTestCase):
56
57 def test_parse_options(self):
58 """
59@@ -165,7 +165,7 @@
60 "--action", "action", "--help"])
61
62
63-class GetCommandTest(TXAWSTestCase):
64+class GetCommandTestCase(TXAWSTestCase):
65
66 def test_get_command_without_arguments(self):
67 """An L{OptionError} is raised if no arguments are provided."""
68@@ -223,7 +223,7 @@
69 self.assertEqual({"Region.Name.0": "us-west-1"}, command.parameters)
70
71
72-class MainTest(TXAWSTestCase):
73+class MainTestCase(TXAWSTestCase):
74
75 def test_usage_message(self):
76 """
77
78=== modified file 'txaws/client/gui/tests/test_gtk.py'
79--- txaws/client/gui/tests/test_gtk.py 2012-01-23 01:02:16 +0000
80+++ txaws/client/gui/tests/test_gtk.py 2012-01-27 06:51:24 +0000
81@@ -4,7 +4,7 @@
82 from twisted.trial.unittest import TestCase
83
84
85-class UITests(TestCase):
86+class UITestCase(TestCase):
87
88 pass
89 # Really need some, but UI testing hurts my brain.
90
91=== modified file 'txaws/s3/client.py'
92--- txaws/s3/client.py 2012-01-27 01:34:54 +0000
93+++ txaws/s3/client.py 2012-01-27 06:51:24 +0000
94@@ -231,6 +231,48 @@
95
96 return WebsiteConfiguration(index_suffix, error_key)
97
98+ def get_bucket_website_config(self, bucket):
99+ """
100+ Get the website configuration of a bucket.
101+
102+ @param bucket: The name of the bucket.
103+ @return: A C{Deferred} that will fire with the bucket's website
104+ configuration.
105+ """
106+ query = self.query_factory(
107+ action='GET', creds=self.creds, endpoint=self.endpoint,
108+ bucket=bucket, object_name='?website')
109+ return query.submit().addCallback(self._parse_website_config)
110+
111+ def _parse_website_config(self, xml_bytes):
112+ """Parse a C{WebsiteConfiguration} XML document."""
113+ root = XML(xml_bytes)
114+ index_suffix = root.findtext("IndexDocument/Suffix")
115+ error_key = root.findtext("ErrorDocument/Key")
116+
117+ return WebsiteConfiguration(index_suffix, error_key)
118+
119+ def get_bucket_website_config(self, bucket):
120+ """
121+ Get the website configuration of a bucket.
122+
123+ @param bucket: The name of the bucket.
124+ @return: A C{Deferred} that will fire with the bucket's website
125+ configuration.
126+ """
127+ query = self.query_factory(
128+ action='GET', creds=self.creds, endpoint=self.endpoint,
129+ bucket=bucket, object_name='?website')
130+ return query.submit().addCallback(self._parse_website_config)
131+
132+ def _parse_website_config(self, xml_bytes):
133+ """Parse a C{WebsiteConfiguration} XML document."""
134+ root = XML(xml_bytes)
135+ index_suffix = root.findtext("IndexDocument/Suffix")
136+ error_key = root.findtext("ErrorDocument/Key")
137+
138+ return WebsiteConfiguration(index_suffix, error_key)
139+
140 def get_bucket_acl(self, bucket):
141 """
142 Get the access control policy for a bucket.
143
144=== modified file 'txaws/s3/model.py'
145--- txaws/s3/model.py 2012-01-27 01:17:28 +0000
146+++ txaws/s3/model.py 2012-01-27 06:51:24 +0000
147@@ -81,6 +81,24 @@
148 self.error_key = error_key
149
150
151+class WebsiteConfiguration(object):
152+ """
153+ A mapping for the data in a bucket website configuration.
154+ """
155+ def __init__(self, index_suffix, error_key=None):
156+ self.index_suffix = index_suffix
157+ self.error_key = error_key
158+
159+
160+class WebsiteConfiguration(object):
161+ """
162+ A mapping for the data in a bucket website configuration.
163+ """
164+ def __init__(self, index_suffix, error_key=None):
165+ self.index_suffix = index_suffix
166+ self.error_key = error_key
167+
168+
169 class FileChunk(object):
170 """
171 An Amazon S3 file chunk.
172
173=== modified file 'txaws/s3/tests/test_acls.py'
174--- txaws/s3/tests/test_acls.py 2012-01-26 23:05:01 +0000
175+++ txaws/s3/tests/test_acls.py 2012-01-27 06:51:24 +0000
176@@ -4,7 +4,7 @@
177 from txaws.s3 import acls
178
179
180-class ACLTests(TestCase):
181+class ACLTestCase(TestCase):
182
183 def test_owner_to_xml(self):
184 owner = acls.Owner(id='8a6925ce4adf588a4f21c32aa379004fef',
185
186=== modified file 'txaws/s3/tests/test_client.py'
187--- txaws/s3/tests/test_client.py 2012-01-27 01:19:27 +0000
188+++ txaws/s3/tests/test_client.py 2012-01-27 06:51:24 +0000
189@@ -382,6 +382,79 @@
190 d = s3.get_bucket_website_config("mybucket")
191 return d.addCallback(check_results)
192
193+ def test_get_bucket_website_config(self):
194+ """
195+ L{S3Client.get_bucket_website_config} creates a L{Query} to get a
196+ bucket's website configurtion. It parses the returned
197+ C{WebsiteConfiguration} XML document and returns a C{Deferred} that
198+ fires with the bucket's region.
199+ """
200+
201+ class StubQuery(client.Query):
202+
203+ def __init__(query, action, creds, endpoint, bucket=None,
204+ object_name=None):
205+ super(StubQuery, query).__init__(action=action, creds=creds,
206+ bucket=bucket,
207+ object_name=object_name)
208+ self.assertEquals(action, "GET")
209+ self.assertEqual(creds.access_key, "foo")
210+ self.assertEqual(creds.secret_key, "bar")
211+ self.assertEqual(query.bucket, "mybucket")
212+ self.assertEqual(query.object_name, "?website")
213+ self.assertEqual(query.data, "")
214+ self.assertEqual(query.metadata, {})
215+ self.assertEqual(query.amz_headers, {})
216+
217+ def submit(query, url_context=None):
218+ return succeed(payload.
219+ sample_s3_get_bucket_website_no_error_result)
220+
221+ def check_results(website_config):
222+ self.assertEquals(website_config.index_suffix, "index.html")
223+ self.assertEquals(website_config.error_key, None)
224+
225+ creds = AWSCredentials("foo", "bar")
226+ s3 = client.S3Client(creds, query_factory=StubQuery)
227+ d = s3.get_bucket_website_config("mybucket")
228+ return d.addCallback(check_results)
229+
230+ def test_get_bucket_website_config_with_error_doc(self):
231+ """
232+ L{S3Client.get_bucket_website_config} creates a L{Query} to get a
233+ bucket's website configurtion. It parses the returned
234+ C{WebsiteConfiguration} XML document and returns a C{Deferred} that
235+ fires with the bucket's region.
236+ """
237+
238+ class StubQuery(client.Query):
239+
240+ def __init__(query, action, creds, endpoint, bucket=None,
241+ object_name=None):
242+ super(StubQuery, query).__init__(action=action, creds=creds,
243+ bucket=bucket,
244+ object_name=object_name)
245+ self.assertEquals(action, "GET")
246+ self.assertEqual(creds.access_key, "foo")
247+ self.assertEqual(creds.secret_key, "bar")
248+ self.assertEqual(query.bucket, "mybucket")
249+ self.assertEqual(query.object_name, "?website")
250+ self.assertEqual(query.data, "")
251+ self.assertEqual(query.metadata, {})
252+ self.assertEqual(query.amz_headers, {})
253+
254+ def submit(query, url_context=None):
255+ return succeed(payload.sample_s3_get_bucket_website_result)
256+
257+ def check_results(website_config):
258+ self.assertEquals(website_config.index_suffix, "index.html")
259+ self.assertEquals(website_config.error_key, "404.html")
260+
261+ creds = AWSCredentials("foo", "bar")
262+ s3 = client.S3Client(creds, query_factory=StubQuery)
263+ d = s3.get_bucket_website_config("mybucket")
264+ return d.addCallback(check_results)
265+
266 def test_delete_bucket(self):
267
268 class StubQuery(client.Query):
269@@ -919,7 +992,7 @@
270 QueryTestCase.skip = s3clientSkip
271
272
273-class MiscellaneousTests(TXAWSTestCase):
274+class MiscellaneousTestCase(TXAWSTestCase):
275
276 def test_content_md5(self):
277 self.assertEqual(calculate_md5("somedata"), "rvr3UC1SmUw7AZV2NqPN0g==")
278
279=== modified file 'txaws/server/tests/test_call.py'
280--- txaws/server/tests/test_call.py 2012-01-12 14:41:59 +0000
281+++ txaws/server/tests/test_call.py 2012-01-27 06:51:24 +0000
282@@ -3,7 +3,7 @@
283 from txaws.server.call import Call
284
285
286-class CallTest(TestCase):
287+class CallTestCase(TestCase):
288
289 def test_default_version(self):
290 """
291
292=== modified file 'txaws/server/tests/test_exception.py'
293--- txaws/server/tests/test_exception.py 2012-01-23 01:12:50 +0000
294+++ txaws/server/tests/test_exception.py 2012-01-27 06:51:24 +0000
295@@ -5,7 +5,7 @@
296 from txaws.server.exception import APIError
297
298
299-class APIErrorTest(TestCase):
300+class APIErrorTestCase(TestCase):
301
302 def test_with_no_parameters(self):
303 """
304
305=== modified file 'txaws/server/tests/test_method.py'
306--- txaws/server/tests/test_method.py 2011-08-19 11:45:12 +0000
307+++ txaws/server/tests/test_method.py 2012-01-27 06:51:24 +0000
308@@ -3,10 +3,10 @@
309 from txaws.server.method import Method
310
311
312-class MethodTest(TestCase):
313+class MethodTestCase(TestCase):
314
315 def setUp(self):
316- super(MethodTest, self).setUp()
317+ super(MethodTestCase, self).setUp()
318 self.method = Method()
319
320 def test_defaults(self):
321
322=== modified file 'txaws/server/tests/test_registry.py'
323--- txaws/server/tests/test_registry.py 2012-01-27 00:38:05 +0000
324+++ txaws/server/tests/test_registry.py 2012-01-27 06:51:24 +0000
325@@ -16,14 +16,14 @@
326 has_venusian = False
327
328
329-class RegistryTest(TestCase):
330+class RegistryTestCase(TestCase):
331
332 if no_class_decorators:
333 skip = ("Your version of Python doesn't seem to support class "
334 "decorators.")
335
336 def setUp(self):
337- super(RegistryTest, self).setUp()
338+ super(RegistryTestCase, self).setUp()
339 self.registry = Registry()
340
341 def test_add(self):
342
343=== modified file 'txaws/server/tests/test_resource.py'
344--- txaws/server/tests/test_resource.py 2012-01-27 00:10:28 +0000
345+++ txaws/server/tests/test_resource.py 2012-01-27 06:51:24 +0000
346@@ -102,10 +102,10 @@
347 return str("%s - %s" % (error.code, safe_str(error.message)))
348
349
350-class QueryAPITest(TestCase):
351+class QueryAPITestCase(TestCase):
352
353 def setUp(self):
354- super(QueryAPITest, self).setUp()
355+ super(QueryAPITestCase, self).setUp()
356 self.registry = Registry()
357 self.registry.add(TestMethod, action="SomeAction", version=None)
358 self.api = TestQueryAPI(registry=self.registry)
359
360=== modified file 'txaws/server/tests/test_schema.py'
361--- txaws/server/tests/test_schema.py 2012-01-23 01:12:50 +0000
362+++ txaws/server/tests/test_schema.py 2012-01-27 06:51:24 +0000
363@@ -11,7 +11,7 @@
364 Arguments, Bool, Date, Enum, Integer, Parameter, RawStr, Schema, Unicode)
365
366
367-class ArgumentsTest(TestCase):
368+class ArgumentsTestCase(TestCase):
369
370 def test_instantiate_empty(self):
371 """Creating an L{Arguments} object."""
372@@ -56,7 +56,7 @@
373 self.assertEqual("egg", arguments.foo[0])
374
375
376-class ParameterTest(TestCase):
377+class ParameterTestCase(TestCase):
378
379 def test_coerce(self):
380 """
381@@ -188,7 +188,7 @@
382 self.assertEqual("foo", parameter.coerce("foo"))
383
384
385-class UnicodeTest(TestCase):
386+class UnicodeTestCase(TestCase):
387
388 def test_parse(self):
389 """L{Unicode.parse} converts the given raw C{value} to C{unicode}."""
390@@ -232,7 +232,7 @@
391 self.assertEqual("InvalidParameterValue", error.code)
392
393
394-class RawStrTest(TestCase):
395+class RawStrTestCase(TestCase):
396
397 def test_parse(self):
398 """L{RawStr.parse} checks that the given raw C{value} is a string."""
399@@ -247,7 +247,7 @@
400 self.assertTrue(isinstance(value, str))
401
402
403-class IntegerTest(TestCase):
404+class IntegerTestCase(TestCase):
405
406 def test_parse(self):
407 """L{Integer.parse} converts the given raw C{value} to C{int}."""
408@@ -265,7 +265,7 @@
409 self.assertEqual("123", parameter.format(123))
410
411
412-class BoolTest(TestCase):
413+class BoolTestCase(TestCase):
414
415 def test_parse(self):
416 """L{Bool.parse} converts 'true' to C{True}."""
417@@ -292,7 +292,7 @@
418 self.assertEqual("false", parameter.format(False))
419
420
421-class EnumTest(TestCase):
422+class EnumTestCase(TestCase):
423
424 def test_parse(self):
425 """L{Enum.parse} accepts a map for translating values."""
426@@ -313,7 +313,7 @@
427 self.assertEqual("foo", parameter.format("bar"))
428
429
430-class DateTest(TestCase):
431+class DateTestCase(TestCase):
432
433 def test_parse(self):
434 """L{Date.parse checks that the given raw C{value} is a date/time."""
435@@ -332,7 +332,7 @@
436 self.assertEqual("2010-09-15T21:59:59Z", parameter.format(date))
437
438
439-class SchemaTest(TestCase):
440+class SchemaTestCase(TestCase):
441
442 def test_extract(self):
443 """
444
445=== modified file 'txaws/tests/test_credentials.py'
446--- txaws/tests/test_credentials.py 2009-08-28 20:13:07 +0000
447+++ txaws/tests/test_credentials.py 2012-01-27 06:51:24 +0000
448@@ -7,7 +7,7 @@
449 from txaws.testing.base import TXAWSTestCase
450
451
452-class TestCredentials(TXAWSTestCase):
453+class CredentialsTestCase(TXAWSTestCase):
454
455 def test_no_access_errors(self):
456 # Without anything in os.environ, AWSService() blows up
457
458=== modified file 'txaws/tests/test_util.py'
459--- txaws/tests/test_util.py 2012-01-23 01:21:37 +0000
460+++ txaws/tests/test_util.py 2012-01-27 06:51:24 +0000
461@@ -5,7 +5,7 @@
462 from txaws.util import hmac_sha1, iso8601time, parse
463
464
465-class MiscellaneousTests(TestCase):
466+class MiscellaneousTestCase(TestCase):
467
468 def test_hmac_sha1(self):
469 cases = [
470
471=== modified file 'txaws/tests/test_wsdl.py'
472--- txaws/tests/test_wsdl.py 2012-01-27 00:10:28 +0000
473+++ txaws/tests/test_wsdl.py 2012-01-27 06:51:24 +0000
474@@ -15,7 +15,7 @@
475 skip = "lxml is either not installed or broken on your system."
476
477
478-class NodeSchemaTest(WsdlBaseTestCase):
479+class NodeSchemaTestCase(WsdlBaseTestCase):
480
481 def test_create_with_bad_tag(self):
482 """
483@@ -70,7 +70,7 @@
484 self.assertEqual("<foo/>", etree.tostring(schema.dump(foo)))
485
486
487-class NodeItemTest(WsdlBaseTestCase):
488+class NodeItemTestCase(WsdlBaseTestCase):
489
490 def test_get(self):
491 """
492@@ -281,7 +281,7 @@
493 self.assertTrue(hasattr(foo, "bar"))
494
495
496-class SequenceSchemaTest(WsdlBaseTestCase):
497+class SequenceSchemaTestCase(WsdlBaseTestCase):
498
499 def test_create_with_bad_tag(self):
500 """
501@@ -351,7 +351,7 @@
502 etree.tostring(schema.dump(foo)))
503
504
505-class SequenceItemTest(WsdlBaseTestCase):
506+class SequenceItemTestCase(WsdlBaseTestCase):
507
508 def test_get(self):
509 """
510@@ -507,10 +507,10 @@
511 self.assertEqual("egg1", item1.bar)
512
513
514-class WDSLParserTest(WsdlBaseTestCase):
515+class WDSLParserTestCase(WsdlBaseTestCase):
516
517 def setUp(self):
518- super(WDSLParserTest, self).setUp()
519+ super(WDSLParserTestCase, self).setUp()
520 parser = WSDLParser()
521 wsdl_dir = os.path.join(os.path.dirname(__file__), "../../wsdl")
522 wsdl_path = os.path.join(wsdl_dir, "2009-11-30.ec2.wsdl")

Subscribers

People subscribed via source and target branches