cleaning up docstrings

This commit is contained in:
Brian Waldon 2011-06-28 10:37:31 -04:00
parent 116ef8202b
commit b6aa958862
20 changed files with 118 additions and 123 deletions

View File

@ -44,7 +44,6 @@ class V1Client(base_client.BaseClient):
:param use_ssl: Should we use HTTPS? (defaults to False) :param use_ssl: Should we use HTTPS? (defaults to False)
:param doc_root: Prefix for all URLs we request from host :param doc_root: Prefix for all URLs we request from host
""" """
port = port or self.DEFAULT_PORT port = port or self.DEFAULT_PORT
self.doc_root = doc_root self.doc_root = doc_root
super(Client, self).__init__(host, port, use_ssl) super(Client, self).__init__(host, port, use_ssl)
@ -81,7 +80,6 @@ class V1Client(base_client.BaseClient):
:param sort_key: results will be ordered by this image attribute :param sort_key: results will be ordered by this image attribute
:param sort_dir: direction in which to to order results (asc, desc) :param sort_dir: direction in which to to order results (asc, desc)
""" """
params = self._extract_params(kwargs, v1_images.SUPPORTED_PARAMS) params = self._extract_params(kwargs, v1_images.SUPPORTED_PARAMS)
res = self.do_request("GET", "/images/detail", params=params) res = self.do_request("GET", "/images/detail", params=params)
data = json.loads(res.read())['images'] data = json.loads(res.read())['images']
@ -126,7 +124,6 @@ class V1Client(base_client.BaseClient):
:retval The newly-stored image's metadata. :retval The newly-stored image's metadata.
""" """
headers = utils.image_meta_to_http_headers(image_meta or {}) headers = utils.image_meta_to_http_headers(image_meta or {})
if image_data: if image_data:

View File

@ -41,7 +41,6 @@ class RegistryClient(BaseClient):
:param port: The port where Glance resides (defaults to 9191) :param port: The port where Glance resides (defaults to 9191)
:param use_ssl: Should we use HTTPS? (defaults to False) :param use_ssl: Should we use HTTPS? (defaults to False)
""" """
port = port or self.DEFAULT_PORT port = port or self.DEFAULT_PORT
super(RegistryClient, self).__init__(host, port, use_ssl) super(RegistryClient, self).__init__(host, port, use_ssl)

View File

@ -97,10 +97,10 @@ def image_create(context, values):
def image_update(context, image_id, values, purge_props=False): def image_update(context, image_id, values, purge_props=False):
"""Set the given properties on an image and update it. """
Set the given properties on an image and update it.
Raises NotFound if image does not exist.
:raises NotFound if image does not exist.
""" """
return _image_update(context, values, image_id, purge_props) return _image_update(context, values, image_id, purge_props)
@ -131,7 +131,8 @@ def image_get(context, image_id, session=None):
def image_get_all_public(context, filters=None, marker=None, limit=None, def image_get_all_public(context, filters=None, marker=None, limit=None,
sort_key='created_at', sort_dir='desc'): sort_key='created_at', sort_dir='desc'):
"""Get all public images that match zero or more filters. """
Get all public images that match zero or more filters.
:param filters: dict of filter keys and values. If a 'properties' :param filters: dict of filter keys and values. If a 'properties'
key is present, it is treated as a dict of key/value key is present, it is treated as a dict of key/value
@ -189,7 +190,8 @@ def image_get_all_public(context, filters=None, marker=None, limit=None,
def _drop_protected_attrs(model_class, values): def _drop_protected_attrs(model_class, values):
"""Removed protected attributes from values dictionary using the models """
Removed protected attributes from values dictionary using the models
__protected_attributes__ field. __protected_attributes__ field.
""" """
for attr in model_class.__protected_attributes__: for attr in model_class.__protected_attributes__:
@ -204,7 +206,6 @@ def validate_image(values):
:param values: Mapping of image metadata to check :param values: Mapping of image metadata to check
""" """
status = values.get('status') status = values.get('status')
disk_format = values.get('disk_format') disk_format = values.get('disk_format')
container_format = values.get('container_format') container_format = values.get('container_format')
@ -237,13 +238,13 @@ def validate_image(values):
def _image_update(context, values, image_id, purge_props=False): def _image_update(context, values, image_id, purge_props=False):
"""Used internally by image_create and image_update """
Used internally by image_create and image_update
:param context: Request context :param context: Request context
:param values: A dict of attributes to set :param values: A dict of attributes to set
:param image_id: If None, create the image, otherwise, find and update it :param image_id: If None, create the image, otherwise, find and update it
""" """
session = get_session() session = get_session()
with session.begin(): with session.begin():
@ -325,7 +326,8 @@ def image_property_update(context, prop_ref, values, session=None):
def _image_property_update(context, prop_ref, values, session=None): def _image_property_update(context, prop_ref, values, session=None):
"""Used internally by image_property_create and image_property_update """
Used internally by image_property_create and image_property_update
""" """
_drop_protected_attrs(models.ImageProperty, values) _drop_protected_attrs(models.ImageProperty, values)
values["deleted"] = False values["deleted"] = False
@ -335,7 +337,8 @@ def _image_property_update(context, prop_ref, values, session=None):
def image_property_delete(context, prop_ref, session=None): def image_property_delete(context, prop_ref, session=None):
"""Used internally by image_property_create and image_property_update """
Used internally by image_property_create and image_property_update
""" """
prop_ref.update(dict(deleted=True)) prop_ref.update(dict(deleted=True))
prop_ref.save(session=session) prop_ref.save(session=session)
@ -344,8 +347,8 @@ def image_property_delete(context, prop_ref, session=None):
# pylint: disable-msg=C0111 # pylint: disable-msg=C0111
def _deleted(context): def _deleted(context):
"""Calculates whether to include deleted objects based on context. """
Calculates whether to include deleted objects based on context.
Currently just looks for a flag called deleted in the context dict. Currently just looks for a flag called deleted in the context dict.
""" """
if not hasattr(context, 'get'): if not hasattr(context, 'get'):

View File

@ -51,7 +51,8 @@ BigInteger = lambda: sqlalchemy.types.BigInteger()
def from_migration_import(module_name, fromlist): def from_migration_import(module_name, fromlist):
"""Import a migration file and return the module """
Import a migration file and return the module
:param module_name: name of migration module to import from :param module_name: name of migration module to import from
(ex: 001_add_images_table) (ex: 001_add_images_table)
@ -84,7 +85,6 @@ def from_migration_import(module_name, fromlist):
images = define_images_table(meta) images = define_images_table(meta)
# Refer to images table # Refer to images table
""" """
module_path = 'glance.registry.db.migrate_repo.versions.%s' % module_name module_path = 'glance.registry.db.migrate_repo.versions.%s' % module_name
module = __import__(module_path, globals(), locals(), fromlist, -1) module = __import__(module_path, globals(), locals(), fromlist, -1)

View File

@ -33,7 +33,8 @@ logger = logging.getLogger('glance.registry.db.migration')
def db_version(options): def db_version(options):
"""Return the database's current migration number """
Return the database's current migration number
:param options: options dict :param options: options dict
:retval version number :retval version number
@ -49,7 +50,8 @@ def db_version(options):
def upgrade(options, version=None): def upgrade(options, version=None):
"""Upgrade the database's current migration level """
Upgrade the database's current migration level
:param options: options dict :param options: options dict
:param version: version to upgrade (defaults to latest) :param version: version to upgrade (defaults to latest)
@ -65,7 +67,8 @@ def upgrade(options, version=None):
def downgrade(options, version): def downgrade(options, version):
"""Downgrade the database's current migration level """
Downgrade the database's current migration level
:param options: options dict :param options: options dict
:param version: version to downgrade to :param version: version to downgrade to
@ -80,7 +83,8 @@ def downgrade(options, version):
def version_control(options): def version_control(options):
"""Place a database under migration control """
Place a database under migration control
:param options: options dict :param options: options dict
""" """
@ -94,7 +98,8 @@ def version_control(options):
def _version_control(options): def _version_control(options):
"""Place a database under migration control """
Place a database under migration control
:param options: options dict :param options: options dict
""" """
@ -104,7 +109,8 @@ def _version_control(options):
def db_sync(options, version=None): def db_sync(options, version=None):
"""Place a database under migration control and perform an upgrade """
Place a database under migration control and perform an upgrade
:param options: options dict :param options: options dict
:retval version number :retval version number

View File

@ -57,7 +57,8 @@ class Controller(object):
db_api.configure_db(options) db_api.configure_db(options)
def index(self, req): def index(self, req):
"""Return a basic filtered list of public, non-deleted images """
Return a basic filtered list of public, non-deleted images
:param req: the Request object coming from the wsgi layer :param req: the Request object coming from the wsgi layer
:retval a mapping of the following form:: :retval a mapping of the following form::
@ -74,7 +75,6 @@ class Controller(object):
'container_format': <CONTAINER_FORMAT>, 'container_format': <CONTAINER_FORMAT>,
'checksum': <CHECKSUM> 'checksum': <CHECKSUM>
} }
""" """
params = self._get_query_params(req) params = self._get_query_params(req)
images = db_api.image_get_all_public(None, **params) images = db_api.image_get_all_public(None, **params)
@ -88,7 +88,8 @@ class Controller(object):
return dict(images=results) return dict(images=results)
def detail(self, req): def detail(self, req):
"""Return a filtered list of public, non-deleted images in detail """
Return a filtered list of public, non-deleted images in detail
:param req: the Request object coming from the wsgi layer :param req: the Request object coming from the wsgi layer
:retval a mapping of the following form:: :retval a mapping of the following form::
@ -97,7 +98,6 @@ class Controller(object):
Where image_list is a sequence of mappings containing Where image_list is a sequence of mappings containing
all image model fields. all image model fields.
""" """
params = self._get_query_params(req) params = self._get_query_params(req)
images = db_api.image_get_all_public(None, **params) images = db_api.image_get_all_public(None, **params)
@ -127,11 +127,11 @@ class Controller(object):
return params return params
def _get_filters(self, req): def _get_filters(self, req):
"""Return a dictionary of query param filters from the request """
Return a dictionary of query param filters from the request
:param req: the Request object coming from the wsgi layer :param req: the Request object coming from the wsgi layer
:retval a dict of key/value filters :retval a dict of key/value filters
""" """
filters = {} filters = {}
properties = {} properties = {}
@ -208,7 +208,6 @@ class Controller(object):
:param id: The opaque internal identifier for the image :param id: The opaque internal identifier for the image
:retval Returns 200 if delete was successful, a fault if not. :retval Returns 200 if delete was successful, a fault if not.
""" """
context = None context = None
try: try:
@ -226,7 +225,6 @@ class Controller(object):
:retval Returns the newly-created image information as a mapping, :retval Returns the newly-created image information as a mapping,
which will include the newly-created image's internal id which will include the newly-created image's internal id
in the 'id' field in the 'id' field
""" """
image_data = body['image'] image_data = body['image']
@ -247,14 +245,14 @@ class Controller(object):
return exc.HTTPBadRequest(msg) return exc.HTTPBadRequest(msg)
def update(self, req, id, body): def update(self, req, id, body):
"""Updates an existing image with the registry. """
Updates an existing image with the registry.
:param req: wsgi Request object :param req: wsgi Request object
:param body: Dictionary of information about the image :param body: Dictionary of information about the image
:param id: The opaque internal identifier for the image :param id: The opaque internal identifier for the image
:retval Returns the updated image information as a mapping, :retval Returns the updated image information as a mapping,
""" """
image_data = body['image'] image_data = body['image']

View File

@ -116,7 +116,6 @@ def parse_uri_tokens(parsed_uri, example_url):
1) urlparse to split the tokens 1) urlparse to split the tokens
2) use RE to split on @ and / 2) use RE to split on @ and /
3) reassemble authurl 3) reassemble authurl
""" """
path = parsed_uri.path.lstrip('//') path = parsed_uri.path.lstrip('//')
netloc = parsed_uri.netloc netloc = parsed_uri.netloc

View File

@ -65,11 +65,11 @@ class ChunkedFile(object):
class FilesystemBackend(glance.store.Backend): class FilesystemBackend(glance.store.Backend):
@classmethod @classmethod
def get(cls, parsed_uri, expected_size=None, options=None): def get(cls, parsed_uri, expected_size=None, options=None):
""" Filesystem-based backend """
Filesystem-based backend
file:///path/to/file.tar.gz.0 file:///path/to/file.tar.gz.0
""" """
filepath = parsed_uri.path filepath = parsed_uri.path
if not os.path.exists(filepath): if not os.path.exists(filepath):
raise exception.NotFound("Image file %s not found" % filepath) raise exception.NotFound("Image file %s not found" % filepath)

View File

@ -25,10 +25,10 @@ class HTTPBackend(glance.store.Backend):
@classmethod @classmethod
def get(cls, parsed_uri, expected_size, options=None, conn_class=None): def get(cls, parsed_uri, expected_size, options=None, conn_class=None):
"""Takes a parsed uri for an HTTP resource, fetches it, and yields the
data.
""" """
Takes a parsed uri for an HTTP resource, fetches it, and
yields the data.
"""
if conn_class: if conn_class:
pass # use the conn_class passed in pass # use the conn_class passed in
elif parsed_uri.scheme == "http": elif parsed_uri.scheme == "http":

View File

@ -32,9 +32,8 @@ logger = logging.getLogger('glance.store.swift')
class SwiftBackend(glance.store.Backend): class SwiftBackend(glance.store.Backend):
""" """An implementation of the swift backend adapter."""
An implementation of the swift backend adapter.
"""
EXAMPLE_URL = "swift://<USER>:<KEY>@<AUTH_ADDRESS>/<CONTAINER>/<FILE>" EXAMPLE_URL = "swift://<USER>:<KEY>@<AUTH_ADDRESS>/<CONTAINER>/<FILE>"
CHUNKSIZE = 65536 CHUNKSIZE = 65536

View File

@ -38,7 +38,8 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""Unittest runner for glance """
Unittest runner for glance
To run all test:: To run all test::
python run_tests.py python run_tests.py
@ -211,7 +212,8 @@ class GlanceTestResult(result.TextTestResult):
# NOTE(vish, tfukushima): copied from unittest with edit to add color # NOTE(vish, tfukushima): copied from unittest with edit to add color
def addError(self, test, err): def addError(self, test, err):
"""Overrides normal addError to add support for errorClasses. """
Overrides normal addError to add support for errorClasses.
If the exception is a registered class, the error will be added If the exception is a registered class, the error will be added
to the list for that class, not errors. to the list for that class, not errors.
""" """

View File

@ -40,7 +40,6 @@ class TestBinGlance(functional.FunctionalTest):
3. Delete the image 3. Delete the image
4. Verify no longer in index 4. Verify no longer in index
""" """
self.cleanup() self.cleanup()
self.start_servers() self.start_servers()
@ -106,7 +105,6 @@ class TestBinGlance(functional.FunctionalTest):
5. Update the image's Name attribute 5. Update the image's Name attribute
6. Verify the updated name is shown 6. Verify the updated name is shown
""" """
self.cleanup() self.cleanup()
self.start_servers() self.start_servers()
@ -192,7 +190,6 @@ class TestBinGlance(functional.FunctionalTest):
3. Verify the status of the image is displayed in the show output 3. Verify the status of the image is displayed in the show output
and is in status 'killed' and is in status 'killed'
""" """
self.cleanup() self.cleanup()
# Start servers with a Swift backend and a bad auth URL # Start servers with a Swift backend and a bad auth URL
@ -253,7 +250,6 @@ class TestBinGlance(functional.FunctionalTest):
3. Verify no public images found 3. Verify no public images found
4. Run SQL against DB to verify no undeleted properties 4. Run SQL against DB to verify no undeleted properties
""" """
self.cleanup() self.cleanup()
self.start_servers() self.start_servers()

View File

@ -63,7 +63,6 @@ class TestCurlApi(functional.FunctionalTest):
11. PUT /images/1 11. PUT /images/1
- Add a previously deleted property. - Add a previously deleted property.
""" """
self.cleanup() self.cleanup()
self.start_servers() self.start_servers()
@ -382,7 +381,6 @@ class TestCurlApi(functional.FunctionalTest):
6. GET /images 6. GET /images
- Verify one public image - Verify one public image
""" """
self.cleanup() self.cleanup()
self.start_servers() self.start_servers()
@ -502,7 +500,6 @@ class TestCurlApi(functional.FunctionalTest):
handled properly, and that usage of the Accept: header does handled properly, and that usage of the Accept: header does
content negotiation properly. content negotiation properly.
""" """
self.cleanup() self.cleanup()
self.start_servers() self.start_servers()
@ -693,7 +690,6 @@ class TestCurlApi(functional.FunctionalTest):
:see https://bugs.launchpad.net/glance/+bug/739433 :see https://bugs.launchpad.net/glance/+bug/739433
""" """
self.cleanup() self.cleanup()
self.start_servers() self.start_servers()
@ -760,7 +756,6 @@ class TestCurlApi(functional.FunctionalTest):
:see https://bugs.launchpad.net/glance/+bug/755912 :see https://bugs.launchpad.net/glance/+bug/755912
""" """
self.cleanup() self.cleanup()
self.start_servers() self.start_servers()

View File

@ -63,7 +63,6 @@ class TestApiHttplib2(functional.FunctionalTest):
11. PUT /images/1 11. PUT /images/1
- Add a previously deleted property. - Add a previously deleted property.
""" """
self.cleanup() self.cleanup()
self.start_servers() self.start_servers()

View File

@ -33,7 +33,6 @@ class TestLogging(functional.FunctionalTest):
Test logging output proper when verbose and debug Test logging output proper when verbose and debug
is on. is on.
""" """
self.cleanup() self.cleanup()
self.start_servers() self.start_servers()
@ -60,7 +59,6 @@ class TestLogging(functional.FunctionalTest):
Test logging output proper when verbose and debug Test logging output proper when verbose and debug
is off. is off.
""" """
self.cleanup() self.cleanup()
self.start_servers(debug=False, verbose=False) self.start_servers(debug=False, verbose=False)

View File

@ -39,7 +39,6 @@ class TestMiscellaneous(functional.FunctionalTest):
We also fire the glance-upload tool against the API server We also fire the glance-upload tool against the API server
and verify that glance-upload doesn't eat the exception either... and verify that glance-upload doesn't eat the exception either...
""" """
self.cleanup() self.cleanup()
self.start_servers() self.start_servers()

View File

@ -44,14 +44,14 @@ DEBUG = False
def stub_out_http_backend(stubs): def stub_out_http_backend(stubs):
"""Stubs out the httplib.HTTPRequest.getresponse to return """
Stubs out the httplib.HTTPRequest.getresponse to return
faked-out data instead of grabbing actual contents of a resource faked-out data instead of grabbing actual contents of a resource
The stubbed getresponse() returns an iterator over The stubbed getresponse() returns an iterator over
the data "I am a teapot, short and stout\n" the data "I am a teapot, short and stout\n"
:param stubs: Set of stubout stubs :param stubs: Set of stubout stubs
""" """
class FakeHTTPConnection(object): class FakeHTTPConnection(object):
@ -95,7 +95,6 @@ def stub_out_filesystem_backend():
//tmp/glance-tests/2 <-- file containing "chunk00000remainder" //tmp/glance-tests/2 <-- file containing "chunk00000remainder"
The stubbed service yields the data in the above files. The stubbed service yields the data in the above files.
""" """
# Establish a clean faked filesystem with dummy images # Establish a clean faked filesystem with dummy images
@ -109,13 +108,13 @@ def stub_out_filesystem_backend():
def stub_out_s3_backend(stubs): def stub_out_s3_backend(stubs):
""" Stubs out the S3 Backend with fake data and calls. """
Stubs out the S3 Backend with fake data and calls.
The stubbed s3 backend provides back an iterator over The stubbed s3 backend provides back an iterator over
the data "" the data ""
:param stubs: Set of stubout stubs :param stubs: Set of stubout stubs
""" """
class FakeSwiftAuth(object): class FakeSwiftAuth(object):
@ -262,7 +261,8 @@ def stub_out_registry_and_store_server(stubs):
def stub_out_registry_db_image_api(stubs): def stub_out_registry_db_image_api(stubs):
"""Stubs out the database set/fetch API calls for Registry """
Stubs out the database set/fetch API calls for Registry
so the calls are routed to an in-memory dict. This helps us so the calls are routed to an in-memory dict. This helps us
avoid having to manually clear or flush the SQLite database. avoid having to manually clear or flush the SQLite database.
@ -270,6 +270,7 @@ def stub_out_registry_db_image_api(stubs):
:param stubs: Set of stubout stubs :param stubs: Set of stubout stubs
""" """
class FakeDatastore(object): class FakeDatastore(object):
FIXTURES = [ FIXTURES = [

View File

@ -50,9 +50,9 @@ class TestRegistryAPI(unittest.TestCase):
self.stubs.UnsetAll() self.stubs.UnsetAll()
def test_get_root(self): def test_get_root(self):
"""Tests that the root registry API returns "index", """
Tests that the root registry API returns "index",
which is a list of public images which is a list of public images
""" """
fixture = {'id': 2, fixture = {'id': 2,
'name': 'fake image #2', 'name': 'fake image #2',
@ -70,9 +70,9 @@ class TestRegistryAPI(unittest.TestCase):
self.assertEquals(v, images[0][k]) self.assertEquals(v, images[0][k])
def test_get_index(self): def test_get_index(self):
"""Tests that the /images registry API returns list of """
Tests that the /images registry API returns list of
public images public images
""" """
fixture = {'id': 2, fixture = {'id': 2,
'name': 'fake image #2', 'name': 'fake image #2',
@ -90,11 +90,10 @@ class TestRegistryAPI(unittest.TestCase):
self.assertEquals(v, images[0][k]) self.assertEquals(v, images[0][k])
def test_get_index_marker(self): def test_get_index_marker(self):
"""Tests that the /images registry API returns list of
public images that conforms to a marker query param
""" """
Tests that the /images registry API returns list of
public images that conforms to a marker query param
"""
time1 = datetime.datetime.utcnow() + datetime.timedelta(seconds=5) time1 = datetime.datetime.utcnow() + datetime.timedelta(seconds=5)
time2 = datetime.datetime.utcnow() time2 = datetime.datetime.utcnow()
@ -148,9 +147,9 @@ class TestRegistryAPI(unittest.TestCase):
self.assertEquals(int(images[2]['id']), 2) self.assertEquals(int(images[2]['id']), 2)
def test_get_index_limit(self): def test_get_index_limit(self):
"""Tests that the /images registry API returns list of """
Tests that the /images registry API returns list of
public images that conforms to a limit query param public images that conforms to a limit query param
""" """
extra_fixture = {'id': 3, extra_fixture = {'id': 3,
'status': 'active', 'status': 'active',
@ -186,27 +185,27 @@ class TestRegistryAPI(unittest.TestCase):
self.assertTrue(int(images[0]['id']), 4) self.assertTrue(int(images[0]['id']), 4)
def test_get_index_limit_negative(self): def test_get_index_limit_negative(self):
"""Tests that the /images registry API returns list of """
Tests that the /images registry API returns list of
public images that conforms to a limit query param public images that conforms to a limit query param
""" """
req = webob.Request.blank('/images?limit=-1') req = webob.Request.blank('/images?limit=-1')
res = req.get_response(self.api) res = req.get_response(self.api)
self.assertEquals(res.status_int, 400) self.assertEquals(res.status_int, 400)
def test_get_index_limit_non_int(self): def test_get_index_limit_non_int(self):
"""Tests that the /images registry API returns list of """
Tests that the /images registry API returns list of
public images that conforms to a limit query param public images that conforms to a limit query param
""" """
req = webob.Request.blank('/images?limit=a') req = webob.Request.blank('/images?limit=a')
res = req.get_response(self.api) res = req.get_response(self.api)
self.assertEquals(res.status_int, 400) self.assertEquals(res.status_int, 400)
def test_get_index_limit_marker(self): def test_get_index_limit_marker(self):
"""Tests that the /images registry API returns list of """
Tests that the /images registry API returns list of
public images that conforms to limit and marker query params public images that conforms to limit and marker query params
""" """
extra_fixture = {'id': 3, extra_fixture = {'id': 3,
'status': 'active', 'status': 'active',
@ -242,10 +241,10 @@ class TestRegistryAPI(unittest.TestCase):
self.assertEqual(int(images[0]['id']), 2) self.assertEqual(int(images[0]['id']), 2)
def test_get_index_filter_name(self): def test_get_index_filter_name(self):
"""Tests that the /images registry API returns list of """
Tests that the /images registry API returns list of
public images that have a specific name. This is really a sanity public images that have a specific name. This is really a sanity
check, filtering is tested more in-depth using /images/detail check, filtering is tested more in-depth using /images/detail
""" """
fixture = {'id': 2, fixture = {'id': 2,
'name': 'fake image #2', 'name': 'fake image #2',
@ -678,9 +677,9 @@ class TestRegistryAPI(unittest.TestCase):
self.assertEquals(int(images[2]['id']), 2) self.assertEquals(int(images[2]['id']), 2)
def test_get_details(self): def test_get_details(self):
"""Tests that the /images/detail registry API returns """
Tests that the /images/detail registry API returns
a mapping containing a list of detailed image information a mapping containing a list of detailed image information
""" """
fixture = {'id': 2, fixture = {'id': 2,
'name': 'fake image #2', 'name': 'fake image #2',
@ -703,11 +702,11 @@ class TestRegistryAPI(unittest.TestCase):
self.assertEquals(v, images[0][k]) self.assertEquals(v, images[0][k])
def test_get_details_limit_marker(self): def test_get_details_limit_marker(self):
"""Tests that the /images/details registry API returns list of """
Tests that the /images/details registry API returns list of
public images that conforms to limit and marker query params. public images that conforms to limit and marker query params.
This functionality is tested more thoroughly on /images, this is This functionality is tested more thoroughly on /images, this is
just a sanity check just a sanity check
""" """
extra_fixture = {'id': 3, extra_fixture = {'id': 3,
'status': 'active', 'status': 'active',
@ -743,9 +742,9 @@ class TestRegistryAPI(unittest.TestCase):
self.assertEqual(int(images[0]['id']), 2) self.assertEqual(int(images[0]['id']), 2)
def test_get_details_filter_name(self): def test_get_details_filter_name(self):
"""Tests that the /images/detail registry API returns list of """
Tests that the /images/detail registry API returns list of
public images that have a specific name public images that have a specific name
""" """
extra_fixture = {'id': 3, extra_fixture = {'id': 3,
'status': 'active', 'status': 'active',
@ -781,9 +780,9 @@ class TestRegistryAPI(unittest.TestCase):
self.assertEqual('new name! #123', image['name']) self.assertEqual('new name! #123', image['name'])
def test_get_details_filter_status(self): def test_get_details_filter_status(self):
"""Tests that the /images/detail registry API returns list of """
Tests that the /images/detail registry API returns list of
public images that have a specific status public images that have a specific status
""" """
extra_fixture = {'id': 3, extra_fixture = {'id': 3,
'status': 'saving', 'status': 'saving',
@ -819,9 +818,9 @@ class TestRegistryAPI(unittest.TestCase):
self.assertEqual('saving', image['status']) self.assertEqual('saving', image['status'])
def test_get_details_filter_container_format(self): def test_get_details_filter_container_format(self):
"""Tests that the /images/detail registry API returns list of """
Tests that the /images/detail registry API returns list of
public images that have a specific container_format public images that have a specific container_format
""" """
extra_fixture = {'id': 3, extra_fixture = {'id': 3,
'status': 'active', 'status': 'active',
@ -857,9 +856,9 @@ class TestRegistryAPI(unittest.TestCase):
self.assertEqual('ovf', image['container_format']) self.assertEqual('ovf', image['container_format'])
def test_get_details_filter_disk_format(self): def test_get_details_filter_disk_format(self):
"""Tests that the /images/detail registry API returns list of """
Tests that the /images/detail registry API returns list of
public images that have a specific disk_format public images that have a specific disk_format
""" """
extra_fixture = {'id': 3, extra_fixture = {'id': 3,
'status': 'active', 'status': 'active',
@ -895,9 +894,9 @@ class TestRegistryAPI(unittest.TestCase):
self.assertEqual('vhd', image['disk_format']) self.assertEqual('vhd', image['disk_format'])
def test_get_details_filter_size_min(self): def test_get_details_filter_size_min(self):
"""Tests that the /images/detail registry API returns list of """
Tests that the /images/detail registry API returns list of
public images that have a size greater than or equal to size_min public images that have a size greater than or equal to size_min
""" """
extra_fixture = {'id': 3, extra_fixture = {'id': 3,
'status': 'active', 'status': 'active',
@ -933,9 +932,9 @@ class TestRegistryAPI(unittest.TestCase):
self.assertTrue(image['size'] >= 19) self.assertTrue(image['size'] >= 19)
def test_get_details_filter_size_max(self): def test_get_details_filter_size_max(self):
"""Tests that the /images/detail registry API returns list of """
Tests that the /images/detail registry API returns list of
public images that have a size less than or equal to size_max public images that have a size less than or equal to size_max
""" """
extra_fixture = {'id': 3, extra_fixture = {'id': 3,
'status': 'active', 'status': 'active',
@ -971,10 +970,10 @@ class TestRegistryAPI(unittest.TestCase):
self.assertTrue(image['size'] <= 19) self.assertTrue(image['size'] <= 19)
def test_get_details_filter_size_min_max(self): def test_get_details_filter_size_min_max(self):
"""Tests that the /images/detail registry API returns list of """
Tests that the /images/detail registry API returns list of
public images that have a size less than or equal to size_max public images that have a size less than or equal to size_max
and greater than or equal to size_min and greater than or equal to size_min
""" """
extra_fixture = {'id': 3, extra_fixture = {'id': 3,
'status': 'active', 'status': 'active',
@ -1021,9 +1020,9 @@ class TestRegistryAPI(unittest.TestCase):
self.assertTrue(image['size'] <= 19 and image['size'] >= 18) self.assertTrue(image['size'] <= 19 and image['size'] >= 18)
def test_get_details_filter_property(self): def test_get_details_filter_property(self):
"""Tests that the /images/detail registry API returns list of """
Tests that the /images/detail registry API returns list of
public images that have a specific custom property public images that have a specific custom property
""" """
extra_fixture = {'id': 3, extra_fixture = {'id': 3,
'status': 'active', 'status': 'active',
@ -1164,8 +1163,10 @@ class TestRegistryAPI(unittest.TestCase):
self.assertTrue('Invalid disk format' in res.body) self.assertTrue('Invalid disk format' in res.body)
def test_create_image_with_mismatched_formats(self): def test_create_image_with_mismatched_formats(self):
"""Tests that exception raised for bad matching disk and container """
formats""" Tests that exception raised for bad matching disk and
container formats
"""
fixture = {'name': 'fake public image #3', fixture = {'name': 'fake public image #3',
'container_format': 'aki', 'container_format': 'aki',
'disk_format': 'ari'} 'disk_format': 'ari'}
@ -1221,8 +1222,10 @@ class TestRegistryAPI(unittest.TestCase):
self.assertEquals(v, res_dict['image'][k]) self.assertEquals(v, res_dict['image'][k])
def test_update_image_not_existing(self): def test_update_image_not_existing(self):
"""Tests proper exception is raised if attempt to update non-existing """
image""" Tests proper exception is raised if attempt to update
non-existing image
"""
fixture = {'status': 'killed'} fixture = {'status': 'killed'}
req = webob.Request.blank('/images/3') req = webob.Request.blank('/images/3')
@ -1278,8 +1281,10 @@ class TestRegistryAPI(unittest.TestCase):
self.assertTrue('Invalid container format' in res.body) self.assertTrue('Invalid container format' in res.body)
def test_update_image_with_mismatched_formats(self): def test_update_image_with_mismatched_formats(self):
"""Tests that exception raised for bad matching disk and container """
formats""" Tests that exception raised for bad matching disk and
container formats
"""
fixture = {'container_format': 'ari'} fixture = {'container_format': 'ari'}
req = webob.Request.blank('/images/2') # Image 2 has disk format 'vhd' req = webob.Request.blank('/images/2') # Image 2 has disk format 'vhd'
@ -1323,9 +1328,10 @@ class TestRegistryAPI(unittest.TestCase):
self.assertEquals(new_num_images, orig_num_images - 1) self.assertEquals(new_num_images, orig_num_images - 1)
def test_delete_image_not_existing(self): def test_delete_image_not_existing(self):
"""Tests proper exception is raised if attempt to delete non-existing """
image""" Tests proper exception is raised if attempt to delete
non-existing image
"""
req = webob.Request.blank('/images/3') req = webob.Request.blank('/images/3')
req.method = 'DELETE' req.method = 'DELETE'

View File

@ -450,8 +450,10 @@ class TestRegistryClient(unittest.TestCase):
self.assertEquals(images[0]['id'], 2) self.assertEquals(images[0]['id'], 2)
def test_get_image_index_by_name(self): def test_get_image_index_by_name(self):
"""Test correct set of public, name-filtered image returned. This """
is just a sanity check, we test the details call more in-depth.""" Test correct set of public, name-filtered image returned. This
is just a sanity check, we test the details call more in-depth.
"""
extra_fixture = {'id': 3, extra_fixture = {'id': 3,
'status': 'active', 'status': 'active',
'is_public': True, 'is_public': True,
@ -712,7 +714,6 @@ class TestRegistryClient(unittest.TestCase):
def test_get_image_non_existing(self): def test_get_image_non_existing(self):
"""Tests that NotFound is raised when getting a non-existing image""" """Tests that NotFound is raised when getting a non-existing image"""
self.assertRaises(exception.NotFound, self.assertRaises(exception.NotFound,
self.client.get_image, self.client.get_image,
42) 42)
@ -826,7 +827,6 @@ class TestRegistryClient(unittest.TestCase):
def test_delete_image(self): def test_delete_image(self):
"""Tests that image metadata is deleted properly""" """Tests that image metadata is deleted properly"""
# Grab the original number of images # Grab the original number of images
orig_num_images = len(self.client.get_images()) orig_num_images = len(self.client.get_images())
@ -840,7 +840,6 @@ class TestRegistryClient(unittest.TestCase):
def test_delete_image_not_existing(self): def test_delete_image_not_existing(self):
"""Tests cannot delete non-existing image""" """Tests cannot delete non-existing image"""
self.assertRaises(exception.NotFound, self.assertRaises(exception.NotFound,
self.client.delete_image, self.client.delete_image,
3) 3)
@ -890,7 +889,6 @@ class TestClient(unittest.TestCase):
def test_get_image_not_existing(self): def test_get_image_not_existing(self):
"""Test retrieval of a non-existing image returns a 404""" """Test retrieval of a non-existing image returns a 404"""
self.assertRaises(exception.NotFound, self.assertRaises(exception.NotFound,
self.client.get_image, self.client.get_image,
3) 3)
@ -1207,7 +1205,6 @@ class TestClient(unittest.TestCase):
def test_get_image_non_existing(self): def test_get_image_non_existing(self):
"""Tests that NotFound is raised when getting a non-existing image""" """Tests that NotFound is raised when getting a non-existing image"""
self.assertRaises(exception.NotFound, self.assertRaises(exception.NotFound,
self.client.get_image, self.client.get_image,
42) 42)
@ -1301,9 +1298,11 @@ class TestClient(unittest.TestCase):
self.assertEquals('active', data['status']) self.assertEquals('active', data['status'])
def test_add_image_with_bad_iso_properties(self): def test_add_image_with_bad_iso_properties(self):
"""Verify that ISO with invalid container format is rejected. """
Verify that ISO with invalid container format is rejected.
Intended to exercise error path once rather than be exhaustive Intended to exercise error path once rather than be exhaustive
set of mismatches""" set of mismatches
"""
fixture = {'name': 'fake public iso', fixture = {'name': 'fake public iso',
'is_public': True, 'is_public': True,
'disk_format': 'iso', 'disk_format': 'iso',
@ -1486,7 +1485,6 @@ class TestClient(unittest.TestCase):
def test_delete_image(self): def test_delete_image(self):
"""Tests that image metadata is deleted properly""" """Tests that image metadata is deleted properly"""
# Grab the original number of images # Grab the original number of images
orig_num_images = len(self.client.get_images()) orig_num_images = len(self.client.get_images())
@ -1500,7 +1498,6 @@ class TestClient(unittest.TestCase):
def test_delete_image_not_existing(self): def test_delete_image_not_existing(self):
"""Tests cannot delete non-existing image""" """Tests cannot delete non-existing image"""
self.assertRaises(exception.NotFound, self.assertRaises(exception.NotFound,
self.client.delete_image, self.client.delete_image,
3) 3)

View File

@ -77,7 +77,8 @@ def check_dependencies():
def create_virtualenv(venv=VENV): def create_virtualenv(venv=VENV):
"""Creates the virtual environment and installs PIP only into the """
Creates the virtual environment and installs PIP only into the
virtual environment virtual environment
""" """
print 'Creating venv...', print 'Creating venv...',