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


Python Project.validate_credentials方法代码示例

本文整理汇总了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()
开发者ID:transifex,项目名称:transifex-client,代码行数:49,代码来源:test_project.py

示例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()
开发者ID:transifex,项目名称:transifex-client,代码行数:19,代码来源:test_project.py


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