def test_060_file_ref(): input = """ [DOCUMENT] TITLE: Test Doc [REQUIREMENT] REFS: - TYPE: File VALUE: /tmp/sample.cpp """.lstrip() reader = SDReader() document = reader.read(input) assert isinstance(document, Document) document: Document = reader.read(input) requirement = document.section_contents[0] assert len(requirement.references) == 1 assert requirement.references[0].ref_type == "File" assert requirement.references[0].path == "/tmp/sample.cpp" writer = SDWriter() output = writer.write(document) assert input == output
def test_030_multiline_statement(): input = """ [DOCUMENT] TITLE: Test Doc [SECTION] TITLE: Test Section [REQUIREMENT] STATEMENT: >>> This is a statement 1 This is a statement 2 This is a statement 3 <<< [/SECTION] """.lstrip() reader = SDReader() document = reader.read(input) assert isinstance(document, Document) writer = SDWriter() output = writer.write(document) assert input == output assert isinstance(document.section_contents[0].section_contents[0], Requirement) requirement_1 = document.section_contents[0].section_contents[0] assert ( requirement_1.statement_multiline == "This is a statement 1\nThis is a statement 2\nThis is a statement 3")
def test_045_composite_requirement_custom_fields(): input = """ [DOCUMENT] TITLE: Test Doc SPECIAL_FIELDS: - NAME: ECSS_VERIFICATION TYPE: String [COMPOSITE_REQUIREMENT] SPECIAL_FIELDS: ECSS_VERIFICATION: R,A,I,T STATEMENT: Some parent requirement statement [REQUIREMENT] STATEMENT: Some child requirement statement [/COMPOSITE_REQUIREMENT] """.lstrip() reader = SDReader() document = reader.read(input) assert isinstance(document, Document) writer = SDWriter() output = writer.write(document) assert input == output assert isinstance(document.section_contents[0], CompositeRequirement) composite_req = document.section_contents[0] assert composite_req.ng_level == 1 assert composite_req.special_fields[0].field_name == "ECSS_VERIFICATION" assert composite_req.special_fields[0].field_value == "R,A,I,T"
def test_001_custom_fields(): input = """ [DOCUMENT] TITLE: Test Doc SPECIAL_FIELDS: - NAME: OWNER TYPE: String - NAME: PRIORITY TYPE: String [REQUIREMENT] SPECIAL_FIELDS: OWNER: Person #1 PRIORITY: 1 TITLE: Requirement 1 """.lstrip() reader = SDReader() document = reader.read(input) assert isinstance(document, Document) requirement = document.section_contents[0] assert requirement.special_fields[0].field_name == "OWNER" assert requirement.special_fields[0].field_value == "Person #1" assert requirement.special_fields[1].field_name == "PRIORITY" assert requirement.special_fields[1].field_value == "1"
def test_036_rationale_singleline(): input = """ [DOCUMENT] TITLE: Test Doc [SECTION] TITLE: Test Section [REQUIREMENT] STATEMENT: Some statement RATIONALE: This is a Rationale [/SECTION] """.lstrip() reader = SDReader() document = reader.read(input) assert isinstance(document, Document) writer = SDWriter() output = writer.write(document) assert input == output assert isinstance(document.section_contents[0].section_contents[0], Requirement) requirement_1 = document.section_contents[0].section_contents[0] assert requirement_1.rationale == "This is a Rationale"
def test_002_no_special_fields_declared(): input = """ [DOCUMENT] TITLE: Hello world doc [REQUIREMENT] SPECIAL_FIELDS: ECSS_COMPLIANCE: Compliant """.lstrip() reader = SDReader() with pytest.raises( StrictDocSemanticError, match="Requirements special fields are not registered document-wide.", ) as _: reader.read(input)
def test_100_basic_test(): input = """ [DOCUMENT] TITLE: Test Doc SPECIAL_FIELDS: - NAME: ECSS_VERIFICATION TYPE: String [SECTION] TITLE: Test Section [REQUIREMENT] TAGS: Tag 1, Tag 2, Tag 3 SPECIAL_FIELDS: ECSS_VERIFICATION: R,A,I,T REFS: - TYPE: File VALUE: /usr/local/bin/hexe - TYPE: File VALUE: /usr/local/bin/hexe - TYPE: File VALUE: /usr/local/bin/hexe STATEMENT: System shall do X BODY: >>> This is an optional body of the requirement. This is an optional body of the requirement. <<< COMMENT: This requirement is very important [REQUIREMENT] UID: REQ-001 STATUS: Draft TITLE: Optional title B STATEMENT: System shall do Y COMMENT: This requirement is very important [/SECTION] """.lstrip() reader = SDReader() document = reader.read(input) assert isinstance(document, Document) assert isinstance(document.section_contents[0].section_contents[0], Requirement) requirement_1 = document.section_contents[0].section_contents[0] assert requirement_1.tags[0] == "Tag 1" assert requirement_1.tags[1] == "Tag 2" assert requirement_1.tags[2] == "Tag 3" writer = SDWriter() output = writer.write(document) assert input == output
def test_004_custom_field_undeclared(): input = """ [DOCUMENT] TITLE: Test Doc SPECIAL_FIELDS: - NAME: PRIORITY TYPE: String [REQUIREMENT] SPECIAL_FIELDS: OWNER: Person #1 TITLE: Requirement 1 """.lstrip() reader = SDReader() with pytest.raises( StrictDocSemanticError, match="Undeclared special field: OWNER." ) as _: reader.read(input)
def test_003_required_custom_field_missing(): input = """ [DOCUMENT] TITLE: Test Doc SPECIAL_FIELDS: - NAME: OWNER TYPE: String - NAME: PRIORITY TYPE: String REQUIRED: Yes [REQUIREMENT] SPECIAL_FIELDS: OWNER: Person #1 TITLE: Requirement 1 """.lstrip() reader = SDReader() with pytest.raises( StrictDocSemanticError, match="Requirement is missing a required special field: PRIORITY.", ) as _: reader.read(input)
def test_070_document_config_version(): input = """ [DOCUMENT] TITLE: Test Doc VERSION: 0.0.1 [REQUIREMENT] REFS: - TYPE: File VALUE: /tmp/sample.cpp """.lstrip() reader = SDReader() document = reader.read(input) assert isinstance(document, Document) document: Document = reader.read(input) assert document.config.version == "0.0.1" writer = SDWriter() output = writer.write(document) assert input == output
def test_071_document_config_number(): input = """ [DOCUMENT] TITLE: Test Doc NUMBER: SDOC-01 [REQUIREMENT] REFS: - TYPE: File VALUE: /tmp/sample.cpp """.lstrip() reader = SDReader() document = reader.read(input) assert isinstance(document, Document) document: Document = reader.read(input) assert document.config.number == "SDOC-01" writer = SDWriter() output = writer.write(document) assert input == output
def test_001_level_1_req(): input = """ [DOCUMENT] TITLE: Test Doc [REQUIREMENT] """.lstrip() reader = SDReader() document = reader.read(input) assert isinstance(document, Document) requirement = document.section_contents[0] assert requirement.ng_document_reference.get_document() == document assert requirement.document == document
def test_040_composite_requirement_1_level(): input = """ [DOCUMENT] TITLE: Test Doc [SECTION] TITLE: Test Section [COMPOSITE_REQUIREMENT] STATEMENT: Some parent requirement statement BODY: >>> This is a body part 1 This is a body part 2 This is a body part 3 <<< [REQUIREMENT] STATEMENT: Some child requirement statement BODY: >>> This is a child body part 1 This is a child body part 2 This is a child body part 3 <<< [/COMPOSITE_REQUIREMENT] [/SECTION] """.lstrip() reader = SDReader() document = reader.read(input) assert isinstance(document, Document) writer = SDWriter() output = writer.write(document) assert input == output assert isinstance(document.section_contents[0].section_contents[0], CompositeRequirement) requirement_1 = document.section_contents[0].section_contents[0] assert requirement_1.ng_level == 2 assert ( requirement_1.body == "This is a body part 1\nThis is a body part 2\nThis is a body part 3")
def test_020_free_text(): input = """ [DOCUMENT] TITLE: Test Doc [FREETEXT] Hello world [/FREETEXT] """.lstrip() reader = SDReader() document = reader.read(input) assert isinstance(document, Document) writer = SDWriter() output = writer.write(document) assert input == output
def test_001_minimal_doc(): input = """ [DOCUMENT] TITLE: Test Doc [REQUIREMENT] [REQUIREMENT] [REQUIREMENT] """.lstrip() reader = SDReader() document = reader.read(input) assert isinstance(document, Document) writer = SDWriter() output = writer.write(document) assert input == output
def test_010_multiple_sections(): input = """ [DOCUMENT] TITLE: Test Doc [SECTION] TITLE: Test Section [REQUIREMENT] STATEMENT: >>> This is a statement 1 This is a statement 2 This is a statement 3 <<< [/SECTION] [SECTION] TITLE: Test Section [REQUIREMENT] STATEMENT: >>> This is a statement 1 This is a statement 2 This is a statement 3 <<< [/SECTION] """.lstrip() reader = SDReader() document = reader.read(input) assert isinstance(document, Document) writer = SDWriter() output = writer.write(document) assert input == output
def test_002_level_2_req(): input = """ [DOCUMENT] TITLE: Test Doc [SECTION] TITLE: Section 1 [REQUIREMENT] [/SECTION] """.lstrip() reader = SDReader() document = reader.read(input) assert isinstance(document, Document) section = document.section_contents[0] req = section.section_contents[0] assert req.ng_document_reference.get_document() == document assert req.document == document
def test_042_composite_requirement_2_level(): input = """ [DOCUMENT] TITLE: Test Doc [SECTION] TITLE: Test Section [COMPOSITE_REQUIREMENT] STATEMENT: 1.1 composite req statement BODY: >>> body composite 1.1 <<< [COMPOSITE_REQUIREMENT] STATEMENT: 1.1.1 composite req statement BODY: >>> body composite 1.1.1 <<< [REQUIREMENT] STATEMENT: 1.1.1.1 composite req statement BODY: >>> body 1.1.1.1 <<< [/COMPOSITE_REQUIREMENT] [/COMPOSITE_REQUIREMENT] [/SECTION] """.lstrip() reader = SDReader() document = reader.read(input) assert isinstance(document, Document) writer = SDWriter() output = writer.write(document) assert input == output assert isinstance(document.section_contents[0].section_contents[0], CompositeRequirement) requirement_1_1 = document.section_contents[0].section_contents[0] assert requirement_1_1.ng_level == 2 assert requirement_1_1.body == "body composite 1.1" assert isinstance( document.section_contents[0].section_contents[0].requirements[0], CompositeRequirement, ) requirement_1_1_1 = ( document.section_contents[0].section_contents[0].requirements[0]) assert requirement_1_1_1.ng_level == 3 assert requirement_1_1_1.body == "body composite 1.1.1" assert isinstance( document.section_contents[0].section_contents[0].requirements[0]. requirements[0], Requirement, ) requirement_1_1_1 = (document.section_contents[0].section_contents[0]. requirements[0].requirements[0]) assert requirement_1_1_1.ng_level == 4 assert requirement_1_1_1.body == "body 1.1.1.1"