本文整理汇总了Python中subscription_manager.managercli.RegisterCommand._get_environment_id方法的典型用法代码示例。如果您正苦于以下问题:Python RegisterCommand._get_environment_id方法的具体用法?Python RegisterCommand._get_environment_id怎么用?Python RegisterCommand._get_environment_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subscription_manager.managercli.RegisterCommand
的用法示例。
在下文中一共展示了RegisterCommand._get_environment_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_environment_id_multi_available_bad_name
# 需要导入模块: from subscription_manager.managercli import RegisterCommand [as 别名]
# 或者: from subscription_manager.managercli.RegisterCommand import _get_environment_id [as 别名]
def test_get_environment_id_multi_available_bad_name(self):
def env_list(*args, **kwargs):
return [{"id": "1234", "name": "somename"},
{"id": "5678", "name": "othername"}]
with patch('rhsm.connection.UEPConnection', new_callable=StubUEP) as mock_uep:
mock_uep.getEnvironmentList = env_list
mock_uep.supports_resource = Mock(return_value=True)
self.stub_cp_provider.basic_auth_cp = mock_uep
rc = RegisterCommand()
rc.options = Mock()
rc.options.activation_keys = None
rc._prompt_for_environment = Mock(return_value="not_an_env")
with nested(Capture(silent=True), self.assertRaises(SystemExit)):
rc._get_environment_id(mock_uep, 'owner', None)
示例2: test_get_environment_id_multi_available_bad_name
# 需要导入模块: from subscription_manager.managercli import RegisterCommand [as 别名]
# 或者: from subscription_manager.managercli.RegisterCommand import _get_environment_id [as 别名]
def test_get_environment_id_multi_available_bad_name(self, mock_sys_exit):
def env_list(*args, **kwargs):
return [{"id": "1234", "name": "somename"}, {"id": "5678", "name": "othername"}]
# Avoid writing to stderr
mock_sys_exit.side_effect = SystemExit(-1)
StubUEP.getEnvironmentList = env_list
cp = StubUEP()
cp.supports_resource = Mock(return_value=True)
rc = RegisterCommand()
rc.options = Mock()
rc.options.activation_keys = None
rc._prompt_for_environment = Mock(return_value="not_an_env")
try:
rc._get_environment_id(cp, "owner", None)
self.fail("No Exception Raised")
except SystemExit:
pass
示例3: test_get_environment_id_one_available
# 需要导入模块: from subscription_manager.managercli import RegisterCommand [as 别名]
# 或者: from subscription_manager.managercli.RegisterCommand import _get_environment_id [as 别名]
def test_get_environment_id_one_available(self):
def env_list(*args, **kwargs):
return [{"id": "1234", "name": "somename"}]
StubUEP.getEnvironmentList = env_list
cp = StubUEP()
cp.supports_resource = Mock(return_value=True)
rc = RegisterCommand()
rc.options = Mock()
rc.options.activation_keys = None
env_id = rc._get_environment_id(cp, "owner", None)
expected = "1234"
self.assertEquals(expected, env_id)
示例4: test_get_environment_id_one_available
# 需要导入模块: from subscription_manager.managercli import RegisterCommand [as 别名]
# 或者: from subscription_manager.managercli.RegisterCommand import _get_environment_id [as 别名]
def test_get_environment_id_one_available(self):
def env_list(*args, **kwargs):
return [{"id": "1234", "name": "somename"}]
with patch('rhsm.connection.UEPConnection', new_callable=StubUEP) as mock_uep:
mock_uep.getEnvironmentList = env_list
mock_uep.supports_resource = Mock(return_value=True)
self.stub_cp_provider.basic_auth_cp = mock_uep
rc = RegisterCommand()
rc.options = Mock()
rc.options.activation_keys = None
env_id = rc._get_environment_id(mock_uep, 'owner', None)
expected = "1234"
self.assertEquals(expected, env_id)