Increase test coverage for glance.common.wsgi

Add unit tests for wsgi.get_socket.

Change-Id: I3850dca6f6e4dbeca0465c8d751458e255e0fed8
Fix call to store.safe_delete_from_backend

When uploading data of a newly created image to a local filesystem
store, if the image data size exceeds the quota allocated to the user
then the operation fails with a "500 Internal Server Error".

This bug is triggered only when using chunked transfers to upload the
image data (curl and glanceclient both use chunked transfers).

When using chunked transfers the 'Content-Length' header is not set and
so the quota checking code in start of quota.ImageProxy.set_data() is
skipped. Furthermore, because of the missing size info, the store
downloads the entire image data without checking for the quota (the
quota is checked only after the image data has been downloaded and the
size determined).

If after the image data has been downloaded it is found that the quota
has been exceeded, then the StorageQuotaFull exception is raised and a
call to store.safe_delete_from_backend() made to clean up the image
data. But the 'location' and 'context' parameters to this call are given
in the wrong order and so this operation raises an (uncaught) exception,
giving rise to this bug.

This bug was not caught by existing tests because existing quota tests
don't use chunked transfer.

This commit fixes the order of the parameters and adds quota tests using
chunked transfers.

Change-Id: Ib8ab11f2115e3aead98af70788eaa45c2c33219c
Closes-bug: #1265446
Merge "Fix call to store.safe_delete_from_backend"
Merge "Increase test coverage for glance.common.wsgi"