File: test_policy.py

package info (click to toggle)
debgpt 0.7.7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,068 kB
  • sloc: python: 6,149; makefile: 34
file content (67 lines) | stat: -rw-r--r-- 2,247 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'''
Copyright (C) 2024-2025 Mo Zhou <lumin@debian.org>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.
'''
import os
import pytest
from debgpt.policy import DebianPolicy
from debgpt.policy import DebianDevref


def test_policy(tmpdir: str) -> None:
    """
    Test the DebianPolicy class by checking specific sections.

    Args:
        tmpdir (str): The temporary directory to use for testing.
    """
    policy = DebianPolicy()
    # specific section of the policy, indexed by section number (as string)
    for section in ('1', '4.6', '4.9.1'):
        text = policy[section]
    # Convert the entire policy to a string
    whole = str(policy)
    assert len(whole) > 1000

    # test __iter__ and __next__
    for i, section in enumerate(policy):
        assert isinstance(section, str)
        assert len(section) > 0

    # test __len__
    assert len(policy) > 0

    # test __getitem__ with int
    for i in range(len(policy)):
        text = policy[i]
        assert len(text) > 0


@pytest.mark.parametrize('section', ('2', '2.1', '3.1.1'))
def test_devref(tmpdir: str, section: str) -> None:
    """
    Test the DebianDevref class by checking specific sections.

    Args:
        tmpdir (str): The temporary directory to use for testing.
        section (str): The section of the Debian Developer's Reference to test.
    """
    devref = DebianDevref()
    # Print the specific section of the developer's reference
    print(devref[section])
    # Convert the entire developer's reference to a string
    whole = str(devref)
    # Assert that the entire developer's reference string is longer than 1000 characters
    assert len(whole) > 1000