Exemplo n.º 1
0
    def test_with_scope_types(self):
        operations = [{
            'method': 'GET',
            'path': '/foo'
        }, {
            'method': 'POST',
            'path': '/some'
        }]
        scope_types = ['bar']
        rule = policy.DocumentedRuleDefault('rule_a',
                                            '@',
                                            'My sample rule',
                                            operations,
                                            scope_types=scope_types)

        results = '\n'.join(
            list(sphinxext._format_policy_section('foo', [rule])))

        self.assertEqual(
            textwrap.dedent("""
        foo
        ===

        ``rule_a``
            :Default: ``@``
            :Operations:
                - **GET** ``/foo``
                - **POST** ``/some``
            :Scope Types:
                - **bar**

            My sample rule
        """).lstrip(), results)
Exemplo n.º 2
0
    def test_with_operations(self):
        results = '\n'.join(
            list(
                sphinxext._format_policy_section('foo', [
                    policy.DocumentedRuleDefault(
                        'rule_a', '@', 'My sample rule', [{
                            'method': 'GET',
                            'path': '/foo'
                        }, {
                            'method': 'POST',
                            'path': '/some'
                        }])
                ])))

        self.assertEqual(
            textwrap.dedent("""
        foo
        ===

        ``rule_a``
            :Default: ``@``
            :Operations:
                - **GET** ``/foo``
                - **POST** ``/some``

            My sample rule
        """).lstrip(), results)
Exemplo n.º 3
0
    def test_minimal(self):
        results = '\n'.join(list(sphinxext._format_policy_section(
            'foo', [policy.RuleDefault('rule_a', '@')])))

        self.assertEqual(textwrap.dedent("""
        foo
        ===

        ``rule_a``
            :Default: ``@``

            (no description provided)
        """).lstrip(), results)
Exemplo n.º 4
0
    def test_with_description(self):
        results = '\n'.join(list(sphinxext._format_policy_section(
            'foo', [policy.RuleDefault('rule_a', '@', 'My sample rule')]
        )))

        self.assertEqual(textwrap.dedent("""
        foo
        ===

        ``rule_a``
            :Default: ``@``

            My sample rule
        """).lstrip(), results)