File: test_list2need.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 (70 lines) | stat: -rw-r--r-- 2,467 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
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
from pathlib import Path

import pytest

from sphinx_needs.api import get_needs_view


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

    view = get_needs_view(app)
    assert dict(view) == snapshot

    index_html = Path(app.outdir, "index.html").read_text()
    assert "NEED-002" in index_html
    assert "Sub-Need on level 3" in index_html
    assert (
        '<a class="reference internal" href="#test"><span class="std std-ref">Test chapter</span></a>'
        in index_html
    )

    # Check parent-child linking (nested)
    assert (
        '<span class="parent_needs"><span><a class="reference internal" href="#NEED-002" title="NEED-003">NEED-002</a></span></span>'
        in index_html
    )

    options_html = Path(app.outdir, "options.html").read_text()

    assert '<span class="needs_label">status: </span>' in options_html
    assert '<span class="needs_data">done</span>' in options_html
    assert '<span class="needs_data">in progress</span>' in options_html

    # check for 2 links
    assert (
        '<div class="line">links outgoing: <span class="links"><span><a class="reference internal" href="#NEED-1" '
        'title="NEED-3">NEED-1</a>, <a class="reference internal" href="#NEED-2" title="NEED-3">NEED-2</a></span>'
        "</span></div>" in options_html
    )

    # check for option defined in own, new line
    assert (
        '<div class="line">links outgoing: <span class="links"><span><a class="reference internal" href="#NEED-3" '
        'title="NEED-4">NEED-3</a></span></span></div>' in options_html
    )

    links_down_html = Path(app.outdir, "links_down.html").read_text()

    assert (
        '<div class="line">checks: <span class="checks"><span><a class="reference internal" href="#NEED-B" '
        'title="NEED-A">NEED-B</a></span></span></div>' in links_down_html
    )

    assert (
        '<div class="line">triggers: <span class="triggers"><span><a class="reference internal" href="#NEED-C" '
        'title="NEED-B">NEED-C</a></span></span></div>' in links_down_html
    )

    assert (
        '<div class="line">is triggered by: <span class="triggers"><span><a class="reference internal" '
        'href="#NEED-B" title="NEED-C">NEED-B</a></span></span></div>'
        in links_down_html
    )