test_models.py 4.07 KB
Newer Older
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
from typing import List, Optional, Tuple

from pytest import mark

from repo_management import models


@mark.parametrize(
    "output_package, package_desc, files",
    [
        (
            models.OutputPackage(
                arch="foo",
                builddate=1,
                csize=1,
                desc="foo",
                filename="foo",
                files=["foo", "bar"],
                isize=1,
                license=["foo"],
                md5sum="foo",
                name="foo",
                pgpsig="foo",
                sha256sum="foo",
                url="foo",
            ),
            models.PackageDesc(
                arch="foo",
                base="foo",
                builddate=1,
                csize=1,
                desc="foo",
                filename="foo",
                isize=1,
                license=["foo"],
                md5sum="foo",
                name="foo",
                packager="foo",
                pgpsig="foo",
                sha256sum="foo",
                url="foo",
                version="foo",
            ),
            models.Files(files=["foo", "bar"]),
        ),
        (
            models.OutputPackage(
                arch="foo",
                builddate=1,
                csize=1,
                desc="foo",
                filename="foo",
                isize=1,
                license=["foo"],
                md5sum="foo",
                name="foo",
                pgpsig="foo",
                sha256sum="foo",
                url="foo",
            ),
            models.PackageDesc(
                arch="foo",
                base="foo",
                builddate=1,
                csize=1,
                desc="foo",
                filename="foo",
                isize=1,
                license=["foo"],
                md5sum="foo",
                name="foo",
                packager="foo",
                pgpsig="foo",
                sha256sum="foo",
                url="foo",
                version="foo",
            ),
            None,
        ),
    ],
)
def test_package_desc_get_output_package(
    output_package: models.OutputPackage,
    package_desc: models.PackageDesc,
    files: Optional[models.Files],
) -> None:
    assert output_package == package_desc.get_output_package(files)


@mark.parametrize(
    "models_list, output_package_base",
    [
        (
            [
                (
                    models.PackageDesc(
                        arch="foo",
                        base="foo",
                        builddate=1,
                        csize=1,
                        desc="foo",
                        filename="foo",
                        isize=1,
                        license=["foo"],
                        md5sum="foo",
                        name="foo",
                        packager="foo",
                        pgpsig="foo",
                        sha256sum="foo",
                        url="foo",
                        version="foo",
                    ),
                    models.Files(files=["foo", "bar"]),
                ),
            ],
            models.OutputPackageBase(
                base="foo",
                packager="foo",
                version="foo",
                packages=[
                    models.OutputPackage(
                        arch="foo",
                        builddate=1,
                        csize=1,
                        desc="foo",
                        filename="foo",
                        files=["foo", "bar"],
                        isize=1,
                        license=["foo"],
                        md5sum="foo",
                        name="foo",
                        pgpsig="foo",
                        sha256sum="foo",
                        url="foo",
                    ),
                ],
            ),
        ),
    ],
)
def test_output_package_base_get_packages_as_models(
    models_list: List[Tuple[models.PackageDesc, models.Files]],
    output_package_base: models.OutputPackageBase,
) -> None:
    assert models_list == output_package_base.get_packages_as_models()