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


Python Bigtop.render_hiera_yaml方法代码示例

本文整理汇总了Python中charms.layer.apache_bigtop_base.Bigtop.render_hiera_yaml方法的典型用法代码示例。如果您正苦于以下问题:Python Bigtop.render_hiera_yaml方法的具体用法?Python Bigtop.render_hiera_yaml怎么用?Python Bigtop.render_hiera_yaml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在charms.layer.apache_bigtop_base.Bigtop的用法示例。


在下文中一共展示了Bigtop.render_hiera_yaml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestBigtopUnit

# 需要导入模块: from charms.layer.apache_bigtop_base import Bigtop [as 别名]
# 或者: from charms.layer.apache_bigtop_base.Bigtop import render_hiera_yaml [as 别名]
class TestBigtopUnit(Harness):
    '''
    Unit tests for Bigtop class.

    '''

    @mock.patch('charms.layer.apache_bigtop_base.hookenv')
    @mock.patch('charms.layer.apache_bigtop_base.Bigtop.bigtop_version',
                new_callable=mock.PropertyMock)
    def setUp(self, mock_ver, mock_hookenv):
        mock_ver.return_value = '1.2.0'
        super(TestBigtopUnit, self).setUp()
        self.bigtop = Bigtop()

    def test_init(self):
        '''
        Verify that the Bigtop class can init itself, and that it has some
        of the properties that we expect..

        '''
        # paths should be Path objects.
        self.assertEqual(type(self.bigtop.bigtop_base), Path)
        self.assertEqual(type(self.bigtop.site_yaml), Path)

    @mock.patch('charms.layer.apache_bigtop_base.Bigtop.render_hiera_yaml')
    @mock.patch('charms.layer.apache_bigtop_base.Bigtop.apply_patches')
    @mock.patch('charms.layer.apache_bigtop_base.Bigtop.install_puppet_modules')
    @mock.patch('charms.layer.apache_bigtop_base.Bigtop.fetch_bigtop_release')
    @mock.patch('charms.layer.apache_bigtop_base.Bigtop.check_reverse_dns')
    @mock.patch('charms.layer.apache_bigtop_base.Bigtop.check_localdomain')
    @mock.patch('charms.layer.apache_bigtop_base.Bigtop.pin_bigtop_packages')
    @mock.patch('charms.layer.apache_bigtop_base.Bigtop.install_java')
    @mock.patch('charms.layer.apache_bigtop_base.Bigtop.install_swap')
    @mock.patch('charms.layer.apache_bigtop_base.is_container')
    def test_install(self, mock_container, mock_swap, mock_java, mock_pin,
                     mock_local, mock_dns, mock_fetch, mock_puppet, mock_apply,
                     mock_hiera):
        '''
        Verify install calls expected class methods.

        '''
        mock_container.return_value = False
        self.bigtop.install()
        self.assertTrue(mock_swap.called)
        self.assertTrue(mock_java.called)
        self.assertTrue(mock_pin.called)
        self.assertTrue(mock_local.called)
        self.assertTrue(mock_dns.called)
        self.assertTrue(mock_fetch.called)
        self.assertTrue(mock_puppet.called)
        self.assertTrue(mock_apply.called)
        self.assertTrue(mock_hiera.called)

    @mock.patch('charms.layer.apache_bigtop_base.Bigtop.update_bigtop_repo')
    @mock.patch('charms.layer.apache_bigtop_base.Bigtop.apply_patches')
    @mock.patch('charms.layer.apache_bigtop_base.Bigtop.fetch_bigtop_release')
    @mock.patch('charms.layer.apache_bigtop_base.Bigtop.pin_bigtop_packages')
    def test_refresh_bigtop_release(self, mock_pin, mock_fetch, mock_apply,
                                    mock_update):
        '''
        Verify refresh calls expected class methods.

        '''
        self.bigtop.refresh_bigtop_release()
        self.assertTrue(mock_pin.called)
        self.assertTrue(mock_fetch.called)
        self.assertTrue(mock_apply.called)
        self.assertTrue(mock_update.called)

    @mock.patch('charms.layer.apache_bigtop_base.hookenv')
    @mock.patch('charms.layer.apache_bigtop_base.utils')
    @mock.patch('charms.layer.apache_bigtop_base.lsb_release')
    @mock.patch('charms.layer.apache_bigtop_base.Bigtop.bigtop_version',
                new_callable=mock.PropertyMock)
    def test_get_repo_url(self, mock_ver, mock_lsb_release,
                          mock_utils, mock_hookenv):
        '''
        Verify that we setup an appropriate repository.

        '''
        mock_ver.return_value = '1.1.0'

        # non-ubuntu should throw an exception
        mock_lsb_release.return_value = {'DISTRIB_ID': 'centos'}
        self.assertRaises(
            BigtopError,
            self.bigtop.get_repo_url,
            '1.1.0')

        # 1.1.0 on trusty/non-power
        mock_utils.cpu_arch.return_value = 'foo'
        mock_lsb_release.return_value = {'DISTRIB_ID': 'ubuntu'}
        self.assertEqual(self.bigtop.get_repo_url('1.1.0'),
                         ('http://bigtop-repos.s3.amazonaws.com/releases/'
                          '1.1.0/ubuntu/trusty/foo'))

        # 1.1.0 on trusty/power (should return vivid url)
        mock_utils.cpu_arch.return_value = 'ppc64le'
        self.assertEqual(self.bigtop.get_repo_url('1.1.0'),
                         ('http://bigtop-repos.s3.amazonaws.com/releases/'
#.........这里部分代码省略.........
开发者ID:juju-solutions,项目名称:layer-apache-bigtop-base,代码行数:103,代码来源:test_bigtop.py


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