File: test_need_id_from_title.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 (37 lines) | stat: -rw-r--r-- 1,061 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
from pathlib import Path

import pytest


@pytest.mark.parametrize(
    "test_app",
    [{"buildername": "html", "srcdir": "doc_test/doc_need_id_from_title"}],
    indirect=True,
)
def test_doc_build_html(test_app):
    app = test_app
    app.build()
    html = Path(app.outdir, "index.html").read_text()
    assert html

    # check need_id_length
    need_id_length = app.config.needs_id_length
    assert need_id_length == 20

    # check generated id from title for need directive story
    assert "US_A_STORY_TITLE_2FD447" in html
    assert "US_CONTENT_ID_TEST_A313" in html

    # check need directive story prefix
    needs_types = app.config.needs_types
    need_directive_story_prefix = ""
    for need_type in needs_types:
        if need_type["directive"] == "story":
            need_directive_story_prefix = need_type["prefix"]

    assert len("US_A_STORY_TITLE_2FD447") == need_id_length + len(
        need_directive_story_prefix
    )
    assert len("US_CONTENT_ID_TEST_A313") == need_id_length + len(
        need_directive_story_prefix
    )