test_wiki_entities.py

tests/test_wiki_entities.py

Entity quick views: a modal per function on a flow, with the view strip (round 5, P5.6).

test_a_brief_is_plain_text_not_doxygen_xml

None test_wiki_entities.test_a_brief_is_plain_text_not_doxygen_xml(tmp_path)

Briefs without markup.

tests/test_wiki_entities.py:75

Show on the map →

Called by none

Calls _briefs

Checks

  • assert _briefs(conn) == {("f", "pkg/a.py"): "Hold a lock."}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003measuredtest_a_brief_is_plain_text_not_doxygen_xml → _briefs → strip_xml
REQ-DDB-WIKI-048catalog
Source · 20 lines
def test_a_brief_is_plain_text_not_doxygen_xml(tmp_path) -> None:
    """FOUND BY LOOKING: the quick view printed `<para>…</para>`. Briefs are read through
    `strip_xml`, as the step modal's are.

    @brief Briefs without markup.
    """
    import sqlite3

    from clew.wiki.entities import _briefs

    db = tmp_path / "b.db"
    conn = sqlite3.connect(db)
    conn.executescript(
        "CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT);"
        "CREATE TABLE memberdef (rowid INTEGER PRIMARY KEY, name TEXT, kind TEXT, file_id INT,"
        " bodyfile_id INT, briefdescription TEXT);"
        "INSERT INTO path VALUES (1, 'pkg/a.py');"
        "INSERT INTO memberdef VALUES (1, 'f', 'function', 1, 1, '<para>Hold a lock. </para>');"
    )
    assert _briefs(conn) == {("f", "pkg/a.py"): "Hold a lock."}

1 more lines, not shown

Activity · 6 steps
lines 81–81import sqlite3lines 83–83from clew.wiki.entities import _briefslines 85–85db = tmp_path / "b.db"lines 86–86conn = sqlite3.connect(db)lines 87–93conn.executescript( "CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT);" "CREATE TABLE memberdef (rowid INTEGER PRIMARY KEY, name TEXT, kind TEXT, file_id INT," " bodyfile_id INT, briefdescription TEXT);" "INSERT INTO path VALUES (1, 'pkg/a.py');" "INSERT INTO memberdef VALUES (1, 'f', 'function', 1, 1, '<para>Hold a lock. </para>');" )lines 94–94assert _briefs(conn) == {("f", "pkg/a.py"): "Hold a lock."}

test_a_long_list_is_capped_with_a_pointer_to_the_page

None test_wiki_entities.test_a_long_list_is_capped_with_a_pointer_to_the_page()

Eight tests: five shown, "3 more on its page" linking the function's page.

tests/test_wiki_entities.py:55

Show on the map →

Called by none

Calls _facts, quick_view

Checks

  • assert tests.count('href="test-t-') == 5
  • assert "3 more on its page" in tests and 'href="sym-pkg-store-py.html#s-save"' in tests

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-022measuredtest_a_long_list_is_capped_with_a_pointer_to_the_page → quick_view → _reqs → page_of
REQ-DDB-WIKI-048measuredtest_a_long_list_is_capped_with_a_pointer_to_the_page → quick_view
Source · 8 lines
def test_a_long_list_is_capped_with_a_pointer_to_the_page() -> None:
    """@brief Eight tests: five shown, "3 more on its page" linking the function's page."""
    html = quick_view(_facts())
    tests = html.split('data-view-panel="tests"', 1)[1].split("</section>", 1)[0]
    assert tests.count('href="test-t-') == 5
    assert "3 more on its page" in tests and 'href="sym-pkg-store-py.html#s-save"' in tests

Activity · 4 steps
lines 57–57html = quick_view(_facts())lines 58–58tests = html.split('data-view-panel="tests"', 1)[1].split("</section>", 1)[0]lines 59–59assert tests.count('href="test-t-') == 5lines 60–60assert "3 more on its page" in tests and 'href="sym-pkg-store-py.html#s-save"' in tests

test_an_empty_view_says_so

None test_wiki_entities.test_an_empty_view_says_so()

Empty views.

tests/test_wiki_entities.py:63

Show on the map →

Called by none

Calls _facts, quick_view

Checks

  • assert "No requirement names this function" in reqs
  • assert "No recorded run" in replay

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-022inferredtest_an_empty_view_says_so → quick_view → _reqs → page_of
REQ-DDB-WIKI-048measuredtest_an_empty_view_says_so → quick_view
Source · 12 lines
def test_an_empty_view_says_so() -> None:
    """ABSENCE IS STATED: no requirement and no recorded run are sentences, not blank tabs.

    @brief Empty views.
    """
    html = quick_view(_facts(reqs=(), replays=()))
    reqs = html.split('data-view-panel="reqs"', 1)[1].split("</section>", 1)[0]
    replay = html.split('data-view-panel="replay"', 1)[1].split("</section>", 1)[0]
    assert "No requirement names this function" in reqs
    assert "No recorded run" in replay

Activity · 5 steps
lines 68–68html = quick_view(_facts(reqs=(), replays=()))lines 69–69reqs = html.split('data-view-panel="reqs"', 1)[1].split("</section>", 1)[0]lines 70–70replay = html.split('data-view-panel="replay"', 1)[1].split("</section>", 1)[0]lines 71–71assert "No requirement names this function" in reqslines 72–72assert "No recorded run" in replay

test_the_view_strip_has_every_view_in_order

None test_wiki_entities.test_the_view_strip_has_every_view_in_order()

Map · Block · Flow · Replay · Source · Tests · Reqs, a tab and a panel each.

tests/test_wiki_entities.py:37

Show on the map →

Called by none

Calls _facts, all, quick_view

Checks

  • assert VIEWS == ("map", "block", "flow", "replay", "source", "tests", "reqs")
  • assert tabs == sorted(tabs) and all(f'data-view-panel="{v}"' in html for v in VIEWS)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-022measuredtest_the_view_strip_has_every_view_in_order → quick_view → _reqs → page_of
REQ-DDB-WIKI-048measuredtest_the_view_strip_has_every_view_in_order → quick_view
REQ-DDB-WIKI-054inferredtest_the_view_strip_has_every_view_in_order → all
Source · 8 lines
def test_the_view_strip_has_every_view_in_order() -> None:
    """@brief Map · Block · Flow · Replay · Source · Tests · Reqs, a tab and a panel each."""
    html = quick_view(_facts())
    assert VIEWS == ("map", "block", "flow", "replay", "source", "tests", "reqs")
    tabs = [html.split(f'data-view="{v}"', 1)[0].count("data-view=") for v in VIEWS]
    assert tabs == sorted(tabs) and all(f'data-view-panel="{v}"' in html for v in VIEWS)

Activity · 4 steps
lines 39–39html = quick_view(_facts())lines 40–40assert VIEWS == ("map", "block", "flow", "replay", "source", "tests", "reqs")lines 41–41tabs = [html.split(f'data-view="{v}"', 1)[0].count("data-view=") for v in VIEWS]lines 42–42assert tabs == sorted(tabs) and all(f'data-view-panel="{v}"' in html for v in VIEWS)