本文整理汇总了Python中txclib.project.Project.validate_credentials方法的典型用法代码示例。如果您正苦于以下问题:Python Project.validate_credentials方法的具体用法?Python Project.validate_credentials怎么用?Python Project.validate_credentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txclib.project.Project
的用法示例。
在下文中一共展示了Project.validate_credentials方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getset_host_credentials_update_transifexrc
# 需要导入模块: from txclib.project import Project [as 别名]
# 或者: from txclib.project.Project import validate_credentials [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()
示例2: test_getset_host_credentials_no_transifexrc
# 需要导入模块: from txclib.project import Project [as 别名]
# 或者: from txclib.project.Project import validate_credentials [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()