本文整理汇总了Python中txclib.project.Project._satisfies_min_translated方法的典型用法代码示例。如果您正苦于以下问题:Python Project._satisfies_min_translated方法的具体用法?Python Project._satisfies_min_translated怎么用?Python Project._satisfies_min_translated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txclib.project.Project
的用法示例。
在下文中一共展示了Project._satisfies_min_translated方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestProjectMinimumPercent
# 需要导入模块: from txclib.project import Project [as 别名]
# 或者: from txclib.project.Project import _satisfies_min_translated [as 别名]
class TestProjectMinimumPercent(unittest.TestCase):
"""Test the minimum-perc option."""
def setUp(self):
super(TestProjectMinimumPercent, self).setUp()
self.p = Project(init=False)
self.p.minimum_perc = None
self.p.resource = "resource"
def test_cmd_option(self):
"""Test command-line option."""
self.p.minimum_perc = 20
results = itertools.cycle([80, 90])
def side_effect(*args):
return next(results)
with patch.object(self.p, "get_resource_option") as mock:
mock.side_effect = side_effect
self.assertFalse(
self.p._satisfies_min_translated({'completed': '12%'})
)
self.assertTrue(
self.p._satisfies_min_translated({'completed': '20%'})
)
self.assertTrue(
self.p._satisfies_min_translated({'completed': '30%'})
)
def test_global_only(self):
"""Test only global option."""
results = itertools.cycle([80, None])
def side_effect(*args):
return next(results)
with patch.object(self.p, "get_resource_option") as mock:
mock.side_effect = side_effect
self.assertFalse(
self.p._satisfies_min_translated({'completed': '70%'})
)
self.assertTrue(
self.p._satisfies_min_translated({'completed': '80%'})
)
self.assertTrue(
self.p._satisfies_min_translated({'completed': '90%'})
)
def test_local_lower_than_global(self):
"""Test the case where the local option is lower than the global."""
results = itertools.cycle([80, 70])
def side_effect(*args):
return next(results)
with patch.object(self.p, "get_resource_option") as mock:
mock.side_effect = side_effect
self.assertFalse(
self.p._satisfies_min_translated({'completed': '60%'})
)
self.assertTrue(
self.p._satisfies_min_translated({'completed': '70%'})
)
self.assertTrue(
self.p._satisfies_min_translated({'completed': '80%'})
)
self.assertTrue(
self.p._satisfies_min_translated({'completed': '90%'})
)
def test_local_higher_than_global(self):
"""Test the case where the local option is lower than the global."""
results = itertools.cycle([60, 70])
def side_effect(*args):
return next(results)
with patch.object(self.p, "get_resource_option") as mock:
mock.side_effect = side_effect
self.assertFalse(
self.p._satisfies_min_translated({'completed': '60%'})
)
self.assertTrue(
self.p._satisfies_min_translated({'completed': '70%'})
)
self.assertTrue(
self.p._satisfies_min_translated({'completed': '80%'})
)
self.assertTrue(
self.p._satisfies_min_translated({'completed': '90%'})
)
def test_local_only(self):
"""Test the case where the local option is lower than the global."""
results = itertools.cycle([None, 70])
def side_effect(*args):
return next(results)
with patch.object(self.p, "get_resource_option") as mock:
#.........这里部分代码省略.........