当前位置: 首页>>代码示例>>Python>>正文


Python Service.create_container方法代码示例

本文整理汇总了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)
开发者ID:Jasperswaagman,项目名称:compose,代码行数:9,代码来源:service_test.py

示例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()
开发者ID:Jasperswaagman,项目名称:compose,代码行数:10,代码来源:service_test.py

示例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)
开发者ID:CSWANG,项目名称:compose,代码行数:15,代码来源:service_test.py

示例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...')
开发者ID:Jasperswaagman,项目名称:compose,代码行数:24,代码来源:service_test.py

示例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')
开发者ID:Jasperswaagman,项目名称:compose,代码行数:7,代码来源:service_test.py


注:本文中的compose.Service.create_container方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。