本文整理匯總了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))