本文整理汇总了Python中snippets.base.tests.ClientMatchRuleFactory类的典型用法代码示例。如果您正苦于以下问题:Python ClientMatchRuleFactory类的具体用法?Python ClientMatchRuleFactory怎么用?Python ClientMatchRuleFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ClientMatchRuleFactory类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_multi_match
def test_multi_match(self):
client = self._client(version='1.0', locale='en-US')
pass_rule = ClientMatchRuleFactory(version='1.0', locale='en-US')
fail_rule = ClientMatchRuleFactory(version='1.0', locale='fr')
ok_(pass_rule.matches(client))
ok_(not fail_rule.matches(client))
示例2: test_regex_match
def test_regex_match(self):
client = self._client(version='15.2.4')
pass_rule = ClientMatchRuleFactory(version='/[\d\.]+/')
fail_rule = ClientMatchRuleFactory(version='/\D+/')
ok_(pass_rule.matches(client))
ok_(not fail_rule.matches(client))
示例3: test_string_match
def test_string_match(self):
client = self._client(channel='aurora')
pass_rule = ClientMatchRuleFactory(channel='aurora')
fail_rule = ClientMatchRuleFactory(channel='nightly')
ok_(pass_rule.matches(client))
ok_(not fail_rule.matches(client))
示例4: test_exclusion_rule_match
def test_exclusion_rule_match(self):
client = self._client(channel='aurora')
fail_rule = ClientMatchRuleFactory(channel='aurora', is_exclusion=True)
pass_rule = ClientMatchRuleFactory(channel='nightly',
is_exclusion=True)
ok_(pass_rule.matches(client))
ok_(not fail_rule.matches(client))
示例5: _dup_test
def _dup_test(self, snippet):
snippet.client_match_rules.add(*ClientMatchRuleFactory.create_batch(3))
snippet_copy = snippet.duplicate()
eq_(snippet_copy.disabled, True)
ok_(snippet_copy.id != snippet.id)
eq_(snippet_copy.locale_set.count(), 1)
ok_(snippet_copy.locale_set.all()[0] != snippet.locale_set.all()[0])
eq_(set(snippet_copy.client_match_rules.all()), set(snippet.client_match_rules.all()))
示例6: _dup_test
def _dup_test(self, snippet):
snippet.client_match_rules.add(*ClientMatchRuleFactory.create_batch(3))
snippet_copy = snippet.duplicate()
self.assertEqual(snippet_copy.disabled, True)
self.assertTrue(snippet_copy.id != snippet.id)
self.assertEqual(snippet_copy.locales.count(), 1)
self.assertTrue(snippet_copy.locales.all()[0] == snippet.locales.all()[0])
self.assertEqual(set(snippet_copy.client_match_rules.all()),
set(snippet.client_match_rules.all()))
示例7: test_basic
def test_basic(self, matches):
rule1_pass = ClientMatchRuleFactory.create()
rule2_pass = ClientMatchRuleFactory.create()
rule3_fail = ClientMatchRuleFactory.create()
rule4_pass = ClientMatchRuleFactory.create()
rule5_fail = ClientMatchRuleFactory.create()
return_values = {
rule1_pass.id: True,
rule2_pass.id: True,
rule3_fail.id: False,
rule4_pass.id: True,
rule5_fail.id: False,
}
matches.side_effect = lambda self, client: return_values.get(self.id, False)
passed, failed = self.manager.all().evaluate('asdf')
eq_(set([rule1_pass, rule2_pass, rule4_pass]), set(passed))
eq_(set([rule3_fail, rule5_fail]), set(failed))
示例8: test_empty_match
def test_empty_match(self):
client = self._client(version='1.0', locale='fr')
rule = ClientMatchRuleFactory()
ok_(rule.matches(client))