Skip to content

Commit

Permalink
Add regression tests for recent fixes
Browse files Browse the repository at this point in the history
Modules with more than one submodule would previously nest all but the
first submodule incorrectly so expand the tests for the Doxygenindex
Node to cover that.

Similarly, expand the Sect Node tests to cover its new support for
attributes.
  • Loading branch information
mudge committed Aug 22, 2024
1 parent 09e14b6 commit c086fe8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
33 changes: 32 additions & 1 deletion tests/test_doxygenindex_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test_to_asciidoc(tmp_path):
<compoundname>hardware_base</compoundname>
<title>hardware_base</title>
<innergroup refid="group__channel__config">channel_config</innergroup>
<innergroup refid="group__sm__config">sm_config</innergroup>
<briefdescription>
</briefdescription>
<detaileddescription>
Expand All @@ -59,6 +60,25 @@ def test_to_asciidoc(tmp_path):
<detaileddescription>
</detaileddescription>
</compoundef>
</doxygen>
"""
)
with open(
f"{tmp_path}/group__sm__config.xml", "w", encoding="utf-8"
) as channel_config:
channel_config.write(
"""\
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.9.7" xml:lang="en-US">
<compounddef id="group__sm__config" kind="group">
<compoundname>sm_config</compoundname>
<title>sm_config</title>
<briefdescription>
<para>PIO state machine configuration.</para>
</briefdescription>
<detaileddescription>
</detaileddescription>
</compoundef>
</doxygen>
"""
)
Expand All @@ -71,6 +91,8 @@ def test_to_asciidoc(tmp_path):
</compound>
<compound refid="group__channel__config" kind="group"><name>channel_config</name>
</compound>
<compound refid="group__sm__config" kind="group"><name>sm_config</name>
</compound>
</doxygenindex>
"""

Expand All @@ -92,6 +114,9 @@ def test_to_asciidoc(tmp_path):
|{nbsp}{nbsp}{nbsp}{nbsp}<<group_channel_config,channel_config>>
|DMA channel configuration.
|{nbsp}{nbsp}{nbsp}{nbsp}<<group_sm_config,sm_config>>
|PIO state machine configuration.
|===
[#group_hardware_base,reftext="hardware_base"]
Expand All @@ -106,9 +131,15 @@ def test_to_asciidoc(tmp_path):
===== Modules
<<group_channel_config,channel_config>>:: DMA channel configuration.
<<group_sm_config,sm_config>>:: PIO state machine configuration.
[#group_channel_config,reftext="channel_config"]
===== channel_config
DMA channel configuration."""
DMA channel configuration.
[#group_sm_config,reftext="sm_config"]
===== sm_config
PIO state machine configuration."""
)
20 changes: 19 additions & 1 deletion tests/test_sect_node.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from textwrap import dedent
from bs4 import BeautifulSoup
from doxygentoasciidoc.nodes import Node, SectNode
from doxygentoasciidoc.nodes import SectNode


def test_sect_node(tmp_path):
Expand All @@ -19,3 +19,21 @@ def test_sect_node(tmp_path):
Interrupts _are_ numbered as follows."""
)


def test_sect_node_with_attributes(tmp_path):
xml = """\
<sect1 id="foo" role="contextspecific" tag="PICO_2040" type="PICO_2040">
<title>Interrupt Numbers</title>
<para>Interrupts <emphasis>are</emphasis> numbered as follows.</para>
</sect1>"""

asciidoc = SectNode(BeautifulSoup(xml, "xml").sect1, xmldir=tmp_path).to_asciidoc()

assert asciidoc == dedent(
"""\
[#foo,role=contextspecific,tag=PICO_2040,type=PICO_2040]
== Interrupt Numbers
Interrupts _are_ numbered as follows."""
)

0 comments on commit c086fe8

Please sign in to comment.