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


Python Project._get_url_by_pull_mode方法代码示例

本文整理汇总了Python中txclib.project.Project._get_url_by_pull_mode方法的典型用法代码示例。如果您正苦于以下问题:Python Project._get_url_by_pull_mode方法的具体用法?Python Project._get_url_by_pull_mode怎么用?Python Project._get_url_by_pull_mode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在txclib.project.Project的用法示例。


在下文中一共展示了Project._get_url_by_pull_mode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestProjectPull

# 需要导入模块: from txclib.project import Project [as 别名]
# 或者: from txclib.project.Project import _get_url_by_pull_mode [as 别名]

#.........这里部分代码省略.........
            self.assertEqual(new, set(['el', ]))

            mock.return_value = False
            res = self.p._languages_to_pull(
                languages, self.files, self.lang_map, self.stats, force
            )
            existing = res[0]
            new = res[1]
            self.assertEqual(existing, set(['en', ]))
            self.assertEqual(new, set([]))

    def test_in_combination_with_force_option(self):
        """Test the minimum-perc option along with -f."""
        with patch.object(self.p, 'get_resource_option') as mock:
            mock.return_value = 70

            res = self.p._should_download('de', self.stats, None, False)
            self.assertEqual(res, False)
            res = self.p._should_download('el', self.stats, None, False)
            self.assertEqual(res, False)
            res = self.p._should_download('el', self.stats, None, True)
            self.assertEqual(res, False)
            res = self.p._should_download('en', self.stats, None, False)
            self.assertEqual(res, True)
            res = self.p._should_download('en', self.stats, None, True)
            self.assertEqual(res, True)

            with patch.object(self.p, '_remote_is_newer'):
                res = self.p._should_download('pt', self.stats, None, False)
                self.assertEqual(res, True)
                res = self.p._should_download('pt', self.stats, None, True)
                self.assertEqual(res, True)

    def test_get_url_by_pull_mode(self):
        self.assertEqual(
            'pull_sourceastranslation_file',
            self.p._get_url_by_pull_mode(mode='sourceastranslation')
        )
        self.assertEqual(
            DEFAULT_PULL_URL,
            self.p._get_url_by_pull_mode(mode='invalid mode')
        )
        self.assertEqual(
            DEFAULT_PULL_URL,
            self.p._get_url_by_pull_mode(mode=None)
        )

    def fixture_mocked_project(func):
        """A mock object with main os and http operations mocked"""
        @wraps(func)
        def wrapper(*args, **kwargs):
            app_dir = dirname(modules['txclib'].__file__)
            config_file = app_dir + "/../tests/templates/config"
            transifex_file = app_dir + "/../tests/templates/transifexrc"
            with patch("txclib.utils.encode_args") as mock_encode_args, \
                patch("txclib.utils.determine_charset")\
                    as mock_determine_charset, \
                    patch("txclib.utils.get_transifex_file",
                          return_value=transifex_file) \
                    as mock_get_transifex_file, \
                    patch("txclib.utils.get_config_file_path",
                          return_value=config_file) \
                    as mock_get_config_file_path, \
                    patch("txclib.utils.save_txrc_file") \
                    as mock_save_txrc_file, \
                    patch("txclib.project.Project._get_stats_for_resource") \
开发者ID:transifex,项目名称:transifex-client,代码行数:70,代码来源:test_project.py


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