190 Commits

Author SHA1 Message Date
Alex Gaynor
c3bec04485 Fixed several shell tests on Python3.
They currently fail because on Python3 arbitrary objects cannot be compared, in
this case, MagicMock and int. In Python2 these comparisons silently pass.

Change-Id: I468c2137702a454365886099e827d329cb1d7209
2014-04-23 15:52:13 -07:00
Samuel Merritt
1353f2412b Fix up StringIO use in tests for py3
Some spots in this file were already referencing six.StringIO, but
some were still using StringIO.StringIO, which does not work on
py3. This patch just makes them all use six.StringIO and removes the
now-unused (and wrong, on py3) import.

Change-Id: I3c7311c3983f4eb409eedb6f85ede6ffe4059e63
2014-04-23 13:04:54 -07:00
Jenkins
1893cbec88 Merge "Fix test_raw_upload test" 2014-04-23 19:58:10 +00:00
Alex Gaynor
0102e2e1ee Updated test_shell for Python3
Change-Id: Ia76e544fa6e0a222c260191a1ab74939078ed2fb
2014-04-23 11:40:37 -07:00
Jenkins
91075c3251 Merge "Remove validate_headers" 2014-04-23 16:57:24 +00:00
Jenkins
cda2573ab6 Merge "Add tests for bin/swift" 2014-04-18 02:28:27 +00:00
Chmouel Boudjnah
e2b7636d66 Fix test_raw_upload test
We were testing the test but we were not testing that we have actually
properly uploaded the object with the right content-len

(and it was broken under py3)

Change-Id: Ifa91c30532090cac9f8e18ff18eaf5e6c98737d1
2014-04-17 12:04:43 -04:00
Chmouel Boudjnah
504e5a7f53 Remove validate_headers
It wasn't used anymore since moved up to requests (and it fails in py3).

Change-Id: Ic8a80ae09ca6445696a9cf34ffb503c5ff51bc79
2014-04-17 12:04:43 -04:00
Jenkins
aaa563c749 Merge "Fix test_multithreading on Python 3" 2014-04-16 02:58:47 +00:00
Jenkins
c810772623 Merge "Fix swiftclient.client.quote() for Python 3" 2014-04-16 00:36:39 +00:00
Victor Stinner
ea498fb052 Fix test_multithreading on Python 3
* On Python 3, the printer doesn't encode Unicode to utf8 anymore, since
  print() expects a Unicode string.

* Update unit tests for Python 3 since repr() doesn't escape non-ASCII
  characters in Unicode strings anymore:
  http://legacy.python.org/dev/peps/pep-3138/

Change-Id: I89471019d691a46651312d6a49964b719192148a
2014-04-15 11:38:26 -04:00
Christian Schwede
f24c67cf1d Add tests for bin/swift
Tests are written to ensure bin/swift is working properly and using
functions from swiftclient modules as expected.

Change-Id: Idb0581516b7e0a41c97977bb0bb9f8290f67ad13
2014-04-14 10:41:55 -04:00
Jenkins
ec538d3720 Merge "Add requests related unit-tests" 2014-04-14 10:49:14 +00:00
Jenkins
cdd8d33ea7 Merge "Python 3: fix tests on HTTP headers" 2014-04-10 14:08:30 +00:00
Victor Stinner
155053ea61 Fix swiftclient.client.quote() for Python 3
On Python 3, urllib.parse.quote() accepts bytes and str (unicode) types and
always return str (unicode).

Add also more tests with non-ASCII characters.

Change-Id: I8e0f19da7240e874392327d0da074ed4abb7d213
2014-04-07 10:30:18 +02:00
Jenkins
c5cc2b7b7e Merge "Use the standard library's copy of mock when it's available." 2014-04-05 09:46:04 +00:00
Tristan Cacqueray
da2d8eef47 Add requests related unit-tests
This change improves unit tests of the new code added by the port to requests.
Raw upload and chunked upload in put_object are now covered.

Change-Id: I995b23a74bc4b00bf5761362b1f1405bb8662311
2014-04-05 09:14:08 +00:00
Victor Stinner
d8cb0b9b32 Python 3: fix tests on HTTP headers
HTTP headers are encoded to bytes. Store headers at (key, value) tuples instead
of Unicode strings.

Check also that non-ASCII Unicode headers are encoded to UTF-8.

Change-Id: Ie45f5a5ba63f539a723a7ac5649779d8efb3e912
2014-04-04 10:57:41 +02:00
Jenkins
cda26a32c1 Merge "set user-agent header" 2014-04-01 15:21:20 +00:00
Alex Gaynor
4e7bc75432 Use the standard library's copy of mock when it's available.
Change-Id: Id6a31157582efe47cc3a74e6658679c2bec14767
2014-03-31 11:34:49 -07:00
Jenkins
21db1bf836 Merge "Python 3: Get compatible types from six" 2014-03-30 19:48:34 +00:00
John Dickinson
4f3d6e7f3a set user-agent header
Change-Id: Ia67807667b4b5177d83cce9fcf16d98dc5024fbc
2014-03-30 10:29:07 -07:00
Victor Stinner
12f86fdcc5 Python 3: Get compatible types from six
* Replace unicode with six.text_type
* Replace basestring with six.string_types
* The long type doesn't exist in Python 3 anymore: replace 1L with long(1) and
  only test this type with Python 2
* Fix quote(): quote the URL if the string is a byte string. Use "bytes" type
  instead of "str" to be Python 3 compatible.

Change-Id: I1df5aa85e4e7d07191fb5c654d52fc4bd8b9f440
2014-03-28 15:48:50 +00:00
Victor Stinner
e3b7ecd2bb Python 3: Fix module names in import
Use six.moves to fix imports on Python 3.

Change-Id: I35b9405690e9f0607b24d79aa7c00830df954c41
2014-03-28 15:04:14 +00:00
Jenkins
b6ecec3cca Merge "Python 3: cast map() result to list" 2014-03-28 10:14:27 +00:00
Jenkins
14f0c89cc1 Merge "Python 3: Fix tests using temporary text files" 2014-03-28 10:14:26 +00:00
Jenkins
7dcefe1b64 Merge "Python 3: Replace iter.next() with six.next(iter)" 2014-03-28 09:59:03 +00:00
Victor Stinner
701faf0d16 Replace dict.iteritems() with dict.items()
dict.iteritems() has been removed in Python 3. In Python 2, dict.items()
creates a temporary list, but Samuel Merritt wrote:

"The size of the data is small enough that we don't need to worry about the
memory consumption; it's all just HTTP headers."

Change-Id: Iac427b8bbd032e4a1efb2bdc84a3968217eb6ddf
2014-03-27 12:21:25 +01:00
Victor Stinner
46d62bd9be Python 3: Replace iter.next() with six.next(iter)
Use six.next() to be Python 3 compatible.

Change-Id: Ia16148a759d368872787d5896a7b1dc42ffcdfb5
2014-03-27 12:13:49 +01:00
Victor Stinner
9c85ea7a75 Python 3: Fix tests using temporary text files
Use mode "w" instead of the default mode "wb+" to get text file instead of
binary file on Python 3.

Change-Id: I2efe8d926309cfcd5ffe4ea963c11799773def73
2014-03-24 18:18:26 +01:00
Victor Stinner
6d5a4749b5 Python 3: cast map() result to list
On Python 3, map() returns a generator, not a list. Cast explicitly the result
of map() to a list to get a list on Python 2 and Python 3.

The cast is useless in Python 2, but it doesn't hurt performances: it's just a
unit test.

Change-Id: I87486b7dbc42507a6fd7886748a2e09735b6fc5b
2014-03-24 18:17:44 +01:00
zhang-jinnan
26e644f7bb Use six.StringIO instead of StringIO.StringIO
Keep Python 3.x compatibility

Change-Id: If7a8f0630bd2582ca9488313dcc59805c2ce1835
2014-03-03 16:16:07 +08:00
Clay Gerrard
3d35a3e989 Add LengthWrapper in put_object to honor content_length param
Closes-Bug:#1284360

Change-Id: Iec63a3fde77bb8195bfe46c764403b367999ff43
2014-02-25 01:12:51 -08:00
John Dickinson
79f189a593 Fix --insecure option on auth
Change-Id: Ibe76d98d6075b84cbdb370b48f3498ab848142ad
2014-02-13 23:37:08 -08:00
Tristan Cacqueray
b182112719 Port to python-requests
Currently, httplib implementation does not support SSL certificate
verification. This patch fixes this. Note that ssl compression parameter
and 100-continue thing is still missing from requests, though those are
lower priority.

Requests now takes care of:
* proxy configuration (get_environ_proxies),
* chunked encoding (with data generator),
* bulk uploading (with files dictionary),
* SSL certificate verification (with 'insecure' and 'cacert' parameter).

This patch have been tested with requests 1.1.0 (CentOS 6) and requests
2.2.1 (current version).

Change-Id: Ib5de962f4102d57c71ad85fd81a615362ef175dc
Closes-Bug: #1199783
DocImpact
SecurityImpact
2014-02-12 13:21:26 +01:00
Jenkins
fa15f66932 Merge "assertEquals is deprecated, use assertEqual" 2014-01-31 09:13:46 +00:00
Jenkins
feb514a207 Merge "Add capabilities option" 2014-01-31 08:55:27 +00:00
Jenkins
b4907e0c81 Merge "retry on ratelimit" 2014-01-18 17:07:16 +00:00
Dirk Mueller
eac3c72924 assertEquals is deprecated, use assertEqual
Change-Id: I226d9046d25d681beea60d38b029b71f9e6bf86c
2014-01-17 11:31:00 +01:00
Fabien Boucher
533c9c5ba1 Add capabilities option
This patch adds a capabilities option on swiftclient.
This option uses the new /info endpoint to request the
remote capabilities and nicely display it.

Change-Id: Ie34b454511d5527e402e66e1fdb72120f427f2fd
2014-01-17 10:26:34 +01:00
Wu Wenxiang
a1cf366a0b Replace xrange in for loop with range
xrange is not supported in python 3, so replace it with range since no
large size lists involved.

Closes-Bug: #1237717

Change-Id: I4e5e0782153d32c8beee03f7d871722ed4352859
2014-01-14 21:49:44 +08:00
John Dickinson
5187fd313f retry on ratelimit
Added a retry_on_ratelimit parameter to the Connection
class so that ratelimited requests can be retried.

DocImpact

Change-Id: I2817a7ea0ed2d69a7659e80111fbd2c91a75d530
2013-12-23 13:53:18 -08:00
Jenkins
0ae2b58f2d Merge "Enable usage of proxies defined in environment (http(s)_proxy)." 2013-12-14 09:37:38 +00:00
Davide Guerri
716b4e722c Enable usage of proxies defined in environment (http(s)_proxy).
As far as proxies usage is concerned, keystone-client API and swift-client API behave differently because the former uses python Request library while the latter uses raw httplib. As a result, Keystone authentication honors environment variables http_proxy, https_proxy and no_proxy while Swift doesn't.

This patch, which code is mainly borrowed from Python Requests, makes Swift
data connections and Swift authentication connections behaving homogeneously.

Change-Id: Ic8a0089c35c458d7ed96e572e22429014298fe4c
2013-12-10 12:12:28 +00:00
Jenkins
b0f794800c Merge "Don't crash when header is value of None" 2013-12-07 10:12:08 +00:00
Chmouel Boudjnah
983988093f Don't crash when header is value of None
Before commit 7d88d14d (http://git.io/hhJWdQ) swifclient used to accept
header value with the type None :

{'Headers': None}

It would just be happy with it with those None headers and not process
them, reinstate the old behavior.

Closes-Bug: 1256441
Change-Id: Ic7f80c38ef2ce9ef1687ed0d6d65521f2e754905
2013-12-06 13:28:01 +01:00
Jenkins
dbc6686b5e Merge "Add close to swiftclient.client.Connection" 2013-11-29 22:01:24 +00:00
Jenkins
04e0cb2783 Merge "Add verbose output to all stat commands" 2013-11-21 08:50:33 +00:00
Feng Liu
9fe79a4aac Add close to swiftclient.client.Connection
Change-Id: I2f5fa9c46886607a9ba99e8915ea84ac4975d004
2013-10-23 11:31:10 +08:00
Leah Klearman
b682935055 enhance swiftclient logging
* log to debug for successes and info for errors
* remove dead code, neither body or raw_body are sent in kwargs
* include resp.reason and response headers in logging
* remove trailing \n in logging. users who want them can set logging.basicConfig(format=FORMAT)
* add --info option to swift cli

Change-Id: If07af46cb377f3f3d70f6c4284037241d360a8b7
2013-10-17 16:05:36 -07:00