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


Python conditions.ConditionSet类代码示例

本文整理汇总了Python中djblets.conditions.ConditionSet的典型用法代码示例。如果您正苦于以下问题:Python ConditionSet类的具体用法?Python ConditionSet怎么用?Python ConditionSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: _create_config

    def _create_config(self, job_name='job_1', with_local_site=False):
        """Create an integration config.

        Args:
            job_name (string, optional):
                The Jenkins job name, which is used in constructing the
                URL to start a build on Jenkins.
        """
        choice = ReviewRequestRepositoriesChoice()

        condition_set = ConditionSet(conditions=[
            Condition(choice=choice,
                      operator=choice.get_operator('any'))
        ])

        if with_local_site:
            local_site = self.get_local_site(name=self.local_site_name)
        else:
            local_site = None

        config = self.integration.create_config(name='Config 1',
                                                enabled=True,
                                                local_site=local_site)
        config.set('conditions', condition_set.serialize())
        config.set('jenkins_job_name', job_name)
        config.set('jenkins_endpoint', 'http://localhost:8000')
        config.set('jenkins_username', 'admin')
        config.set('jenkins_password', 'admin')

        config.save()

        return config
开发者ID:reviewboard,项目名称:rbintegrations,代码行数:32,代码来源:tests.py

示例2: test_matches_with_none_op

    def test_matches_with_none_op(self):
        """Testing RepositoriesChoice.matches with "none" operator"""
        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('none')),
        ])

        self.assertTrue(condition_set.matches(repository=None))
        self.assertFalse(condition_set.matches(
            repository=self.create_repository()))
开发者ID:darmhoo,项目名称:reviewboard,代码行数:9,代码来源:test_conditions.py

示例3: test_matches_with_is_private_op

    def test_matches_with_is_private_op(self):
        """Testing RepositoriesChoice.matches with "is-private" operator"""
        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('is-private')),
        ])

        self.assertTrue(condition_set.matches(
            repository=self.create_repository(name='repo1', public=False)))
        self.assertFalse(condition_set.matches(
            repository=self.create_repository(name='repo2', public=True)))
开发者ID:darmhoo,项目名称:reviewboard,代码行数:10,代码来源:test_conditions.py

示例4: test_matches_with_any_op

    def test_matches_with_any_op(self):
        """Testing ReviewRequestRepositoriesChoice.matches with "any" operator
        """
        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('any')),
        ])

        self.assertTrue(condition_set.matches(
            review_request=self.create_review_request(create_repository=True)))
        self.assertFalse(condition_set.matches(
            review_request=self.create_review_request()))
开发者ID:davidt,项目名称:reviewboard,代码行数:11,代码来源:test_conditions.py

示例5: test_matches_with_is_op

    def test_matches_with_is_op(self):
        """Testing ReviewRequestAllDiffFilesChoice.matches with "is" operator
        """
        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('is'), 'file1'),
        ])
        self.assertFalse(condition_set.matches(
            review_request=self.review_request))

        self.filediff2.delete()
        self.assertTrue(condition_set.matches(
            review_request=self.review_request))
开发者ID:davidt,项目名称:reviewboard,代码行数:12,代码来源:test_conditions.py

示例6: test_matches_with_none_op

    def test_matches_with_none_op(self):
        """Testing ReviewGroupsChoice.matches with "none" operator"""
        self.create_review_group(name='group1')

        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('none')),
        ])

        self.assertTrue(condition_set.matches(
            review_groups=Group.objects.none()))
        self.assertFalse(condition_set.matches(
            review_groups=Group.objects.all()))
开发者ID:davidt,项目名称:reviewboard,代码行数:12,代码来源:test_conditions.py

示例7: test_matches_with_not_one_of_op

    def test_matches_with_not_one_of_op(self):
        """Testing RepositoriesChoice.matches with "not-one-of" operator"""
        repository1 = self.create_repository(name='repo1')
        repository2 = self.create_repository(name='repo2')
        repository3 = self.create_repository(name='repo3')

        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('not-one-of'),
                      [repository1, repository2])
        ])

        self.assertFalse(condition_set.matches(repository=repository1))
        self.assertFalse(condition_set.matches(repository=repository2))
        self.assertTrue(condition_set.matches(repository=repository3))
开发者ID:darmhoo,项目名称:reviewboard,代码行数:14,代码来源:test_conditions.py

示例8: test_matches_with_any_public_op

    def test_matches_with_any_public_op(self):
        """Testing ReviewGroupsChoice.matches with "any-public" operator"""
        group1 = self.create_review_group(name='group1', invite_only=False)
        group2 = self.create_review_group(name='group2', invite_only=True)

        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('any-public')),
        ])

        self.assertTrue(condition_set.matches(
            review_groups=Group.objects.filter(pk=group1.pk)))
        self.assertFalse(condition_set.matches(
            review_groups=Group.objects.filter(pk=group2.pk)))
        self.assertFalse(condition_set.matches(
            review_groups=Group.objects.none()))
开发者ID:davidt,项目名称:reviewboard,代码行数:15,代码来源:test_conditions.py

示例9: test_matches_with_not_one_of_op

    def test_matches_with_not_one_of_op(self):
        """Testing ReviewRequestSubmitterChoice.matches with "not-one-of"
        operator
        """
        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice,
                      self.choice.get_operator('not-one-of'),
                      [self.user1, self.user2]),
        ])

        self.assertFalse(condition_set.matches(
            review_request=self.create_review_request(submitter=self.user1)))
        self.assertFalse(condition_set.matches(
            review_request=self.create_review_request(submitter=self.user2)))
        self.assertTrue(condition_set.matches(
            review_request=self.create_review_request(submitter=self.user3)))
开发者ID:davidt,项目名称:reviewboard,代码行数:16,代码来源:test_conditions.py

示例10: test_matches_with_contains_any_op

    def test_matches_with_contains_any_op(self):
        """Testing ReviewGroupsChoice.matches with "contains-any" operator"""
        group1 = self.create_review_group(name='group1')
        group2 = self.create_review_group(name='group2')
        group3 = self.create_review_group(name='group3')

        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('contains-any'),
                      [group1, group2])
        ])

        self.assertTrue(condition_set.matches(
            review_groups=Group.objects.filter(pk=group1.pk)))
        self.assertFalse(condition_set.matches(
            review_groups=Group.objects.filter(pk=group3.pk)))
        self.assertFalse(condition_set.matches(
            review_groups=Group.objects.none()))
开发者ID:davidt,项目名称:reviewboard,代码行数:17,代码来源:test_conditions.py

示例11: test_matches_with_contains_op

    def test_matches_with_contains_op(self):
        """Testing ReviewRequestAnyDiffFileChoice.matches with "contains"
        operator
        """
        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('contains'),
                      '1'),
        ])
        self.assertTrue(condition_set.matches(
            review_request=self.review_request))

        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('contains'),
                      '3'),
        ])
        self.assertFalse(condition_set.matches(
            review_request=self.review_request))
开发者ID:davidt,项目名称:reviewboard,代码行数:17,代码来源:test_conditions.py

示例12: test_matches_with_starts_with_op

    def test_matches_with_starts_with_op(self):
        """Testing ReviewRequestAllDiffFilesChoice.matches with "starts-with"
        operator
        """
        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('starts-with'),
                      'file'),
        ])
        self.assertTrue(condition_set.matches(
            review_request=self.review_request))

        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('starts-with'),
                      'file1'),
        ])
        self.assertFalse(condition_set.matches(
            review_request=self.review_request))
开发者ID:davidt,项目名称:reviewboard,代码行数:17,代码来源:test_conditions.py

示例13: test_matches_with_matches_regex_op

    def test_matches_with_matches_regex_op(self):
        """Testing ReviewRequestAnyDiffFileChoice.matches with "matches-regex"
        operator
        """
        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('matches-regex'),
                      re.compile(r'^[Ff]ile1$')),
        ])
        self.assertTrue(condition_set.matches(
            review_request=self.review_request))

        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('matches-regex'),
                      re.compile('^\d')),
        ])
        self.assertFalse(condition_set.matches(
            review_request=self.review_request))
开发者ID:davidt,项目名称:reviewboard,代码行数:17,代码来源:test_conditions.py

示例14: test_matches_with_ends_with_op

    def test_matches_with_ends_with_op(self):
        """Testing ReviewRequestAnyDiffFileChoice.matches with "ends-with"
        operator
        """
        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('ends-with'),
                      'le1'),
        ])
        self.assertTrue(condition_set.matches(
            review_request=self.review_request))

        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice, self.choice.get_operator('ends-with'),
                      'xyz'),
        ])
        self.assertFalse(condition_set.matches(
            review_request=self.review_request))
开发者ID:davidt,项目名称:reviewboard,代码行数:17,代码来源:test_conditions.py

示例15: test_matches_with_does_not_contain_any_op

    def test_matches_with_does_not_contain_any_op(self):
        """Testing ReviewRequestParticipantChoice.matches with
        "does-not-contain-any" operator
        """
        condition_set = ConditionSet(ConditionSet.MODE_ALL, [
            Condition(self.choice,
                      self.choice.get_operator('does-not-contain-any'),
                      [self.user1, self.user2]),
        ])

        review_request = self.create_review_request()
        self.assertTrue(condition_set.matches(review_request=review_request))

        review_request = self.create_review_request()
        self.create_review(review_request,
                           user=self.user1,
                           public=True)
        self.assertFalse(condition_set.matches(review_request=review_request))
开发者ID:chipx86,项目名称:reviewboard,代码行数:18,代码来源:test_conditions.py


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