File: obsoletes.py

package info (click to toggle)
libmodulemd 2.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,152 kB
  • sloc: ansic: 37,845; python: 3,236; xml: 1,739; sh: 377; makefile: 42
file content (72 lines) | stat: -rw-r--r-- 2,116 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/python3

# This file is part of libmodulemd
# Copyright (C) 2020 Red Hat, Inc.
#
# Fedora-License-Identifier: MIT
# SPDX-2.0-License-Identifier: MIT
# SPDX-3.0-License-Identifier: MIT
#
# This program is free software.
# For more information on the license, see COPYING.
# For more information on free software, see
# <https://www.gnu.org/philosophy/free-sw.en.html>.

import sys

try:
    import unittest
    import gi

    gi.require_version("Modulemd", "2.0")
    from gi.repository import Modulemd
except ImportError:
    # Return error 77 to skip this test on platforms without the necessary
    # python modules
    sys.exit(77)

from base import TestBase


class TestObsoletes(TestBase):
    def test_constructors(self):

        # Test that the new() function works
        o = Modulemd.Obsoletes.new(1, 2, "testmodule", "teststream", "testmsg")
        assert o
        assert o.props.mdversion == 1
        assert o.props.modified == 2
        assert o.props.module_name == "testmodule"
        assert o.props.module_stream == "teststream"
        assert o.props.message == "testmsg"

        # Test that keywords are accepted
        o = Modulemd.Obsoletes(
            mdversion=1,
            modified=42,
            module_name="testmodule2",
            module_stream="teststream2",
            message="testmessage2",
        )
        assert o
        assert o.validate()
        assert o.props.mdversion == 1
        assert o.props.modified == 42
        assert o.props.module_name == "testmodule2"
        assert o.props.module_stream == "teststream2"
        assert o.props.message == "testmessage2"

    def test_copy(self):
        o = Modulemd.Obsoletes.new(1, 2, "testmodule", "teststream", "testmsg")
        o_copy = o.copy()
        assert o_copy
        assert o_copy.validate()
        assert o_copy.props.mdversion == 1
        assert o_copy.props.modified == 2
        assert o_copy.props.module_name == "testmodule"
        assert o_copy.props.module_stream == "teststream"
        assert o_copy.props.message == "testmsg"


if __name__ == "__main__":
    unittest.main()