File: test_add_sections_sigs.py

package info (click to toggle)
sphinx-needs 5.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 11,924 kB
  • sloc: python: 21,132; javascript: 187; makefile: 89; sh: 29; xml: 10
file content (43 lines) | stat: -rw-r--r-- 1,179 bytes parent folder | download
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
import json
import re
from pathlib import Path

import pytest
from sphinx.testing.util import SphinxTestApp


@pytest.mark.parametrize(
    "test_app",
    [
        {
            "buildername": "html",
            "srcdir": "doc_test/add_sections_sigs",
            "no_plantuml": True,
        }
    ],
    indirect=True,
)
def test_section_is_usable_in_filters(test_app: SphinxTestApp, snapshot):
    app = test_app
    app.build()
    assert not app._warning.getvalue()

    needs_data = json.loads(Path(app.outdir, "needs.json").read_text())
    assert needs_data["versions"][""]["needs"] == snapshot

    html = Path(app.outdir, "index.html").read_text()

    tables = re.findall("(<table .*?</table>)", html, re.DOTALL)
    assert len(tables) == 5

    # All requirements should be in first table
    assert "R_12345" in tables[3]
    assert "First Section" in tables[3]
    assert "R_12346" in tables[3]
    assert "Second Section" in tables[3]

    # Only requirements from the first section should be in table 2
    assert "R_12345" in tables[4]
    assert "First Section" in tables[4]
    assert "R_12346" not in tables[4]
    assert "Second Section" not in tables[4]