本文整理汇总了Python中txclib.project.Project.txrc_file方法的典型用法代码示例。如果您正苦于以下问题:Python Project.txrc_file方法的具体用法?Python Project.txrc_file怎么用?Python Project.txrc_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txclib.project.Project
的用法示例。
在下文中一共展示了Project.txrc_file方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getset_host_credentials_env_variable_first_time
# 需要导入模块: from txclib.project import Project [as 别名]
# 或者: from txclib.project.Project import txrc_file [as 别名]
def test_getset_host_credentials_env_variable_first_time(
self, m_parser, m_input):
p = Project(init=False)
p.txrc = m_parser
p.save = Mock()
p.txrc_file = '/tmp'
p.txrc.has_section.side_effect = [False]
username, password = p.getset_host_credentials('test')
self.assertEqual(username, 'api')
self.assertEqual(password, 'environment_value')
# ensure that we have set host in the txrc_file, even though TX_TOKEN
# exists
self.assertEqual(p.txrc.set.call_count, 2)
p.save.assert_called()
示例2: test_getset_host_credentials_env_variable
# 需要导入模块: from txclib.project import Project [as 别名]
# 或者: from txclib.project.Project import txrc_file [as 别名]
def test_getset_host_credentials_env_variable(
self, m_parser, m_input):
p = Project(init=False)
p.txrc = m_parser
p.save = Mock()
p.txrc_file = '/tmp'
p.txrc.has_section.side_effect = [False]
username, password = p.getset_host_credentials('test')
self.assertEqual(username, 'api')
self.assertEqual(password, 'environment_value')
self.assertEqual(p.txrc.set.call_count, 2)
# no input will be asked, password will be used by environment variable
self.assertEqual(m_input.call_count, 0)
p.save.assert_called()
示例3: test_getset_host_credentials_both_token_and_env
# 需要导入模块: from txclib.project import Project [as 别名]
# 或者: from txclib.project.Project import txrc_file [as 别名]
def test_getset_host_credentials_both_token_and_env(
self, m_logger, m_parser):
p = Project(init=False)
p.txrc = m_parser
p.save = Mock()
p.txrc_file = '/tmp'
p.txrc.has_section.side_effect = [False]
username, password = p.getset_host_credentials('test', token='demo')
self.assertEqual(username, 'api')
self.assertEqual(password, 'environment_value')
# ensure that we did not make additional calls to set the token in the
# txrc file
self.assertEqual(p.txrc.set.call_count, 2)
p.save.assert_called()
self.assertEqual(m_logger.warning.call_count, 1)
示例4: test_getset_host_credentials_update_transifexrc
# 需要导入模块: from txclib.project import Project [as 别名]
# 或者: from txclib.project.Project import txrc_file [as 别名]
def test_getset_host_credentials_update_transifexrc(
self, m_parser, m_input):
p = Project(init=False)
dummy_token = 'salala'
p.txrc = m_parser
p.save = Mock()
p.txrc_file = '/tmp'
p.validate_credentials = Mock(return_value=True)
p.txrc.get.side_effect = [
'foo', 'bar'
]
# transifexrc does not get updated if credentials are the same
username, password = p.getset_host_credentials(
'test', username='foo', password='bar'
)
self.assertEqual(username, 'foo')
self.assertEqual(password, 'bar')
self.assertEqual(p.txrc.set.call_count, 0)
self.assertEqual(m_input.call_count, 0)
self.assertEqual(p.save.call_count, 0)
# transifexrc is not updated if confirm is no
p.txrc.get.side_effect = [
'foo', 'bar'
]
m_input.return_value = False
username, password = p.getset_host_credentials('test',
token=dummy_token)
self.assertEqual(username, 'api')
self.assertEqual(password, dummy_token)
self.assertEqual(p.txrc.set.call_count, 0)
self.assertEqual(m_input.call_count, 1)
self.assertEqual(p.save.call_count, 0)
# transifexrc is not updated if confirm is yes
p.txrc.get.side_effect = [
'foo', 'bar'
]
m_input.return_value = True
m_input.reset_mock()
username, password = p.getset_host_credentials('test',
token=dummy_token)
self.assertEqual(username, 'api')
self.assertEqual(password, dummy_token)
self.assertEqual(p.txrc.set.call_count, 2)
self.assertEqual(m_input.call_count, 1)
p.save.assert_called()
示例5: test_getset_host_credentials_no_transifexrc
# 需要导入模块: from txclib.project import Project [as 别名]
# 或者: from txclib.project.Project import txrc_file [as 别名]
def test_getset_host_credentials_no_transifexrc(
self, m_parser, m_input):
p = Project(init=False)
# let suppose a token has been set at the config
dummy_token = 'salala'
p.txrc = m_parser
p.save = Mock()
p.validate_credentials = Mock(return_value=True)
p.txrc_file = '/tmp'
p.txrc.get.side_effect = configparser.NoSectionError('test')
m_input.return_value = dummy_token
username, password = p.getset_host_credentials('test')
self.assertEqual(username, 'api')
self.assertEqual(password, dummy_token)
self.assertEqual(p.txrc.set.call_count, 2)
self.assertEqual(m_input.call_count, 1)
p.save.assert_called()
示例6: test_getset_host_credentials
# 需要导入模块: from txclib.project import Project [as 别名]
# 或者: from txclib.project.Project import txrc_file [as 别名]
def test_getset_host_credentials(self, m_parser):
p = Project(init=False)
# let suppose a token has been set at the config
dummy_token = 'salala'
p.txrc = m_parser
p.txrc.add_section = Mock()
p.txrc.set = Mock()
p.txrc.get = Mock()
p.txrc.get.side_effect = ['api', dummy_token, None, None]
p.txrc_file = '/tmp'
username, password = p.getset_host_credentials('test')
self.assertEqual(username, 'api')
self.assertEqual(password, dummy_token)
# let's try to get credentials for someone without
# a token
p.txrc.get.side_effect = [
'username',
'passw0rdz'
]
username, password = p.getset_host_credentials('test')
self.assertEqual(username, 'username')
self.assertEqual(password, 'passw0rdz')