Merge pull request #3059 from quay/joseph.schorr/QUAY-906/reg-tests

Move registry integration tests to py.test
This commit is contained in:
Joseph Schorr 2018-05-22 17:09:11 -04:00 committed by GitHub
commit 6ffafe44d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 2149 additions and 204 deletions

View file

@ -17,9 +17,9 @@ class ExpiresEntry(object):
class ExpiresDict(object):
""" ExpiresDict defines a dictionary-like class whose keys have expiration. The rebuilder is
a function that returns the full contents of the cached dictionary as a dict of the keys
and whose values are TTLEntry's.
and whose values are TTLEntry's. If the rebuilder is None, then no rebuilding is performed.
"""
def __init__(self, rebuilder):
def __init__(self, rebuilder=None):
self._rebuilder = rebuilder
self._items = {}
@ -49,6 +49,9 @@ class ExpiresDict(object):
return self.get(key) is not None
def _rebuild(self):
if self._rebuilder is None:
return self._items
items = self._rebuilder()
self._items = items
return items

View file

@ -14,6 +14,13 @@ TAG_REGEX = re.compile(FULL_TAG_PATTERN)
TAG_ERROR = ('Invalid tag: must match [A-Za-z0-9_.-], NOT start with "." or "-", '
'and can contain 1-128 characters')
class ImplicitLibraryNamespaceNotAllowed(Exception):
""" Exception raised if the implicit library namespace was specified but is
not allowed. """
pass
def escape_tag(tag, default='latest'):
""" Escapes a Docker tag, ensuring it matches the tag regular expression. """
if not tag:
@ -24,13 +31,16 @@ def escape_tag(tag, default='latest'):
return tag[0:127]
def parse_namespace_repository(repository, library_namespace, include_tag=False):
def parse_namespace_repository(repository, library_namespace, include_tag=False,
allow_library=True):
repository = repository.encode('unidecode', 'ignore')
parts = repository.rstrip('/').split('/', 1)
if len(parts) < 2:
namespace = library_namespace
repository = parts[0]
if not allow_library:
raise ImplicitLibraryNamespaceNotAllowed()
else:
(namespace, repository) = parts