Without up-reving hacking python 3.12 can't be used for pep8/flake8
checks. Also address a few new pyflakes issues that seem reasonable
to enforce:
E275 missing whitespace after keyword
H214 Use assertIn/NotIn(A, B) rather than
assertTrue/False(A in/not in B)
H211 do not compare types, use assert{Is,IsNot}Instance
Add F811 (redefinition of unused 'function'), as this check makes
client.py fail.
And noqa some longer lines that we're happy to carry.
Change-Id: Ic97698a310ffe7114b668b8c4bc0195f6997bb45
Under py312, MagicMock.has_calls raises an AttributeError. This is
actually a good thing, as previously we weren't actually making the
assertions we thought we were making.
Fix the one place that we forgot the leading `assert_`, and switch it
to `any_order=True`; this is required for the test to pass, as there
are additional calls between the two expected calls.
See https://github.com/python/cpython/commit/1d4d677d
Change-Id: Ia2ff2f198b4c1312a3e7dce32f11b87050683d45
We've had SLO for nearly ten years, and it is preferable for most
use-cases. It's time to default to SLO rather than DLO.
Add a new --use-dlo option to give users a way to return to old
behavior; ensure there is still a --use-slo option so we don't break
existing scripts that may use it.
UpgradeImpact:
==============
The default segmented-upload behavior has changed; Static Large Objects
are now used by default rather than Dynamic Large Objects. To revert to
the old behavior:
* CLI users may use the new `--use-dlo` option
* Service API users may explicitly set `use_slo` to False in their
options dicts
Change-Id: Iebcd64ced8eab6efebb9f02a0c4be6bf6338cb3b
...provided it isn't something to do with certification validation.
Closes-Bug: #1641363
Closes-Bug: #2011731
Change-Id: Ic3acbf431e444fcd8bc0fe79571fe2db4140cf22
If the received content-length does not match expectations, of course
the etag won't match!
Co-Authored-By: Alistair Coles <alistairncoles@gmail.com>
Change-Id: I1a0c066c11b94718fffbb11e13b82d0b16e01626
We have seen middlewares that return ratelimit responses as 498 or 429,
so tolerate either.
Closes-Bug: #1879572
Change-Id: I027222157f6c2ad7882a0508302c9de097baae4c
UpgradeImpact
=============
The Connection class now enables retry_on_ratelimit by default.
If you need to return to the old behavior, explicitly pass
retry_on_ratelimit=False as a keyword arg.
The SwiftService class will now enables the retry_on_ratelimit option by
default. If you need to return to the old behavior, explicitly set it to
false in your options dict.
Change-Id: I3221fda84f0b8031c50128aa600e2c19deb5b102
Up the default to sha256 since
* the proxy has supported (and defaulted to allowing) it for four years
now, and
* Rackspace has supported it for even longer.
Include a note in the --help about older clusters likely requiring sha1.
Change-Id: Ibac2bb7e2e4c9946c7384f0aab8e43d0d79ba645
Related-Change: Ia9dd1a91cc3c9c946f5f029cdefc9e66bcf01046
Related-Bug: #1733634
Closes-Bug: #1977867
Since Python 3.4, the unittest module has provided mock, negating the
need for the external dependancy. Switch to using unittest.mock.
Change-Id: Idec3aaed2fddd1ece3ed86ee0bcc48f7616d56fa
All strings are unicode by default in Python 3. No need to mark them as
such.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I68fb60ef271abfddebcc9d2137424f5db2a17e92
All classes subclass from object by default in Python 3.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I5a1ad57bcc092861ce969759b06a07c880ad3d35
This mostly affects tests. Nothing too complicated
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: Iabc78f651e1d48db35638280722f8019798eccd6
These aren't needed in modern Python 3 versions.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I5e81d6fb2e2cb8e4bfae4ed746da002f44e871c4
This also upgrades the Requests dependency to 2.4+ (released in 2014)
to avoid having to do version comparisons altogether.
Refs https://bugs.launchpad.net/python-swiftclient/+bug/1904551
Signed-off-by: Aarni Koskela <akx@iki.fi>
Change-Id: I58399f6c526b0b78462f31739c43076314ba9e76
There's a lot of cleanup possible, but this is a start.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: Ia1176b7fd5434d52070d482a37abfbb98800cdb3
Currently, a user with read/write access to a container (but without
access to creat new containers) recieves a warning every time they
upload. Now, allow them to avoid the extra request and warning by
specifying --skip-container-put on the command line.
This is also useful when testing: developers can HEAD a container to
ensure it's in memcache, shut down all container servers, then upload
and creaate a bunch of async pendings. Previously, the 503 on container
PUT would prevent the object upload from even being attempted.
Closes-Bug: 1317956
Related-Bug: 1204558
Change-Id: I3d9129a0b6b65c6c6187ae6af003b221afceef47
Related-Change: If1f8a02ee7459ea2158ffa6e958f67d299ec529e
Previously, we would write out totals for every page of listings, like
$ swift list sync --prefix=09-21 --total -l
80000000000
80000000000
80000000000
58096000000
Now, roll those all into a single total:
$ swift list sync --prefix=09-21 --total -l
298096000000
Change-Id: Icc265636815220e33e8c9eec0a3ab80e9f899038
You can run all tests by just running
$ pytest
Or just unit tests with
$ pytest test/unit/
Or one specific test with
$ pytest test/unit/test_swiftclient.py::TestConnection::test_reauth
Change-Id: I1dfa239f9ee9ea85663b5c1f22631a97f87b4dfc