本文整理汇总了Python中compose.Service.create_container方法的典型用法代码示例。如果您正苦于以下问题:Python Service.create_container方法的具体用法?Python Service.create_container怎么用?Python Service.create_container使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类compose.Service
的用法示例。
在下文中一共展示了Service.create_container方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_container_no_build
# 需要导入模块: from compose import Service [as 别名]
# 或者: from compose.Service import create_container [as 别名]
def test_create_container_no_build(self):
self.mock_client.images.return_value = []
service = Service('foo', client=self.mock_client, build='.')
service.create_container(do_build=False)
self.assertFalse(self.mock_client.images.called)
self.assertFalse(self.mock_client.build.called)
示例2: test_create_container_with_build
# 需要导入模块: from compose import Service [as 别名]
# 或者: from compose.Service import create_container [as 别名]
def test_create_container_with_build(self):
self.mock_client.images.return_value = []
service = Service('foo', client=self.mock_client, build='.')
service.build = mock.create_autospec(service.build)
service.create_container(do_build=True)
self.mock_client.images.assert_called_once_with(name=service.full_name)
service.build.assert_called_once_with()
示例3: test_create_container_latest_is_used_when_no_tag_specified
# 需要导入模块: from compose import Service [as 别名]
# 或者: from compose.Service import create_container [as 别名]
def test_create_container_latest_is_used_when_no_tag_specified(self, mock_container):
mock_container.create.side_effect = APIError(
"oops",
mock.Mock(status_code=404),
"No such image")
service = Service('foo', client=self.mock_client, image='someimage')
with self.assertRaises(APIError):
service.create_container()
self.mock_client.pull.assert_called_once_with(
'someimage',
tag='latest',
insecure_registry=False,
stream=True)
示例4: test_create_container_from_insecure_registry
# 需要导入模块: from compose import Service [as 别名]
# 或者: from compose.Service import create_container [as 别名]
def test_create_container_from_insecure_registry(
self,
mock_log,
mock_container):
service = Service('foo', client=self.mock_client, image='someimage:sometag')
mock_response = mock.Mock(Response)
mock_response.status_code = 404
mock_response.reason = "Not Found"
mock_container.create.side_effect = APIError(
'Mock error', mock_response, "No such image")
# We expect the APIError because our service requires a
# non-existent image.
with self.assertRaises(APIError):
service.create_container(insecure_registry=True)
self.mock_client.pull.assert_called_once_with(
'someimage:sometag',
insecure_registry=True,
stream=True)
mock_log.info.assert_called_once_with(
'Pulling image someimage:sometag...')
示例5: test_latest_is_used_when_tag_is_not_specified
# 需要导入模块: from compose import Service [as 别名]
# 或者: from compose.Service import create_container [as 别名]
def test_latest_is_used_when_tag_is_not_specified(self):
service = Service('foo', client=self.mock_client, image='someimage')
Container.create = mock.Mock()
service.create_container()
self.assertEqual(Container.create.call_args[1]['image'], 'someimage:latest')