Path:
tests/unit_server/strictdoc/server/02_export_document_to_reqif/test_case.py
Lines:
50
Non-empty lines:
39
Non-empty lines covered with requirements:
39 / 39 (100.0%)
Functions:
1
Functions covered by requirements:
1 / 1 (100.0%)
1
"""2
@relation(SDOC-SRS-72, scope=file)3
"""4
5
import os
6
import re
7
import shutil
8
9
from fastapi.testclient import TestClient
10
11
from strictdoc.commands.server_config import ServerCommandConfig
12
from strictdoc.core.project_config import ProjectConfig, ProjectFeature
13
from strictdoc.server.app import create_app
14
15
PATH_TO_THIS_TEST_FOLDER = os.path.dirname(os.path.abspath(__file__))
16
PATH_TO_OUTPUT_FOLDER = os.path.join(PATH_TO_THIS_TEST_FOLDER, "output")
17
18
19
def test_export_document_to_reqif():
20
shutil.rmtree(PATH_TO_OUTPUT_FOLDER, ignore_errors=True)
21
22
server_config = ServerCommandConfig(
23
debug=False,
24
command="server",
25
input_path=PATH_TO_THIS_TEST_FOLDER,
26
output_path=PATH_TO_OUTPUT_FOLDER,
27
config=None,
28
reload=False,
29
host="127.0.0.1",
30
port=8001,
31
)32
project_config: ProjectConfig = ProjectConfig.default_config()
33
project_config.project_features.append(ProjectFeature.REQIF)
34
project_config.integrate_server_config(server_config)
35
36
client = TestClient(create_app(project_config=project_config))
37
response = client.get("/02_export_document_to_reqif/sample.html")
38
assert response.status_code == 200
39
40
response_body = response.content.decode()
41
42
match_document_mid = re.search(
43
r"/reqif/export_document/(?P<document_mid>[a-z0-9]+)", response_body
44
)45
assert match_document_mid is not None
46
document_mid = match_document_mid.group("document_mid")
47
48
response = client.get(f"/reqif/export_document/{document_mid}")
49
assert response.status_code == 200
50
assert "<REQ-IF xmlns=" in response.content.decode()