Commit Graph

6 Commits

Author SHA1 Message Date
Tim Burke
9b8ab67a78 Include response headers in ClientExceptions
Now, client applications can get to things like transaction IDs for
failures without needing to turn on all of logging.

While we're at it, add a from_response factory method for
ClientException.

Co-Authored-By: Alexander Corwin <ancorwin@gmail.com>
Change-Id: Ib46d5f8fc7f36f651f5908bb9d900316fdaebce3
2016-03-03 17:16:33 +00:00
Zack M. Davis
5ae4b42392 make ClientException.http_status default to None rather than 0
The extant default of zero is a bit counterintuitive;
insufficiently-careful programmers using swiftclient in their
application might, without carefully reading the source or
documentation, write buggy code based on the assumption that the
`http_status` attribute is absent or defaults to None if ClientException
is raised for reasons other than to indicate an unsuccessful HTTP
request. (However improbable this scenario may seem, the present author
can sadly attest to it having actually happened at least once.)

Just changing the default would break some tests on Python 3, due to the
`500 <= err.http_status <= 599` comparison in Connection's _retry
method (NoneType and int are not orderable in the Python 3.x series);
thus, the case where http_status is None is explicitly folded into a
code branch that logs and reraises (whereas previously it would have
fallen through to an `else` branch where it would be logged and reraised
just the same).

While we're here, we might as well make ClientException's __init__ use
super() (although admittedly the kinds of multiple-inheritance scenarios
in which `super` truly shines seem unlikely to occur here).

Change-Id: I8c02bfb4a0ef059e781be5e08fcde13fb1be5b88
2015-09-04 16:24:54 -07:00
Christian Schwede
5ecff2868e Use skipTest from testtools instead of inherited Exception
SkipTest is raised if there is no func_test section in the Swift test
config file. However, the currently raised Exception will result in a
failed test, not in a test marked as skipped.

Since we already use testtools we can use the included skipTest easily.

Change-Id: I1bbb1f9dbe31fb0698d774550708d1196b266625
2014-10-08 07:10:23 +00:00
Christian Schwede
eb94ac076d Add functional tests for python-swiftclient
Coverage for swiftclient.client is 71% with these tests.

Unit tests have been moved into another subdirectory
to separate them from functional tests.

Change-Id: Ib8c4d78f7169cee893f82906f6388a5b06c45602
2014-05-05 11:53:37 +02: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
Darrell Bishop
9198e95468 Move multi-threading code to a library.
This patch extracts the multi-threading code from bin/swift into
swiftclient/multithreading and adds tests.  In particular, this new way
of doing it (with context managers) will prevent non-daemonic threads
from wedging the process when unexpected exceptions happen.

I enabled reporting of which lines, specifically, are not covered by
unit tests (added -m option to "coverage report" in .unittests).

This patch includes a drive-by fix for uploading a segmented file with
--use-slo when that object already exists.  A key of "name" was used
instead of "path", raising KeyError.

There's also another drive-by fix for uploading segmented objects with
--use-slo.  Commit 874e0e4427 regressed
this by removing the capturing of thread-worker results in
QueueFunctionThread.run().  This patch restores that functionality and
the feature (uploading SLO objects).

Change-Id: I0b4f677e4a734e83d1a25088d9a74f7d46384e53
2013-07-28 22:08:17 -07:00