client: use 12 character short IDs (#2862)

Use 12 characters for Docker resource IDs for
consistency with the Docker CLI.

Signed-off-by: Ben Fasoli <benfasoli@gmail.com>
This commit is contained in:
Ben Fasoli 2022-07-29 06:06:22 -07:00 коммит произвёл GitHub
Родитель ab43018b02
Коммит 23cf16f03a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 99 добавлений и 81 удалений

Просмотреть файл

@ -31,12 +31,12 @@ class Image(Model):
@property
def short_id(self):
"""
The ID of the image truncated to 10 characters, plus the ``sha256:``
The ID of the image truncated to 12 characters, plus the ``sha256:``
prefix.
"""
if self.id.startswith('sha256:'):
return self.id[:17]
return self.id[:10]
return self.id[:19]
return self.id[:12]
@property
def tags(self):
@ -141,10 +141,10 @@ class RegistryData(Model):
@property
def short_id(self):
"""
The ID of the image truncated to 10 characters, plus the ``sha256:``
The ID of the image truncated to 12 characters, plus the ``sha256:``
prefix.
"""
return self.id[:17]
return self.id[:19]
def pull(self, platform=None):
"""

Просмотреть файл

@ -35,9 +35,9 @@ class Model:
@property
def short_id(self):
"""
The ID of the object, truncated to 10 characters.
The ID of the object, truncated to 12 characters.
"""
return self.id[:10]
return self.id[:12]
def reload(self):
"""

Просмотреть файл

@ -24,7 +24,8 @@ class StartContainerTest(BaseAPIClientTest):
self.client.start(fake_api.FAKE_CONTAINER_ID)
args = fake_request.call_args
assert args[0][1] == url_prefix + 'containers/3cc2351ab11b/start'
assert args[0][1] == (url_prefix + 'containers/' +
fake_api.FAKE_CONTAINER_ID + '/start')
assert 'data' not in args[1]
assert args[1]['timeout'] == DEFAULT_TIMEOUT_SECONDS
@ -117,7 +118,8 @@ class StartContainerTest(BaseAPIClientTest):
self.client.start({'Id': fake_api.FAKE_CONTAINER_ID})
args = fake_request.call_args
assert args[0][1] == url_prefix + 'containers/3cc2351ab11b/start'
assert args[0][1] == (url_prefix + 'containers/' +
fake_api.FAKE_CONTAINER_ID + '/start')
assert 'data' not in args[1]
assert args[1]['timeout'] == DEFAULT_TIMEOUT_SECONDS
@ -1079,7 +1081,8 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'containers/3cc2351ab11b/resize',
(url_prefix + 'containers/' +
fake_api.FAKE_CONTAINER_ID + '/resize'),
params={'h': 15, 'w': 120},
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -1092,7 +1095,8 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'containers/3cc2351ab11b/rename',
(url_prefix + 'containers/' +
fake_api.FAKE_CONTAINER_ID + '/rename'),
params={'name': 'foobar'},
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -1102,7 +1106,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'containers/3cc2351ab11b/wait',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/wait',
timeout=None,
params={}
)
@ -1112,7 +1116,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'containers/3cc2351ab11b/wait',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/wait',
timeout=None,
params={}
)
@ -1124,7 +1128,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/logs',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
'tail': 'all'},
timeout=DEFAULT_TIMEOUT_SECONDS,
@ -1140,7 +1144,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/logs',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
'tail': 'all'},
timeout=DEFAULT_TIMEOUT_SECONDS,
@ -1157,7 +1161,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/logs',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
'tail': 'all'},
timeout=DEFAULT_TIMEOUT_SECONDS,
@ -1172,7 +1176,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/logs',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
params={'timestamps': 0, 'follow': 1, 'stderr': 1, 'stdout': 1,
'tail': 'all'},
timeout=DEFAULT_TIMEOUT_SECONDS,
@ -1186,7 +1190,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/logs',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
params={'timestamps': 0, 'follow': 1, 'stderr': 1, 'stdout': 1,
'tail': 'all'},
timeout=DEFAULT_TIMEOUT_SECONDS,
@ -1201,7 +1205,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/logs',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
params={'timestamps': 0, 'follow': 1, 'stderr': 1, 'stdout': 1,
'tail': 'all'},
timeout=DEFAULT_TIMEOUT_SECONDS,
@ -1217,7 +1221,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/logs',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
'tail': 10},
timeout=DEFAULT_TIMEOUT_SECONDS,
@ -1233,7 +1237,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/logs',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
'tail': 'all', 'since': ts},
timeout=DEFAULT_TIMEOUT_SECONDS,
@ -1250,7 +1254,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/logs',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
'tail': 'all', 'since': ts},
timeout=DEFAULT_TIMEOUT_SECONDS,
@ -1276,7 +1280,7 @@ class ContainerTest(BaseAPIClientTest):
assert m.called
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/logs',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
params={'timestamps': 0, 'follow': 1, 'stderr': 1, 'stdout': 1,
'tail': 'all'},
timeout=DEFAULT_TIMEOUT_SECONDS,
@ -1288,7 +1292,8 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/changes',
(url_prefix + 'containers/' +
fake_api.FAKE_CONTAINER_ID + '/changes'),
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -1297,7 +1302,8 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/changes',
(url_prefix + 'containers/' +
fake_api.FAKE_CONTAINER_ID + '/changes'),
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -1306,7 +1312,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/json',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/json',
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -1317,7 +1323,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'containers/3cc2351ab11b/stop',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/stop',
params={'t': timeout},
timeout=(DEFAULT_TIMEOUT_SECONDS + timeout)
)
@ -1330,7 +1336,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'containers/3cc2351ab11b/stop',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/stop',
params={'t': timeout},
timeout=(DEFAULT_TIMEOUT_SECONDS + timeout)
)
@ -1340,7 +1346,8 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'containers/3cc2351ab11b/pause',
(url_prefix + 'containers/' +
fake_api.FAKE_CONTAINER_ID + '/pause'),
timeout=(DEFAULT_TIMEOUT_SECONDS)
)
@ -1349,7 +1356,8 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'containers/3cc2351ab11b/unpause',
(url_prefix + 'containers/' +
fake_api.FAKE_CONTAINER_ID + '/unpause'),
timeout=(DEFAULT_TIMEOUT_SECONDS)
)
@ -1358,7 +1366,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'containers/3cc2351ab11b/kill',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/kill',
params={},
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -1368,7 +1376,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'containers/3cc2351ab11b/kill',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/kill',
params={},
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -1378,7 +1386,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'containers/3cc2351ab11b/kill',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/kill',
params={'signal': signal.SIGTERM},
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -1388,7 +1396,8 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'containers/3cc2351ab11b/restart',
(url_prefix + 'containers/' +
fake_api.FAKE_CONTAINER_ID + '/restart'),
params={'t': 2},
timeout=(DEFAULT_TIMEOUT_SECONDS + 2)
)
@ -1398,7 +1407,8 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'containers/3cc2351ab11b/restart',
(url_prefix + 'containers/' +
fake_api.FAKE_CONTAINER_ID + '/restart'),
params={'t': 2},
timeout=(DEFAULT_TIMEOUT_SECONDS + 2)
)
@ -1408,7 +1418,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'DELETE',
url_prefix + 'containers/3cc2351ab11b',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID,
params={'v': False, 'link': False, 'force': False},
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -1418,7 +1428,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'DELETE',
url_prefix + 'containers/3cc2351ab11b',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID,
params={'v': False, 'link': False, 'force': False},
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -1428,7 +1438,8 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/export',
(url_prefix + 'containers/' +
fake_api.FAKE_CONTAINER_ID + '/export'),
stream=True,
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -1438,7 +1449,8 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/export',
(url_prefix + 'containers/' +
fake_api.FAKE_CONTAINER_ID + '/export'),
stream=True,
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -1448,7 +1460,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/json',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/json',
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -1464,7 +1476,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/stats',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/stats',
timeout=60,
stream=True
)
@ -1474,7 +1486,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/top',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/top',
params={},
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -1484,7 +1496,7 @@ class ContainerTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'containers/3cc2351ab11b/top',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/top',
params={'ps_args': 'waux'},
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -1496,7 +1508,8 @@ class ContainerTest(BaseAPIClientTest):
blkio_weight=345
)
args = fake_request.call_args
assert args[0][1] == url_prefix + 'containers/3cc2351ab11b/update'
assert args[0][1] == (url_prefix + 'containers/' +
fake_api.FAKE_CONTAINER_ID + '/update')
assert json.loads(args[1]['data']) == {
'Memory': 2 * 1024, 'CpuShares': 124, 'BlkioWeight': 345
}

Просмотреть файл

@ -100,7 +100,7 @@ class ImageTest(BaseAPIClientTest):
'repo': None,
'comment': None,
'tag': None,
'container': '3cc2351ab11b',
'container': fake_api.FAKE_CONTAINER_ID,
'author': None,
'changes': None
},
@ -112,7 +112,7 @@ class ImageTest(BaseAPIClientTest):
fake_request.assert_called_with(
'DELETE',
url_prefix + 'images/e9aa60c60128',
url_prefix + 'images/' + fake_api.FAKE_IMAGE_ID,
params={'force': False, 'noprune': False},
timeout=DEFAULT_TIMEOUT_SECONDS
)
@ -287,7 +287,7 @@ class ImageTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'images/e9aa60c60128/tag',
url_prefix + 'images/' + fake_api.FAKE_IMAGE_ID + '/tag',
params={
'tag': None,
'repo': 'repo',
@ -305,7 +305,7 @@ class ImageTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'images/e9aa60c60128/tag',
url_prefix + 'images/' + fake_api.FAKE_IMAGE_ID + '/tag',
params={
'tag': 'tag',
'repo': 'repo',
@ -320,7 +320,7 @@ class ImageTest(BaseAPIClientTest):
fake_request.assert_called_with(
'POST',
url_prefix + 'images/e9aa60c60128/tag',
url_prefix + 'images/' + fake_api.FAKE_IMAGE_ID + '/tag',
params={
'tag': None,
'repo': 'repo',
@ -334,7 +334,7 @@ class ImageTest(BaseAPIClientTest):
fake_request.assert_called_with(
'GET',
url_prefix + 'images/e9aa60c60128/get',
url_prefix + 'images/' + fake_api.FAKE_IMAGE_ID + '/get',
stream=True,
timeout=DEFAULT_TIMEOUT_SECONDS
)

Просмотреть файл

@ -318,7 +318,7 @@ class DockerApiTest(BaseAPIClientTest):
fake_request.assert_called_with(
'DELETE',
url_prefix + 'containers/3cc2351ab11b',
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID,
params={'v': False, 'link': True, 'force': False},
timeout=DEFAULT_TIMEOUT_SECONDS
)

Просмотреть файл

@ -4,10 +4,10 @@ from . import fake_stat
CURRENT_VERSION = f'v{constants.DEFAULT_DOCKER_API_VERSION}'
FAKE_CONTAINER_ID = '3cc2351ab11b'
FAKE_IMAGE_ID = 'e9aa60c60128'
FAKE_EXEC_ID = 'd5d177f121dc'
FAKE_NETWORK_ID = '33fb6a3462b8'
FAKE_CONTAINER_ID = '81cf499cc928ce3fedc250a080d2b9b978df20e4517304c45211e8a68b33e254' # noqa: E501
FAKE_IMAGE_ID = 'sha256:fe7a8fc91d3f17835cbb3b86a1c60287500ab01a53bc79c4497d09f07a3f0688' # noqa: E501
FAKE_EXEC_ID = 'b098ec855f10434b5c7c973c78484208223a83f663ddaefb0f02a242840cb1c7' # noqa: E501
FAKE_NETWORK_ID = '1999cfb42e414483841a125ade3c276c3cb80cb3269b14e339354ac63a31b02c' # noqa: E501
FAKE_IMAGE_NAME = 'test_image'
FAKE_TARBALL_PATH = '/path/to/tarball'
FAKE_REPO_NAME = 'repo'
@ -546,56 +546,56 @@ fake_responses = {
post_fake_import_image,
f'{prefix}/{CURRENT_VERSION}/containers/json':
get_fake_containers,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/start':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/start':
post_fake_start_container,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/resize':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/resize':
post_fake_resize_container,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/json':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/json':
get_fake_inspect_container,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/rename':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/rename':
post_fake_rename_container,
f'{prefix}/{CURRENT_VERSION}/images/e9aa60c60128/tag':
f'{prefix}/{CURRENT_VERSION}/images/{FAKE_IMAGE_ID}/tag':
post_fake_tag_image,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/wait':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/wait':
get_fake_wait,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/logs':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/logs':
get_fake_logs,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/changes':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/changes':
get_fake_diff,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/export':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/export':
get_fake_export,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/update':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/update':
post_fake_update_container,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/exec':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/exec':
post_fake_exec_create,
f'{prefix}/{CURRENT_VERSION}/exec/d5d177f121dc/start':
f'{prefix}/{CURRENT_VERSION}/exec/{FAKE_EXEC_ID}/start':
post_fake_exec_start,
f'{prefix}/{CURRENT_VERSION}/exec/d5d177f121dc/json':
f'{prefix}/{CURRENT_VERSION}/exec/{FAKE_EXEC_ID}/json':
get_fake_exec_inspect,
f'{prefix}/{CURRENT_VERSION}/exec/d5d177f121dc/resize':
f'{prefix}/{CURRENT_VERSION}/exec/{FAKE_EXEC_ID}/resize':
post_fake_exec_resize,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/stats':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/stats':
get_fake_stats,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/top':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/top':
get_fake_top,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/stop':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/stop':
post_fake_stop_container,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/kill':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/kill':
post_fake_kill_container,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/pause':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/pause':
post_fake_pause_container,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/unpause':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/unpause':
post_fake_unpause_container,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/restart':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/restart':
post_fake_restart_container,
f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b':
f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}':
delete_fake_remove_container,
f'{prefix}/{CURRENT_VERSION}/images/create':
post_fake_image_create,
f'{prefix}/{CURRENT_VERSION}/images/e9aa60c60128':
f'{prefix}/{CURRENT_VERSION}/images/{FAKE_IMAGE_ID}':
delete_fake_remove_image,
f'{prefix}/{CURRENT_VERSION}/images/e9aa60c60128/get':
f'{prefix}/{CURRENT_VERSION}/images/{FAKE_IMAGE_ID}/get':
get_fake_get_image,
f'{prefix}/{CURRENT_VERSION}/images/load':
post_fake_load_image,

Просмотреть файл

@ -377,6 +377,11 @@ class ContainerCollectionTest(unittest.TestCase):
class ContainerTest(unittest.TestCase):
def test_short_id(self):
container = Container(attrs={'Id': '8497fe9244dd45cac543eb3c37d8605077'
'6800eebef1f3ec2ee111e8ccf12db6'})
assert container.short_id == '8497fe9244dd'
def test_name(self):
client = make_fake_client()
container = client.containers.get(FAKE_CONTAINER_ID)

Просмотреть файл

@ -122,11 +122,11 @@ class ImageTest(unittest.TestCase):
def test_short_id(self):
image = Image(attrs={'Id': 'sha256:b6846070672ce4e8f1f91564ea6782bd675'
'f69d65a6f73ef6262057ad0a15dcd'})
assert image.short_id == 'sha256:b684607067'
assert image.short_id == 'sha256:b6846070672c'
image = Image(attrs={'Id': 'b6846070672ce4e8f1f91564ea6782bd675'
'f69d65a6f73ef6262057ad0a15dcd'})
assert image.short_id == 'b684607067'
assert image.short_id == 'b6846070672c'
def test_tags(self):
image = Image(attrs={