StrictDoc Documentation
tests/unit/strictdoc/backend/sdoc_source_code/test_marker_writer.py
Source file coverage
Path:
tests/unit/strictdoc/backend/sdoc_source_code/test_marker_writer.py
Lines:
72
Non-empty lines:
62
Non-empty lines covered with requirements:
62 / 62 (100.0%)
Functions:
2
Functions covered by requirements:
2 / 2 (100.0%)
1
"""
2
@relation(SDOC-SRS-34, SDOC-SRS-141, scope=file)
3
"""
4
 
5
from strictdoc.backend.sdoc_source_code.marker_parser import MarkerParser
6
from strictdoc.backend.sdoc_source_code.marker_writer import MarkerWriter
7
 
8
 
9
def test_write_doxygen_comment():
10
    input_string = """\
11
/**
12
 * Some text.
13
 *
14
 * @relation(
15
 *     REQ-1,
16
 *     REQ-2,
17
 *     REQ-3,
18
 *     scope=function
19
 * )
20
 * @relation(
21
 *     REQ-4,
22
 *     REQ-5,
23
 *     REQ-6,
24
 *     scope=function
25
 * )
26
 */
27
"""
28
 
29
    source_node = MarkerParser.parse(
30
        input_string=input_string,
31
        line_start=1,
32
        line_end=16,
33
        comment_line_start=1,
34
        comment_byte_range=None,
35
    )
36
 
37
    output_string = MarkerWriter().write(
38
        source_node,
39
        rewrites={},
40
        comment_file_bytes=bytes(input_string, encoding="utf8"),
41
    )
42
    assert output_string == bytes(input_string, encoding="utf8")
43
 
44
 
45
def test_write_node_fields():
46
    input_string = """\
47
/**
48
 * FOO: BAR
49
 */
50
"""
51
 
52
    source_node = MarkerParser.parse(
53
        input_string=input_string,
54
        line_start=1,
55
        line_end=16,
56
        comment_line_start=1,
57
        comment_byte_range=None,
58
        custom_tags={"FOO"},
59
    )
60
 
61
    expected_output_string = b"""\
62
/**
63
 * FOO: <MODIFIED>
64
 */
65
"""
66
 
67
    output_string = MarkerWriter().write(
68
        source_node,
69
        rewrites={"FOO": b"<MODIFIED>"},
70
        comment_file_bytes=bytes(input_string, encoding="utf8"),
71
    )
72
    assert output_string == expected_output_string