Skip to content

Commit 3375caf

Browse files
authored
Merge pull request #2258 from strictdoc-project/stanislaw/create_SECTION
tests/end2end: create [[SECTION]], deprecate create [SECTION]
2 parents 3c4cc8c + e040170 commit 3375caf

File tree

22 files changed

+212
-64
lines changed

22 files changed

+212
-64
lines changed

.coveragerc.unit

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
branch = True
33
omit =
44
build/
5+
output/
6+
strictdoc/server/
57

68
[report]
7-
fail_under = 60.0
9+
fail_under = 50.0
810
precision = 2
911
skip_covered = true
1012
show_missing = true

strictdoc/backend/sdoc/models/document_grammar.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
RequirementFieldName,
1616
)
1717
from strictdoc.helpers.auto_described import auto_described
18+
from strictdoc.helpers.exception import StrictDocException
1819
from strictdoc.helpers.mid import MID
1920

2021

@@ -108,20 +109,20 @@ def __init__(
108109
statement_field or description_field or content_field or ("", -1)
109110
)
110111

111-
# Some nodes have the content field, e.g., STATEMENT or DESCRIPTION,
112-
# some don't. For those that don't, use TITLE as a boundary between
113-
# the single-line and multiline.
114-
multiline_field_index = self.content_field[1]
115-
if multiline_field_index == -1:
116-
try:
117-
multiline_field_index = self.get_field_titles().index("TITLE")
118-
except ValueError as value_error_:
119-
raise RuntimeError(
112+
# Use TITLE as a boundary between the single-line and multiline, if
113+
# TITLE exists. For nodes without a TITLE, use the content field, e.g.,
114+
# STATEMENT or DESCRIPTION.
115+
try:
116+
multiline_field_index = self.get_field_titles().index("TITLE") + 1
117+
except ValueError:
118+
multiline_field_index = self.content_field[1]
119+
if multiline_field_index == -1:
120+
raise StrictDocException(
120121
(
121122
f"The grammar element {self.tag} must have at least one of the "
122123
f"following fields: TITLE, STATEMENT, DESCRIPTION, CONTENT."
123124
),
124-
) from value_error_
125+
) from None
125126
self.multiline_field_index: int = multiline_field_index
126127

127128
self.mid: MID = MID.create()

strictdoc/export/html/templates/components/node/node_controls/index.jinja

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
data-turbo-action="replace"
129129
data-turbo="true"
130130
title="Add first child SECTION"
131-
data-testid="node-add-section-first-action"
131+
data-testid="node-add-section-DEPRECATED-first-action"
132132
>{% include "_res/svg_ico16_add_child.jinja" %}</a>
133133
</li>
134134

@@ -166,7 +166,7 @@
166166
data-turbo-action="replace"
167167
data-turbo="true"
168168
title="Add SECTION above"
169-
data-testid="node-add-section-above-action"
169+
data-testid="node-add-section-DEPRECATED-above-action"
170170
>{% include "_res/svg_ico16_add_above.jinja" %}</a>
171171
</li>
172172
<li>{# 2 • Section -> add Section #}
@@ -184,7 +184,7 @@
184184
data-turbo-action="replace"
185185
data-turbo="true"
186186
title="Add SECTION below"
187-
data-testid="node-add-section-below-action"
187+
data-testid="node-add-section-DEPRECATED-below-action"
188188
>{% include "_res/svg_ico16_add_below.jinja" %}</a>
189189
</li>
190190

@@ -239,7 +239,7 @@
239239
data-turbo-action="replace"
240240
data-turbo="true"
241241
title="Add SECTION above"
242-
data-testid="node-add-section-above-action"
242+
data-testid="node-add-section-DEPRECATED-above-action"
243243
>{% include "_res/svg_ico16_add_above.jinja" %}</a>
244244
</li>
245245
<li>{# 3 • Requirement -> add Section #}
@@ -248,7 +248,7 @@
248248
data-turbo-action="replace"
249249
data-turbo="true"
250250
title="Add SECTION below"
251-
data-testid="node-add-section-below-action"
251+
data-testid="node-add-section-DEPRECATED-below-action"
252252
>{% include "_res/svg_ico16_add_below.jinja" %}</a>
253253
</li>
254254

strictdoc/server/helpers/turbo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from markupsafe import Markup
22

33

4-
# mypy: disable-error-code="no-untyped-def"
54
def render_turbo_stream(content: str, action: str, target: str) -> Markup:
65
assert action in ("append", "replace", "update")
76

tasks.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,13 +353,19 @@ def test_unit(context, focus=None):
353353
)
354354

355355

356-
@task(test_unit)
356+
@task(test_unit, aliases=["tuc"])
357357
def test_unit_report(context):
358+
cwd = os.getcwd()
359+
360+
path_to_coverage_file = f"{cwd}/build/coverage/unit/.coverage"
361+
358362
run_invoke_with_tox(
359363
context,
360364
ToxEnvironment.CHECK,
361-
"""
365+
f"""
362366
coverage html
367+
--rcfile=.coveragerc.unit
368+
--data-file={path_to_coverage_file}
363369
""",
364370
)
365371

tests/end2end/helpers/components/node/add_node_menu.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def assert_node_has_action_add_requirement_above(self) -> None:
3737
def assert_node_has_action_add_section_above(self) -> None:
3838
self.test_case.assert_element_present(
3939
f"{self.node_xpath}"
40-
'//*[@data-testid="node-add-section-above-action"]'
40+
'//*[@data-testid="node-add-section-DEPRECATED-above-action"]'
4141
)
4242

4343
def assert_node_has_action_add_requirement_below(self) -> None:
@@ -49,7 +49,7 @@ def assert_node_has_action_add_requirement_below(self) -> None:
4949
def assert_node_has_action_add_section_below(self) -> None:
5050
self.test_case.assert_element_present(
5151
f"{self.node_xpath}"
52-
'//*[@data-testid="node-add-section-below-action"]'
52+
'//*[@data-testid="node-add-section-DEPRECATED-below-action"]'
5353
)
5454

5555
def assert_node_has_action_add_requirement_child(self) -> None:
@@ -71,7 +71,7 @@ def do_node_add_section_first(self) -> Form_EditSection:
7171
self.test_case.click(
7272
selector=(
7373
'//*[@data-testid="node-root"]'
74-
'//*[@data-testid="node-add-section-first-action"]'
74+
'//*[@data-testid="node-add-section-DEPRECATED-first-action"]'
7575
),
7676
by=By.XPATH,
7777
)
@@ -82,7 +82,7 @@ def do_node_add_section_above(self) -> Form_EditSection:
8282
self.test_case.click(
8383
selector=(
8484
f"{self.node_xpath}"
85-
'//*[@data-testid="node-add-section-above-action"]'
85+
'//*[@data-testid="node-add-section-DEPRECATED-above-action"]'
8686
),
8787
by=By.XPATH,
8888
)
@@ -92,7 +92,7 @@ def do_node_add_section_below(self) -> Form_EditSection:
9292
self.test_case.click(
9393
selector=(
9494
f"{self.node_xpath}"
95-
'//*[@data-testid="node-add-section-below-action"]'
95+
'//*[@data-testid="node-add-section-DEPRECATED-below-action"]'
9696
),
9797
by=By.XPATH,
9898
)

tests/end2end/screens/document/create_requirement/_SingleChoice/create_requirement_SingleChoice_field_using_autocomplete/expected_output/document.sdoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ ELEMENTS:
2525
- TITLE: TAGS
2626
TYPE: String
2727
REQUIRED: False
28-
- TITLE: TITLE
29-
TYPE: String
30-
REQUIRED: False
3128
- TITLE: OWNER
3229
TYPE: SingleChoice(Abigail ACCURACY, Basil BOUNDARY, Clarence COMPLIANCE, Daphne DESIGN, Fiona FRAMEWORK, Felix FUNCTIONAL, Gloria GOVERNANCE, Gertrude GUIDELINE, Hugo HARMONY, Harvey HIERARCHY, Lydia LOGIC, Olivia OBJECTIVE, Mildred METADATA, Nigel NORMATIVE, Penelope PROCEDURE, Rachel RATIONALE, Eleanor RIGOR, Samuel SPECIFICATION, Sylvia STANDARD, Theodore TRACEABILITY, Victor VALIDATION, Walter WORKFLOW)
3330
REQUIRED: False
31+
- TITLE: TITLE
32+
TYPE: String
33+
REQUIRED: False
3434
- TITLE: STATEMENT
3535
TYPE: String
3636
REQUIRED: False
@@ -68,8 +68,8 @@ Shall test foo.
6868
[REQUIREMENT]
6969
UID: REQ-2
7070
STATUS: accepted
71-
TITLE: Requirement 2 XYZ
7271
OWNER: Abigail ACCURACY
72+
TITLE: Requirement 2 XYZ
7373
STATEMENT: >>>
7474
Shall test foo 2.
7575
<<<

tests/end2end/screens/document/create_requirement/_SingleChoice/create_requirement_SingleChoice_field_using_autocomplete/input/document.sdoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ ELEMENTS:
2525
- TITLE: TAGS
2626
TYPE: String
2727
REQUIRED: False
28-
- TITLE: TITLE
29-
TYPE: String
30-
REQUIRED: False
3128
- TITLE: OWNER
3229
TYPE: SingleChoice(Abigail ACCURACY, Basil BOUNDARY, Clarence COMPLIANCE, Daphne DESIGN, Fiona FRAMEWORK, Felix FUNCTIONAL, Gloria GOVERNANCE, Gertrude GUIDELINE, Hugo HARMONY, Harvey HIERARCHY, Lydia LOGIC, Olivia OBJECTIVE, Mildred METADATA, Nigel NORMATIVE, Penelope PROCEDURE, Rachel RATIONALE, Eleanor RIGOR, Samuel SPECIFICATION, Sylvia STANDARD, Theodore TRACEABILITY, Victor VALIDATION, Walter WORKFLOW)
3330
REQUIRED: False
31+
- TITLE: TITLE
32+
TYPE: String
33+
REQUIRED: False
3434
- TITLE: STATEMENT
3535
TYPE: String
3636
REQUIRED: False
Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,35 @@
11
[DOCUMENT]
22
TITLE: Document 1
33

4-
[SECTION]
4+
[GRAMMAR]
5+
ELEMENTS:
6+
- TAG: SECTION
7+
PROPERTIES:
8+
IS_COMPOSITE: True
9+
PREFIX: None
10+
FIELDS:
11+
- TITLE: MID
12+
TYPE: String
13+
REQUIRED: False
14+
- TITLE: UID
15+
TYPE: String
16+
REQUIRED: False
17+
- TITLE: TITLE
18+
TYPE: String
19+
REQUIRED: True
20+
- TAG: TEXT
21+
PROPERTIES:
22+
VIEW_STYLE: Narrative
23+
FIELDS:
24+
- TITLE: MID
25+
TYPE: String
26+
REQUIRED: True
27+
- TITLE: STATEMENT
28+
TYPE: String
29+
REQUIRED: True
30+
31+
[[SECTION]]
532
UID: SECTION-UID
633
TITLE: First title
734

8-
[/SECTION]
35+
[[/SECTION]]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,29 @@
11
[DOCUMENT]
22
TITLE: Document 1
3+
4+
[GRAMMAR]
5+
ELEMENTS:
6+
- TAG: SECTION
7+
PROPERTIES:
8+
IS_COMPOSITE: True
9+
PREFIX: None
10+
FIELDS:
11+
- TITLE: MID
12+
TYPE: String
13+
REQUIRED: False
14+
- TITLE: UID
15+
TYPE: String
16+
REQUIRED: False
17+
- TITLE: TITLE
18+
TYPE: String
19+
REQUIRED: True
20+
- TAG: TEXT
21+
PROPERTIES:
22+
VIEW_STYLE: Narrative
23+
FIELDS:
24+
- TITLE: MID
25+
TYPE: String
26+
REQUIRED: True
27+
- TITLE: STATEMENT
28+
TYPE: String
29+
REQUIRED: True

0 commit comments

Comments
 (0)