當前位置: 首頁>>代碼示例>>Python>>正文


Python base.Base類代碼示例

本文整理匯總了Python中robottelo.cli.base.Base的典型用法代碼示例。如果您正苦於以下問題:Python Base類的具體用法?Python Base怎麽用?Python Base使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Base類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_handle_response_success

 def test_handle_response_success(self):
     """Check handle_response returns stdout when the is no problem on ssh
     execution
     """
     base = Base()
     response = mock.Mock()
     response.return_code = 0
     response.stderr = []
     self.assertEqual(response.stdout, base._handle_response(response))
開發者ID:Ichimonji10,項目名稱:robottelo,代碼行數:9,代碼來源:test_cli.py

示例2: test_with_user

    def test_with_user(self):
        """Check if ``with_user`` method returns a right wrapper class"""
        new_class = Base.with_user('auser', 'apass')

        self.assertEqual(new_class.foreman_admin_username, 'auser')
        self.assertEqual(new_class.foreman_admin_password, 'apass')
        self.assertIn(Base, new_class.__bases__)
開發者ID:oshtaier,項目名稱:robottelo,代碼行數:7,代碼來源:test_cli.py

示例3: test_exists_with_option_and_no_empty_return

 def test_exists_with_option_and_no_empty_return(self, lst_method):
     """Check exists method with options and no empty return"""
     lst_method.return_value = [1, 2]
     my_options = {u'search': u'foo=bar'}
     response = Base.exists(my_options, search=['id', 1])
     lst_method.assert_called_once_with(my_options)
     self.assertEqual(1, response)
開發者ID:BlackSmith,項目名稱:robottelo,代碼行數:7,代碼來源:test_cli.py

示例4: test_username_password_config_lookup

    def test_username_password_config_lookup(self, settings):
        """Username and password returned are from configuration"""
        settings.server.admin_username = 'alice'
        settings.server.admin_password = 'hackme'
        username, password = Base._get_username_password()

        self.assertEqual(username, settings.server.admin_username)
        self.assertEqual(password, settings.server.admin_password)
開發者ID:Ichimonji10,項目名稱:robottelo,代碼行數:8,代碼來源:test_cli.py

示例5: test_list_with_default_per_page

 def test_list_with_default_per_page(self, construct, execute):
     """Check list method set per_page as 1000 by default"""
     self.assertEquals(
         execute.return_value,
         Base.list(options={'organization-id': 1})
     )
     self.assertEqual('list', Base.command_sub)
     construct.called_once_with({'per-page': 1000})
     execute.called_once_with(construct.return_value, output_format='csv')
開發者ID:BlackSmith,項目名稱:robottelo,代碼行數:9,代碼來源:test_cli.py

示例6: test_add_create_with_empty_result

 def test_add_create_with_empty_result(self, construct, execute):
     """Check command create when result is empty"""
     execute.return_value = []
     self.assertEqual(
         execute.return_value,
         Base.create()
     )
     self.assertEqual('create', Base.command_sub)
     construct.called_once_with({})
     execute.called_once_with(construct.return_value, output_format='csv')
開發者ID:Ichimonji10,項目名稱:robottelo,代碼行數:10,代碼來源:test_cli.py

示例7: test_handle_response_logging_when_stderr_not_empty

 def test_handle_response_logging_when_stderr_not_empty(self, warning):
     """Check handle_response log stderr when it is not empty"""
     base = Base()
     response = mock.Mock()
     response.return_code = 0
     response.stderr = [u'not empty']
     self.assertEqual(response.stdout, base._handle_response(response))
     warning.assert_called_once_with(
         u'stderr contains following message:\n{}'.format(response.stderr)
     )
     warning.reset_mock()
     self.assertEqual(
         response.stdout,
         base._handle_response(response, True)
     )
     self.assertFalse(
         warning.called,
         u'Should not be called when ignore_stderr is True'
     )
開發者ID:Ichimonji10,項目名稱:robottelo,代碼行數:19,代碼來源:test_cli.py

示例8: test_add_operating_system

 def test_add_operating_system(self, construct, execute):
     """Check command_sub edited when executing add_operating_system"""
     options = {u'foo': u'bar'}
     self.assertNotEqual('add-operatingsystem', Base.command_sub)
     self.assertEqual(
         execute.return_value,
         Base.add_operating_system(options)
     )
     self.assertEqual('add-operatingsystem', Base.command_sub)
     construct.called_once_with(options)
     execute.called_once_with(construct.return_value)
開發者ID:Ichimonji10,項目名稱:robottelo,代碼行數:11,代碼來源:test_cli.py

示例9: test_add_create_with_result_dct_without_id

 def test_add_create_with_result_dct_without_id(
         self, construct, execute, info):
     """Check command create when result has dct but dct hasn't id key"""
     execute.return_value = [{'not_id': 'foo'}]
     self.assertEqual(
         execute.return_value,
         Base.create()
     )
     self.assertEqual('create', Base.command_sub)
     construct.called_once_with({})
     execute.called_once_with(construct.return_value, output_format='csv')
     self.assertFalse(info.called)
開發者ID:Ichimonji10,項目名稱:robottelo,代碼行數:12,代碼來源:test_cli.py

示例10: test_add_create_with_result_dct_with_id_required_org

 def test_add_create_with_result_dct_with_id_required_org(
         self, construct, execute, info):
     """Check command create when result has dct id key and organization
     is required
     """
     execute.return_value = [{'id': 'foo', 'bar': 'bas'}]
     Base.command_requires_org = True
     self.assertEqual(
         execute.return_value,
         Base.create({'organization-id': 'org-id'})
     )
     self.assertEqual('create', Base.command_sub)
     construct.called_once_with({})
     execute.called_once_with(construct.return_value, output_format='csv')
     info.called_once_with({'id': 'foo', 'organization-id': 'org-id'})
開發者ID:Ichimonji10,項目名稱:robottelo,代碼行數:15,代碼來源:test_cli.py

示例11: test_execute_with_raw_response

 def test_execute_with_raw_response(self, settings, command):
     """Check excuted build ssh method and returns raw response"""
     settings.locale = 'en_US'
     settings.performance = False
     settings.server.admin_username = 'admin'
     settings.server.admin_password = 'password'
     response = Base.execute('some_cmd', return_raw_response=True)
     ssh_cmd = u'LANG=en_US  hammer -v -u admin -p password  some_cmd'
     command.assert_called_once_with(
         ssh_cmd.encode('utf-8'),
         output_format=None,
         timeout=None,
         connection_timeout=None
     )
     self.assertIs(response, command.return_value)
開發者ID:BlackSmith,項目名稱:robottelo,代碼行數:15,代碼來源:test_cli.py

示例12: test_construct_command

    def test_construct_command(self):
        """_construct_command builds a command using flags and arguments"""
        Base.command_base = 'basecommand'
        Base.command_sub = 'subcommand'
        command_parts = Base._construct_command({
            u'flag-one': True,
            u'flag-two': False,
            u'argument': u'value',
            u'ommited-arg': None,
        }).split()

        self.assertIn(u'basecommand', command_parts)
        self.assertIn(u'subcommand', command_parts)
        self.assertIn(u'--flag-one', command_parts)
        self.assertIn(u'--argument="value"', command_parts)
        self.assertNotIn(u'--flag-two', command_parts)
        self.assertEqual(len(command_parts), 4)
開發者ID:oshtaier,項目名稱:robottelo,代碼行數:17,代碼來源:test_cli.py

示例13: test_execute_with_performance

 def test_execute_with_performance(self, settings, command, handle_resp):
     """Check excuted build ssh method and delegate response handling"""
     settings.locale = 'en_US'
     settings.performance.timer_hammer = True
     settings.server.admin_username = 'admin'
     settings.server.admin_password = 'password'
     response = Base.execute('some_cmd', output_format='json')
     ssh_cmd = (
         u'LANG=en_US time -p hammer -v -u admin -p password --output=json'
         u' some_cmd'
     )
     command.assert_called_once_with(
         ssh_cmd.encode('utf-8'),
         output_format='json',
         timeout=None,
         connection_timeout=None
     )
     handle_resp.assert_called_once_with(
         command.return_value,
         ignore_stderr=None
     )
     self.assertIs(response, handle_resp.return_value)
開發者ID:BlackSmith,項目名稱:robottelo,代碼行數:22,代碼來源:test_cli.py

示例14: test_username_password_config_lookup

    def test_username_password_config_lookup(self):
        """Username and password returned are from configuration"""
        username, password = Base._get_username_password()

        self.assertEqual(username, conf.properties['foreman.admin.username'])
        self.assertEqual(password, conf.properties['foreman.admin.password'])
開發者ID:oshtaier,項目名稱:robottelo,代碼行數:6,代碼來源:test_cli.py

示例15: __init__

 def __init__(self):
     """
     Sets the base command for class.
     """
     Base.__init__(self)
     self.command_base = "host"
開發者ID:pavelpromin,項目名稱:robottelo,代碼行數:6,代碼來源:host.py


注:本文中的robottelo.cli.base.Base類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。