source: rtems-central/rtemsqual/tests/test_applconfig.py @ 3b9b2bd

Last change on this file since 3b9b2bd was 3b9b2bd, checked in by Sebastian Huber <sebastian.huber@…>, on 04/30/20 at 04:53:40

tests: Fix issues found by flake8

  • Property mode set to 100644
File size: 5.7 KB
Line 
1# SPDX-License-Identifier: BSD-2-Clause
2""" Unit tests for the rtemsqual.applconfig module. """
3
4# Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25# POSSIBILITY OF SUCH DAMAGE.
26
27import os
28import shutil
29
30from rtemsqual.applconfig import generate
31from rtemsqual.items import ItemCache
32
33
34def test_applconfig(tmpdir):
35    item_cache_config = {}
36    item_cache_config["cache-directory"] = "cache"
37    spec_src = os.path.join(os.path.dirname(__file__), "spec-applconfig")
38    spec_dst = os.path.join(tmpdir, "spec")
39    shutil.copytree(spec_src, spec_dst)
40    item_cache_config["paths"] = [os.path.normpath(spec_dst)]
41    ic = ItemCache(item_cache_config)
42
43    applconfig_config = {}
44    g_rst = os.path.join(tmpdir, "g.rst")
45    applconfig_config["groups"] = [{"uid": "/g", "target": g_rst}]
46    generate(applconfig_config, ic)
47
48    with open(g_rst, "r") as src:
49        content = """.. SPDX-License-Identifier: CC-BY-SA-4.0
50
51.. Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
52
53group name
54==========
55
56description
57
58.. index:: a
59.. index:: index a
60
61.. _a:
62
63a
64-
65
66CONSTANT:
67    ``a``
68
69OPTION TYPE:
70    This configuration option is a boolean feature define.
71
72DEFAULT CONFIGURATION:
73    default a
74
75DESCRIPTION:
76    description a
77
78NOTES:
79    notes a
80
81.. index:: b
82
83.. _b:
84
85b
86-
87
88CONSTANT:
89    ``b``
90
91OPTION TYPE:
92    This configuration option is a boolean feature define.
93
94DEFAULT CONFIGURATION:
95    If this configuration option is undefined, then the described feature is \
96not
97    enabled.
98
99DESCRIPTION:
100    description b
101
102NOTES:
103    None.
104
105.. index:: c
106
107.. _c:
108
109c
110-
111
112CONSTANT:
113    ``c``
114
115OPTION TYPE:
116    This configuration option is an integer define.
117
118DEFAULT VALUE:
119    The default value is 13.
120
121VALUE CONSTRAINTS:
122    The value of this configuration option shall satisfy all of the following
123    constraints:
124
125    * It shall be greater than or equal to -1.
126
127    * It shall be less than or equal to 99.
128
129    * custom c 1
130
131    * custom c 2
132
133    * constraint d
134
135DESCRIPTION:
136    description c
137
138NOTES:
139    notes c
140
141.. index:: e
142
143.. _e:
144
145e
146-
147
148CONSTANT:
149    ``e``
150
151OPTION TYPE:
152    This configuration option is an integer define.
153
154DEFAULT VALUE:
155    The default value is 7.
156
157VALUE CONSTRAINTS:
158    The value of this configuration option shall be greater than or equal to \
159-2.
160
161DESCRIPTION:
162    description e
163
164NOTES:
165    None.
166
167.. index:: f
168
169.. _f:
170
171f
172-
173
174CONSTANT:
175    ``f``
176
177OPTION TYPE:
178    This configuration option is an integer define.
179
180DEFAULT VALUE:
181    The default value is 1.
182
183VALUE CONSTRAINTS:
184    The value of this configuration option shall be less than or equal to 2.
185
186DESCRIPTION:
187    description f
188
189NOTES:
190    None.
191
192.. index:: h
193
194.. _h:
195
196h
197-
198
199CONSTANT:
200    ``h``
201
202OPTION TYPE:
203    This configuration option is an integer define.
204
205DEFAULT VALUE:
206    The default value is 1.
207
208VALUE CONSTRAINTS:
209    custom h
210
211DESCRIPTION:
212    description h
213
214NOTES:
215    None.
216
217.. index:: i
218
219.. _i:
220
221i
222-
223
224CONSTANT:
225    ``i``
226
227OPTION TYPE:
228    This configuration option is an integer define.
229
230DEFAULT VALUE:
231    The default value is 1.
232
233VALUE CONSTRAINTS:
234    The value of this configuration option shall be
235    an element of {1, 2, 3}.
236
237DESCRIPTION:
238    description i
239
240NOTES:
241    None.
242
243.. index:: j
244
245.. _j:
246
247j
248-
249
250CONSTANT:
251    ``j``
252
253OPTION TYPE:
254    This configuration option is an integer define.
255
256DEFAULT VALUE:
257    Foo bar.
258
259VALUE CONSTRAINTS:
260    The value of this configuration option shall satisfy all of the following
261    constraints:
262
263    * It shall be an element of [1, 2].
264
265    * constraint d
266
267DESCRIPTION:
268    description j
269
270NOTES:
271    None.
272
273.. index:: k
274
275.. _k:
276
277k
278-
279
280CONSTANT:
281    ``k``
282
283OPTION TYPE:
284    This configuration option is an integer define.
285
286DEFAULT VALUE:
287    The default value is 1.
288
289VALUE CONSTRAINTS:
290    The value of this configuration option shall satisfy all of the following
291    constraints:
292
293    * custom k 1
294
295    * custom k 2
296
297DESCRIPTION:
298    description k
299
300NOTES:
301    None.
302
303.. index:: l
304
305.. _l:
306
307l
308-
309
310CONSTANT:
311    ``l``
312
313OPTION TYPE:
314    This configuration option is an initializer define.
315
316DEFAULT VALUE:
317    The default value is 1.
318
319VALUE CONSTRAINTS:
320    The value of this configuration option shall be greater than or equal to 0
321    and less than or equal to 2.
322
323DESCRIPTION:
324    description l
325
326NOTES:
327    None.
328
329.. index:: m
330
331.. _m:
332
333m
334-
335
336CONSTANT:
337    ``m``
338
339OPTION TYPE:
340    This configuration option is an initializer define.
341
342DEFAULT VALUE:
343    The default value is 1.
344
345DESCRIPTION:
346    description m
347
348NOTES:
349    None.
350"""
351        assert content == src.read()
Note: See TracBrowser for help on using the repository browser.