File: test_dnf_conf.py

package info (click to toggle)
dnf 4.5.2-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 10,556 kB
  • sloc: python: 26,916; xml: 778; sh: 131; makefile: 42
file content (114 lines) | stat: -rw-r--r-- 3,998 bytes parent folder | download | duplicates (4)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# -*- coding: utf-8 -*-


from __future__ import absolute_import
from __future__ import unicode_literals

import dnf

from .common import TestCase


class DnfConfTest(TestCase):
    def setUp(self):
        self.base = dnf.Base(dnf.conf.Conf())
        self.conf = self.base.conf

    def tearDown(self):
        self.base.close()

    def test_priorities(self):
        self.assertHasAttr(dnf.conf.config, "PRIO_EMPTY")
        self.assertHasType(dnf.conf.config.PRIO_EMPTY, int)

        self.assertHasAttr(dnf.conf.config, "PRIO_DEFAULT")
        self.assertHasType(dnf.conf.config.PRIO_DEFAULT, int)

        self.assertHasAttr(dnf.conf.config, "PRIO_MAINCONFIG")
        self.assertHasType(dnf.conf.config.PRIO_MAINCONFIG, int)

        self.assertHasAttr(dnf.conf.config, "PRIO_AUTOMATICCONFIG")
        self.assertHasType(dnf.conf.config.PRIO_AUTOMATICCONFIG, int)

        self.assertHasAttr(dnf.conf.config, "PRIO_REPOCONFIG")
        self.assertHasType(dnf.conf.config.PRIO_REPOCONFIG, int)

        self.assertHasAttr(dnf.conf.config, "PRIO_PLUGINDEFAULT")
        self.assertHasType(dnf.conf.config.PRIO_PLUGINDEFAULT, int)

        self.assertHasAttr(dnf.conf.config, "PRIO_PLUGINCONFIG")
        self.assertHasType(dnf.conf.config.PRIO_PLUGINCONFIG, int)

        self.assertHasAttr(dnf.conf.config, "PRIO_COMMANDLINE")
        self.assertHasType(dnf.conf.config.PRIO_COMMANDLINE, int)

        self.assertHasAttr(dnf.conf.config, "PRIO_RUNTIME")
        self.assertHasType(dnf.conf.config.PRIO_RUNTIME, int)

    def test_get_reposdir(self):
        # Conf.get_reposdir
        self.conf.reposdir = ["."]
        self.assertHasAttr(self.conf, "get_reposdir")
        self.assertHasType(self.conf.get_reposdir, str)

    def test_substitutions(self):
        # Conf.substitutions
        self.assertHasAttr(self.conf, "substitutions")
        self.assertHasType(self.conf.substitutions, dnf.conf.substitutions.Substitutions)

    def test_tempfiles(self):
        # Conf.tempfiles
        self.assertHasAttr(self.conf, "tempfiles")
        self.assertHasType(self.conf.tempfiles, list)

    def test_exclude_pkgs(self):
        # Conf.exclude_pkgs
        self.assertHasAttr(self.conf, "exclude_pkgs")
        self.conf.exclude_pkgs(pkgs=["package_a", "package_b"])

    def test_prepend_installroot(self):
        # Conf.prepend_installroot
        self.assertHasAttr(self.conf, "prepend_installroot")
        self.conf.prepend_installroot(optname="logdir")

    def test_read(self):
        # Conf.read
        self.assertHasAttr(self.conf, "read")
        self.conf.read(filename=None, priority=dnf.conf.config.PRIO_DEFAULT)

    def test_dump(self):
        # Conf.dump
        self.assertHasAttr(self.conf, "dump")
        self.assertHasType(self.conf.dump(), str)

    def test_releasever(self):
        # Conf.releasever
        self.assertHasAttr(self.conf, "releasever")
        self.conf.releasever = "test setter"
        self.assertHasType(self.conf.releasever, str)

    def test_arch(self):
        # Conf.arch
        self.assertHasAttr(self.conf, "arch")
        self.conf.arch = "aarch64"
        self.assertHasType(self.conf.arch, str)

    def test_basearch(self):
        # Conf.basearch
        self.assertHasAttr(self.conf, "basearch")
        self.conf.basearch = "aarch64"
        self.assertHasType(self.conf.basearch, str)

    def test_write_raw_configfile(self):
        # Conf.write_raw_configfile
        self.assertHasAttr(self.conf, "write_raw_configfile")
        s = dnf.conf.substitutions.Substitutions()
        self.conf.write_raw_configfile(filename="file.conf", section_id='main', substitutions=s, modify={})


class DnfSubstitutionsTest(TestCase):
    def test_update_from_etc(self):
        # Substitutions.update_from_etc
        substitutions = dnf.conf.substitutions.Substitutions()
        self.assertHasAttr(substitutions, "update_from_etc")
        substitutions.update_from_etc(installroot="path", varsdir=("/etc/path/", "/etc/path2"))