Skip to content

Commit

Permalink
🧪 improve some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Sep 13, 2024
1 parent dc3242a commit d769707
Show file tree
Hide file tree
Showing 34 changed files with 413 additions and 542 deletions.
15 changes: 13 additions & 2 deletions sphinx_needs/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
from .configuration import ( # noqa: F401
from .configuration import (
add_dynamic_function,
add_extra_option,
add_need_type,
get_need_types,
)
from .need import add_external_need, add_need, del_need, make_hashed_id # noqa: F401
from .need import add_external_need, add_need, del_need, make_hashed_id

__all__ = (
"add_dynamic_function",
"add_extra_option",
"add_need_type",
"get_need_types",
"add_external_need",
"add_need",
"del_need",
"make_hashed_id",
)
70 changes: 70 additions & 0 deletions tests/__snapshots__/test_add_sections_sigs.ambr
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# name: test_section_is_usable_in_filters[test_app0]
dict({
'R_12345': dict({
'description': 'The Tool **shall** have a command line interface.',
'docname': 'index',
'external_css': 'external_link',
'full_title': 'Command line interface',
'id': 'R_12345',
'impacts': 'component_a',
'introduced': '1.0.0',
'layout': '',
'section_name': '1.1 First Section',
'sections': list([
'1.1 First Section',
'1 TEST DOCUMENT',
]),
'tags': list([
'test',
'test2',
]),
'target_id': 'R_12345',
'title': 'Command line interface',
'type': 'req',
'type_name': 'Requirement',
'updated': '1.5.1',
}),
'R_12346': dict({
'description': 'The Tool **shall** have a command line interface.',
'docname': 'index',
'external_css': 'external_link',
'full_title': 'Another Requirement',
'id': 'R_12346',
'impacts': 'component_b',
'introduced': '1.1.1',
'layout': '',
'section_name': '1.2 Second Section',
'sections': list([
'1.2 Second Section',
'1 TEST DOCUMENT',
]),
'tags': list([
'test',
'test2',
]),
'target_id': 'R_12346',
'title': 'Another Requirement',
'type': 'req',
'type_name': 'Requirement',
'updated': '1.4.0',
}),
'T_001': dict({
'description': '',
'docname': 'index',
'external_css': 'external_link',
'full_title': 'test method',
'id': 'T_001',
'layout': '',
'section_name': '1.3 need in API',
'sections': list([
'1.3 need in API',
'1 TEST DOCUMENT',
]),
'signature': 'test_method',
'target_id': 'T_001',
'title': 'test method',
'type': 'test',
'type_name': 'Test Case',
}),
})
# ---
35 changes: 35 additions & 0 deletions tests/__snapshots__/test_api_usage.ambr
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# name: test_api_add_type[test_app0]
list([
dict({
'color': '#BFD8D2',
'directive': 'story',
'prefix': 'US_',
'title': 'User Story',
}),
dict({
'color': '#FEDCD2',
'directive': 'spec',
'prefix': 'SP_',
'title': 'Specification',
}),
dict({
'color': '#DF744A',
'directive': 'impl',
'prefix': 'IM_',
'title': 'Implementation',
}),
dict({
'color': '#DCB239',
'directive': 'test',
'prefix': 'TC_',
'title': 'Test Case',
}),
dict({
'color': '#000000',
'directive': 'awesome',
'prefix': 'AW_',
'style': 'cloud',
'title': 'Awesome',
}),
])
# ---
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
<target anonymous="" ids="US_38823" refid="US_38823">
<Need classes="need need-story" ids="US_38823" refid="US_38823">
<target refid="needtable-index-0">
<Needtable caption="True" classes="" columns="('ID',\ 'ID') ('TITLE',\ 'Title') ('STATUS',\ 'Status') ('TYPE',\ 'Type') ('OUTGOING',\ 'Outgoing') ('TAGS',\ 'Tags')" colwidths="" docname="index" export_id="" filter="status == "open"" filter_code="[]" filter_func="True" filter_warning="True" ids="needtable-index-0" lineno="12" show_filters="False" show_parts="False" sort="id_complete" sort_by="True" status="" style="" style_col="" style_row="" tags="" target_id="needtable-index-0" types="">
<Needtable caption="Table from sphinx-needs 'needtable' directive" classes="" columns="('ID',\ 'ID') ('TITLE',\ 'Title') ('STATUS',\ 'Status') ('TYPE',\ 'Type') ('OUTGOING',\ 'Outgoing') ('TAGS',\ 'Tags')" colwidths="" docname="index" export_id="" filter="status == "open"" filter_code="[]" filter_func="True" filter_warning="True" ids="needtable-index-0" lineno="12" show_filters="False" show_parts="False" sort="id_complete" sort_by="True" status="" style="" style_col="" style_row="" tags="" target_id="needtable-index-0" types="">
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
extensions = ["sphinx_needs"]

needs_build_json = True
needs_json_remove_defaults = True

needs_extra_options = [
"introduced",
"updated",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ Second Section

The Tool **shall** have a command line interface.

need in API
-----------

.. py:class:: TestClass
This is a test class.

.. py:method:: test_method(self)
This is a test method.

.. test:: test method
:id: T_001

All Requirements
----------------

Expand All @@ -39,3 +53,4 @@ First Section Only
.. needtable::
:columns: id;title;sections
:filter: 'First Section' in sections[0] and sections[0].startswith('1.1')

32 changes: 0 additions & 32 deletions tests/doc_test/api_doc/conf.py

This file was deleted.

15 changes: 0 additions & 15 deletions tests/doc_test/api_doc/index.rst

This file was deleted.

32 changes: 0 additions & 32 deletions tests/doc_test/api_doc_awesome/conf.py

This file was deleted.

21 changes: 0 additions & 21 deletions tests/doc_test/api_doc_awesome/index.rst

This file was deleted.

37 changes: 0 additions & 37 deletions tests/doc_test/broken_tags_2/conf.py

This file was deleted.

22 changes: 0 additions & 22 deletions tests/doc_test/broken_tags_2/index.rst

This file was deleted.

1 change: 1 addition & 0 deletions tests/doc_test/doc_basic/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
project = "needs"
version = "0.1.0"
copyright = "2024"

Expand Down
2 changes: 1 addition & 1 deletion tests/doc_test/doc_basic/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ TEST DOCUMENT
:status: open


.. needtable::
.. needtable:: Table from sphinx-needs 'needtable' directive
:filter: status == "open"
44 changes: 0 additions & 44 deletions tests/doc_test/doc_build_latex/conf.py

This file was deleted.

Loading

0 comments on commit d769707

Please sign in to comment.